-
Notifications
You must be signed in to change notification settings - Fork 0
PIE: data section + dynamic tags + PHDR layout #36
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8c3fd035a3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| def link(inputs: @inputs, output: @output, debug: @debug, shared: @shared, executable: @executable, pie: @pie) | ||
| return to_elf(inputs:, output:, debug:, shared:, executable:, pie:) if @linker == "self" | ||
|
|
||
| IO.popen(link_command).close |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honor pie flag for non-self linkers
When linker is not "self" (the default path), the pie flag is ignored and the code just runs link_command without adding a -pie/--pie option. This means callers using Linker.link!(..., pie: true, linker: "mold") still get a non-PIE executable, which defeats the new feature outside the self-linker path. The issue is triggered whenever pie: true is combined with a non-self linker.
Useful? React with 👍 / 👎.
| body: [ | ||
| Caotral::Binary::ELF::Section::Dynamic.new.set!(tag: tag_types[:HASH], un: 0), | ||
| Caotral::Binary::ELF::Section::Dynamic.new.set!(tag: tag_types[:RELA], un: 0), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid emitting DT_HASH without a .hash section
The dynamic section now unconditionally adds a DT_HASH entry, but .hash is only emitted for PIE (sections << build_hash_section if @pie). For shared objects (shared: true, pie: false), DT_HASH remains zero because the writer only fills it when hash_section exists. A DT_HASH tag with a null pointer is invalid and can cause the dynamic loader to reject or mis-handle the shared object. Either add .hash for shared builds as well, or only emit DT_HASH when the section exists.
Useful? React with 👍 / 👎.
Summary
Testing
Notes