FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[X86] Support i386 absolute relocations by BhoumikPatidar · Pull Request #2027 · qualcomm/eld · GitHub

/ eld Public

[X86] Support i386 absolute relocations - #2027

Open
Bhoumik Patidar (BhoumikPatidar) wants to merge 1 commit into
qualcomm:mainfrom
BhoumikPatidar:x86_32_absolute_relocations
Open

Bhoumik Patidar (BhoumikPatidar) wants to merge 1 commit into
qualcomm:mainfrom
BhoumikPatidar:x86_32_absolute_relocations

Conversation

Bhoumik Patidar (BhoumikPatidar) commented Oct 1, 2026 •
edited
Loading

Copy link
Copy Markdown
Contributor

Add the relocation layer for i386 links: R_386_NONE, R_386_8, R_386_16, and R_386_32.

Unlike x86-64, i386 uses Elf32_Rel rather than Elf64_Rela. The addend is stored in the field being relocated, so it must be read and sign-extended from that field width before evaluating S + A. Normalize the result to the 32-bit ELF address space before checking narrow fields and writing the result back. This preserves valid full-width 32-bit bit patterns, including addresses with bit 31 set, while rejecting values that cannot be encoded in 8- or 16-bit fields.

Resolves #2028
Progress on #1961

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Can look into how ARM parses "llvm/BinaryFormat/ELFRelocs/ARM.def" to create the list of relocations? This helps our relocation list to never get stale.

Copy link
Copy Markdown
Contributor

Can look into how ARM parses "llvm/BinaryFormat/ELFRelocs/ARM.def" to create the list of relocations? This helps our relocation list to never get stale.

Great comment. Thanks for bringing this up!

Add the relocation layer for i386 links: R_386_NONE, R_386_8, R_386_16, and R_386_32.

Unlike x86-64, i386 uses Elf32_Rel rather than Elf64_Rela. The addend is stored in the field
being relocated, so it must be read and sign-extended from that field width before evaluating S + A.
Normalize the result to the 32-bit ELF address space before checking narrow fields and writing the result
back. This preserves valid full-width 32-bit bit patterns, including addresses with bit 31 set,
while rejecting values that cannot be encoded in 8- or 16-bit fields.

Signed-off-by: Bhoumik Patidar <bpatidar@qti.qualcomm.com>

Copy link
Copy Markdown
Contributor Author

Can look into how ARM parses "llvm/BinaryFormat/ELFRelocs/ARM.def" to create the list of relocations? This helps our relocation list to never get stale.

Thanks for highlighting this. I have updated the code to use i386.def to populate the reloc names and IDs.

This branch has not been deployed

No deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support i386 absolute relocations

3 participants


Back | FazBrowse Home | New Git URL