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

Add support for STT_GNU_IFUNC and STT_OBJECT ELF symbols types #499

Merged
merged 6 commits into from
Jan 26, 2024
Merged

Add support for STT_GNU_IFUNC and STT_OBJECT ELF symbols types #499

merged 6 commits into from
Jan 26, 2024

Conversation

danielocfb
Copy link
Collaborator

Please see individual commits for descriptions.

The SymType enum is really fairly generic and not specific to the
inspect set of APIs. As such, it makes more sense to have it be defined
in and exposed by the library itself as opposed to a sub-module.
This change moves it out of the inspect module and into lib.rs.

Signed-off-by: Daniel Müller <deso@posteo.net>
The SymType enum may show up in both input and output contexts. E.g., in
the inspect API it is used to determine what symbols to report and at
the same time it is used to report the type of a symbol.
Having an 'Unknown' variant really only makes sense in an output
context. To make this variant less confusing, rename it to 'Undefined',
which elicits reasonable associations in both contexts.

Signed-off-by: Daniel Müller <deso@posteo.net>
Introduce the Elf64_Sym::matches() helper function that will allow us to
more easily support properly handling ELF symbols representing variables
as well as indirect functions down the line.

Signed-off-by: Daniel Müller <deso@posteo.net>
So far we have been caching all ELF symbols inside ElfParser objects.
That's arguably a bit of a waste, memory-wise.
With this change we make sure to keep around only those that the library
supports and knows what to do with.

Signed-off-by: Daniel Müller <deso@posteo.net>
So far the library was only concerned with support function symbols for
the various formats.
With this change we add support for reporting & querying ELF symbols
representing variables as well.

Signed-off-by: Daniel Müller <deso@posteo.net>
Add support for indirect functions to our ELF parser logic, such that
they are treated as regular functions from blazeym's perspective.

Closes: #210

Signed-off-by: Daniel Müller <deso@posteo.net>
Copy link

codecov bot commented Jan 25, 2024

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (a78a8ac) 0.00% compared to head (2d8f39e) 93.44%.
Report is 1 commits behind head on main.

❗ Current head 2d8f39e differs from pull request most recent head bed0e15. Consider uploading reports for the commit bed0e15 to get more accurate results

Files Patch % Lines
src/elf/types.rs 93.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##           main     #499       +/-   ##
=========================================
+ Coverage      0   93.44%   +93.44%     
=========================================
  Files         0       45       +45     
  Lines         0     7875     +7875     
=========================================
+ Hits          0     7359     +7359     
- Misses        0      516      +516     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@anakryiko anakryiko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@d-e-s-o d-e-s-o merged commit ab76985 into libbpf:main Jan 26, 2024
27 checks passed
@d-e-s-o d-e-s-o deleted the topic/gnu-ifunc branch January 26, 2024 14:35
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.

Correctly handle STT_GNU_IFUNC ELF symbols
3 participants