• Skip to main content
  • Skip to secondary menu
  • Skip to primary sidebar
  • Home
  • Contact Us

iHash

News and How to's

  • Prism Drive Secure Cloud Storage: Lifetime Subscription (10TB) for $89

    Prism Drive Secure Cloud Storage: Lifetime Subscription (10TB) for $89
  • Mashvisor: Lifetime Subscription (Professional Plan) for $199

    Mashvisor: Lifetime Subscription (Professional Plan) for $199
  • Beducated: Lifetime Subscription for $99

    Beducated: Lifetime Subscription for $99
  • Amysen Wi-Fi Smart Plug (4-Pack) for $23

    Amysen Wi-Fi Smart Plug (4-Pack) for $23
  • Refurbished Apple iPad 4 (2012) WiFi Black / 16GB / Grade A for $76

    Refurbished Apple iPad 4 (2012) WiFi Black / 16GB / Grade A for $76
  • News
    • Rumor
    • Design
    • Concept
    • WWDC
    • Security
    • BigData
  • Apps
    • Free Apps
    • OS X
    • iOS
    • iTunes
      • Music
      • Movie
      • Books
  • How to
    • OS X
      • OS X Mavericks
      • OS X Yosemite
      • Where Download OS X 10.9 Mavericks
    • iOS
      • iOS 7
      • iOS 8
      • iPhone Firmware
      • iPad Firmware
      • iPod touch
      • AppleTV Firmware
      • Where Download iOS 7 Beta
      • Jailbreak News
      • iOS 8 Beta/GM Download Links (mega links) and How to Upgrade
      • iPhone Recovery Mode
      • iPhone DFU Mode
      • How to Upgrade iOS 6 to iOS 7
      • How To Downgrade From iOS 7 Beta to iOS 6
    • Other
      • Disable Apple Remote Control
      • Pair Apple Remote Control
      • Unpair Apple Remote Control
  • Special Offers
  • Contact us

Code coverage for eBPF programs

Feb 4, 2022 by iHash Leave a Comment


By analyzing the resulting LLVM IR for source-based coverage instrumented programs, we should now have a better understanding of what we need to do for having it on eBPF programs running in the Linux kernel. We now know what to completely get rid of and do differently, and what we need to patch to make it loadable and usable by the BPF VM in the kernel.

The plan is simple: get Clang to instrument a BPF LLVM intermediate representation for source-based code coverage, then patch it to model it into a valid representation for BPF ELF. How do we need to transform it?

First of all, we are so lucky we don’t have to mess with the actual BPF instructions — namely the counters increments. We can keep them the way they are. This is a huge win because we let LLVM keep track of the global state of the registers and we avoid a lot of work this way.

But for sure we have to strip any profile initialization stuff that Clang creates, things like __llvm_profile_runtime and __llvm_profile_init – when present – are no good for the BPF VM in the kernel.

We also want to ensure the global variables, whether constants or not, have the right visibility (ie., dso_local) and linkage, to have them in the libbpf skeletons if we plan to use them.

For the global structs that we need for generating the profraw files, namely the __profd_ variables, we just transform them into different and single global variables, one for each field.

For example, this is what I did for the __profd_* variables which originally are a struct with 7 fields. For other global structs like the __covrec_ ones, we can just strip them from the BPF ELF that is meant to be loaded in the kernel.

Anyway, the report generation phase (ie., llvm-cov or bpfcov out) will need them for knowing at which line and column a code region or a branch starts. For this reason, I decided to give the LLVM pass an option (enabled with the strip-initializers-only flag) that keeps them, so we can later create a BPF ELF that is only meant for this phase and not for loading.

This BPF ELF will have .bpf.obj as an extension, rather than .bpf.o.

Finally, we know that libbpf supports (on recent Linux kernels) eBPF global variables, which are simply eBPF maps with one single value, and we are planning to use them. But, as already mentioned, it does not accept or recognize the ELF sections that the Clang instrumentation injects in the intermediate representation.

So we need our LLVM pass to change them to custom eBPF sections. The eBPF custom sections are in the form of .rodata.* or .data.* made to contain static and/or global data. We can change the section of the counters to be .data.profc. The section of the __llvm_prf_nm from _llvm_prf_names to .rodata.profn, and so on. You can find all this logic summarized in these bits of code.

So, assuming the following dummy eBPF program:



Source link

Share this:

  • Facebook
  • Twitter
  • Pinterest
  • LinkedIn

Filed Under: News Tagged With: CODE, coverage, eBPF, programs

Special Offers

  • Prism Drive Secure Cloud Storage: Lifetime Subscription (10TB) for $89

    Prism Drive Secure Cloud Storage: Lifetime Subscription (10TB) for $89
  • Mashvisor: Lifetime Subscription (Professional Plan) for $199

    Mashvisor: Lifetime Subscription (Professional Plan) for $199
  • Beducated: Lifetime Subscription for $99

    Beducated: Lifetime Subscription for $99
  • Amysen Wi-Fi Smart Plug (4-Pack) for $23

    Amysen Wi-Fi Smart Plug (4-Pack) for $23
  • Refurbished Apple iPad 4 (2012) WiFi Black / 16GB / Grade A for $76

    Refurbished Apple iPad 4 (2012) WiFi Black / 16GB / Grade A for $76

