Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve attaching to uprobes with size 0 #2562

Merged
merged 1 commit into from
Apr 14, 2023

Conversation

viktormalik
Copy link
Contributor

@viktormalik viktormalik commented Apr 12, 2023

Compilers do not set symbol size in the .symtab ELF section for some of their generated symbols (e.g. _init and _fini). This causes problems when attaching to these as we are not able to check offset.

This commit enables attachment to such functions if the offset is 0 and --unsafe is used. For other cases, appropriate error/warning is shown.

In total, there are multiple cases covered:

  • unsafe is on: allow attachment to symbols with size 0,
  • unsafe is off, attaching to multiple probes: skip symbols with size 0 and show a warning,
  • unsafe is off, attaching to a single probe: fail and show an error.

Added runtime tests for cases 1 and 3 but disabled them on embedded alpine builds since the _init symbol seems to have non-zero size there.

Fixes #2552, fixes #940.

Checklist
  • Language changes are updated in man/adoc/bpftrace.adoc and if needed in docs/reference_guide.md
  • User-visible and non-trivial changes updated in CHANGELOG.md
  • The new behaviour is covered by tests

@viktormalik viktormalik requested review from ajor, danobi and fbs as code owners April 12, 2023 08:42
Compilers do not set symbol size in the .symtab ELF section for some of
their generated symbols (e.g. _init and _fini). This causes problems
when attaching to these as we are not able to check offset.

This commit enables attachment to such functions if the offset is 0 and
--unsafe is used. For other cases, appropriate error/warning is shown.

In total, there are multiple cases covered:
- unsafe is on: allow attachment to symbols with size 0,
- unsafe is off, attaching to multiple probes: skip symbols with size 0
  and show a warning,
- unsafe is off, attaching to a single probe: fail and show an error.

Added runtime tests for cases 1 and 3 but disabled them on embedded
alpine builds since the _init symbol seems to have non-zero size there.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

uprobes: trying to trace all functions of a userspace program using '*' returns an error "Offset outside the function bounds" Can't attach to uprobes if .size information is missing
3 participants