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

Fix is_lib detection for PIE and static PIE Elf objects. #366

Merged
merged 3 commits into from
May 15, 2023

Conversation

m-hilgendorf
Copy link
Contributor

PIE executables (either static or dynamically linked) erroneously report is_lib == true, due to the fact that they have e_type == ET_DYN in their elf headers.

To distinguish you have to check if the DT_FLAGS_1 was set in the dynamics section.

The part that I'm not sure about is lazy_parse, which can't detect if something is a library or not.

Copy link
Owner

@m4b m4b left a comment

Choose a reason for hiding this comment

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

LGTM, thanks! lazy parsing is up to user to fill in rest of fields, i'm not sure what we do right now for is_lib?

@m4b m4b merged commit 9f7fb6b into m4b:master May 15, 2023
@m4b
Copy link
Owner

m4b commented May 15, 2023

non-breaking

@m-hilgendorf
Copy link
Contributor Author

I think right now what you do is check the e_type of the Elf header for ET_DYN. However, ET_DYN only implies the object is dynamic, not if it is a library. The field name is a bit misleading in that sense, it might make more to expose the type directly through an enum (including the other variants of e_type).

@m4b
Copy link
Owner

m4b commented Jun 12, 2023

released in 0.7.0, thank you so much for your patience!

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.

2 participants