Reader Interactions

Leave a ReplyCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

  • Facebook
  • GitHub
  • Instagram
  • Pinterest
  • Twitter
  • YouTube

More to See

Mashvisor: Lifetime Subscription (Professional Plan) for $199

Oct 3, 2023 By iHash

What Does the Commercialization of Generative AI Mean for Society?

Oct 2, 2023 By iHash

Tags

* Apple attacks Cisco computer security cyber attacks cyber crime cyber news cybersecurity Cyber Security cyber security news cyber security news today cyber security updates cyber threats cyber updates data data breach data breaches google hacker hacker news Hackers hacking hacking news how to hack incident response information security iOS 7 iOS 8 iPhone Malware microsoft network security ransomware ransomware malware risk management security security breaches security vulnerabilities software vulnerability the hacker news Threat update video web applications

Latest

Prism Drive Secure Cloud Storage: Lifetime Subscription (10TB) for $89

Expires January 01, 2030 05:00 PST Buy now and get 87% off KEY FEATURES Free up space on your phone, tablet, laptop, or home computer. Keep all your important files securely in one place. Easily share large files, like video, graphics, images, and audio. Access files from your computer, your phone, or your tablet. Preview […]

Beducated: Lifetime Subscription for $99

Expires January 01, 2024 07:59 PST Buy now and get 66% off KEY FEATURES Learn how to have great sex with Beducated, the #1 online platform for pleasure-based sex education. The extensive library boasts 100+ online courses on everything from basic oral sex guides to rope-bondage tutorials, all produced by the world’s top experts. As […]

Amysen Wi-Fi Smart Plug (4-Pack) for $23

Expires October 03, 2123 07:59 PST Buy now and get 52% off KEY FEATURES Introducing the Amysen smart plug – your ultimate home automation solution. Compatible with Alexa and Google Assistant, this smart plug allows for voice control and seamless integration with your smart home ecosystem. The schedule feature enables you to set specific times […]

Video Highlights: Vicuña, Gorilla, Chatbot Arena and Socially Beneficial LLMs — with Prof. Joey Gonzalez

Why Car Storage Depends on the Right Workload Analysis In this sponsored post, Russell Ruben, director of automotive and emerging segment market, Western Digital, believes that as vehicle innovation continues over the next few years, driven by advances in sensors, 5G, AI, machine and deep learning and big data analytics, so must storage. Storage technology […]

Swift 5.9 Released

Swift 5.9 is now available! 🎉 This is a major new release that adds an expressive macro system to the language and introduces support for integrating Swift into C++ codebases through bidirectional interoperability. It also introduces parameter packs, an improved expression evaluator while debugging, enhanced crash handling, Windows platform improvements, and more. Read on for […]

Anaconda’s State of Data Science Report Report Reveals Surge in AI Upskilling Among Data and IT Professionals

Anaconda Inc., provider of the popular platform for data science and modern AI development, released its sixth annual State of Data Science report, surfacing insights into today’s vibrant data science community and the growth and usage of AI and open-source software.  Unlike previous years, the 2023 report delves into the ways generative artificial intelligence (AI) is reshaping […]

Jailbreak

Pangu Releases Updated Jailbreak of iOS 9 Pangu9 v1.2.0

Pangu has updated its jailbreak utility for iOS 9.0 to 9.0.2 with a fix for the manage storage bug and the latest version of Cydia. Change log V1.2.0 (2015-10-27) 1. Bundle latest Cydia with new Patcyh which fixed failure to open url scheme in MobileSafari 2. Fixed the bug that “preferences -> Storage&iCloud Usage -> […]

Apple Blocks Pangu Jailbreak Exploits With Release of iOS 9.1

Apple has blocked exploits used by the Pangu Jailbreak with the release of iOS 9.1. Pangu was able to jailbreak iOS 9.0 to 9.0.2; however, in Apple’s document on the security content of iOS 9.1, PanguTeam is credited with discovering two vulnerabilities that have been patched.

Pangu Releases Updated Jailbreak of iOS 9 Pangu9 v1.1.0

  Pangu has released an update to its jailbreak utility for iOS 9 that improves its reliability and success rate.   Change log V1.1.0 (2015-10-21) 1. Improve the success rate and reliability of jailbreak program for 64bit devices 2. Optimize backup process and improve jailbreak speed, and fix an issue that leads to fail to […]

Activator 1.9.6 Released With Support for iOS 9, 3D Touch

  Ryan Petrich has released Activator 1.9.6, an update to the centralized gesture, button, and shortcut manager, that brings support for iOS 9 and 3D Touch.

Copyright iHash.eu © 2023
We use cookies on this website. By using this site, you agree that we may store and access cookies on your device. Accept Read More
Privacy & Cookies Policy

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SAVE & ACCEPT