Giter Club home page Giter Club logo

ndk-build-ebpf-example's Introduction

ndk-build-ebpf-example

本项目用于演示如何使用NDK编译一个eBPF程序,主要参考为Android平台编译eBPF程序

步骤

准备工作

先同步需要的源代码,这里选择的是android11-gsi分支,可以根据自己的需求修改

git clone -b android11-gsi https://android.googlesource.com/platform/bionic --depth=1
git clone -b android11-gsi https://android.googlesource.com/platform/system/core --depth=1
git clone -b android11-gsi https://android.googlesource.com/platform/system/bpf --depth=1

整理文件结构

mkdir system && mv core system/ && mv bpf system/

然后准备好NDK,修改build.sh中的NDK_ROOT即可

编译

执行./build.sh即可,产物在out目录下

其他

Q: 和参考文章有什么不同吗?

A: 编译增加了-g选项,作用是生成带有BTF信息的.o文件

https://clang.llvm.org/docs/UsersManual.html#cmdoption-g

如果没有BTF信息,那么加载eBPF程序时会要求内核启用CONFIG_DEBUG_INFOCONFIG_DEBUG_INFO_BTF,否则无法正确加载

readelf -S out/stack.o | grep BTF

ndk-build-ebpf-example's People

Stargazers

 avatar  avatar ted avatar NLEG avatar 手机用户Xh2vb13n avatar heckerstone avatar Bowen Chen avatar

Watchers

 avatar SeeFlowerX avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.