-
Notifications
You must be signed in to change notification settings - Fork 0
Adjust symtab section header #31
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: a145bf1f50
ℹ️ 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".
2cd8a69 to
3a54b40
Compare
|
@codex review |
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: 3a54b40262
ℹ️ 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".
| name, info, link, entsize = (name_offset.nil? ? 0 : name_offset), header.info, header.link, 0 | ||
| if header.type == :symtab | ||
| info = section.body.size | ||
| link = strtabndx |
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.
Set symtab sh_info to local symbol count
In ELF, a symtab section’s sh_info must be the index of the first non-local symbol (i.e., the count of local symbols). Here info = section.body.size sets it to the total symbol count, so any global symbols are effectively marked as local to consumers that rely on sh_info. This shows up whenever the input has globals (e.g., the main symbol from the assembler or GCC-produced objects), and it can cause tools/linkers to misclassify or ignore globals.
Useful? React with 👍 / 👎.
| write_order << @elf_obj.find_by_name(".text") | ||
| write_order << @elf_obj.find_by_name(".symtab") | ||
| write_order << @elf_obj.find_by_name(".strtab") | ||
| write_order.concat(@elf_obj.select_by_names([/\.rel\./, /\.rela\./])) | ||
| write_order << @elf_obj.find_by_name(".shstrtab") |
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 rel sections without target sections
The write order now includes every .rel.*/.rela.* section but only keeps .text, .symtab, .strtab, and .shstrtab. For objects that also have relocations for other sections (e.g., GCC adds .rela.eh_frame alongside .eh_frame), this emits relocation sections whose referenced target section is omitted from the output. That leaves sh_info pointing at a section index that doesn’t exist in the new section table, producing an invalid ELF that can confuse tooling. Either include the referenced sections or drop relocations whose targets aren’t being written.
Useful? React with 👍 / 👎.
Summary
Testing