OSDN Git Service

libbpf: Add support for attaching uprobes to shared objects in APKs
authorDaniel Müller <deso@posteo.net>
Wed, 1 Mar 2023 21:23:08 +0000 (21:23 +0000)
committerAndrii Nakryiko <andrii@kernel.org>
Thu, 2 Mar 2023 00:05:35 +0000 (16:05 -0800)
commitc44fd84507637f07ca9a7e16f83706e109f6b8ff
treea491598eedabc23d0d43ed42798fe8a21b307ed8
parent434fdcead73515a76885418ffe2d96b4f3ed0f49
libbpf: Add support for attaching uprobes to shared objects in APKs

This change adds support for attaching uprobes to shared objects located
in APKs, which is relevant for Android systems where various libraries
may reside in APKs. To make that happen, we extend the syntax for the
"binary path" argument to attach to with that supported by various
Android tools:
  <archive>!/<binary-in-archive>

For example:
  /system/app/test-app/test-app.apk!/lib/arm64-v8a/libc++_shared.so

APKs need to be specified via full path, i.e., we do not attempt to
resolve mere file names by searching system directories.

We cannot currently test this functionality end-to-end in an automated
fashion, because it relies on an Android system being present, but there
is no support for that in CI. I have tested the functionality manually,
by creating a libbpf program containing a uretprobe, attaching it to a
function inside a shared object inside an APK, and verifying the sanity
of the returned values.

Signed-off-by: Daniel Müller <deso@posteo.net>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20230301212308.1839139-4-deso@posteo.net
tools/lib/bpf/libbpf.c