aboutsummaryrefslogtreecommitdiffstats
path: root/tools/bpf/bpftool/prog.c
diff options
context:
space:
mode:
authorAlan Maguire <[email protected]>2022-03-30 15:26:37 +0000
committerAndrii Nakryiko <[email protected]>2022-04-04 01:12:05 +0000
commit433966e3ae04165811b116af492a684bad7a158c (patch)
tree27bd0ca269cbbb97d63b8c96b721874208a8a632 /tools/bpf/bpftool/prog.c
parentlibbpf: auto-resolve programs/libraries when necessary for uprobes (diff)
downloadkernel-433966e3ae04165811b116af492a684bad7a158c.tar.gz
kernel-433966e3ae04165811b116af492a684bad7a158c.zip
libbpf: Support function name-based attach uprobes
kprobe attach is name-based, using lookups of kallsyms to translate a function name to an address. Currently uprobe attach is done via an offset value as described in [1]. Extend uprobe opts for attach to include a function name which can then be converted into a uprobe-friendly offset. The calcualation is done in several steps: 1. First, determine the symbol address using libelf; this gives us the offset as reported by objdump 2. If the function is a shared library function - and the binary provided is a shared library - no further work is required; the address found is the required address 3. Finally, if the function is local, subtract the base address associated with the object, retrieved from ELF program headers. The resultant value is then added to the func_offset value passed in to specify the uprobe attach address. So specifying a func_offset of 0 along with a function name "printf" will attach to printf entry. The modes of operation supported are then 1. to attach to a local function in a binary; function "foo1" in "/usr/bin/foo" 2. to attach to a shared library function in a shared library - function "malloc" in libc. [1] https://www.kernel.org/doc/html/latest/trace/uprobetracer.html Signed-off-by: Alan Maguire <[email protected]> Signed-off-by: Andrii Nakryiko <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
Diffstat (limited to 'tools/bpf/bpftool/prog.c')
0 files changed, 0 insertions, 0 deletions