Skip to content
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.

sym_offset calculation in attach uprobe fails to account to address differences #356

Open
ajwerner opened this issue Dec 28, 2022 · 1 comment

Comments

@ajwerner
Copy link

BPF probes want the offset of a symbol in the object file. In shared object and executable files, at least, the current logic seems to return the virtual address of the symbol as opposed to the offset in the object file.

The st_value for a goblin::elf:sym::Sym with st_info of STT_FUNC (2) refers to the virtual memory address. In order to compute the offset, one needs to find the offset by translating it to be relative to the address of the section containing the symbol and then adding the offset of the section in the file.

The offending code is:

.st_value

In some cases, the address of the symbol is its offset, but certainly not in all cases.

See: bpftrace/bpftrace#1763 (comment)

@ajwerner
Copy link
Author

Fixed by #308; would it be possible to release a new version containing this fix?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant