[X86] Support i386 absolute relocations - #2027
Open
Bhoumik Patidar (BhoumikPatidar) wants to merge 1 commit into
Open
Bhoumik Patidar (BhoumikPatidar) wants to merge 1 commit into
Bhoumik Patidar (BhoumikPatidar) wants to merge 1 commit into
Conversation
Bhoumik Patidar (BhoumikPatidar)
requested a review
from Parth (parth-07)
as a code owner
October 1, 2026 13:53
Shankar Easwaran (quic-seaswara)
approved these changes
Oct 1, 2026
Steven Ramirez Rosa (Steven6798)
requested changes
Oct 1, 2026
Steven Ramirez Rosa (Steven6798)
left a comment
Contributor
There was a problem hiding this comment.
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.
Contributor
Great comment. Thanks for bringing this up! |
Shankar Easwaran (quic-seaswara)
approved these changes
Oct 1, 2026
Bhoumik Patidar (BhoumikPatidar)
force-pushed
the
x86_32_absolute_relocations
branch
from
October 5, 2026 10:19
84bedc6 to
37c8ad5
Compare
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>
Bhoumik Patidar (BhoumikPatidar)
force-pushed
the
x86_32_absolute_relocations
branch
from
October 5, 2026 10:21
37c8ad5 to
8a7dae9
Compare
Contributor
Author
Thanks for highlighting this. I have updated the code to use i386.def to populate the reloc names and IDs. |
Steven Ramirez Rosa (Steven6798)
approved these changes
Oct 5, 2026
This branch has not been deployed
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add the relocation layer for
i386links:R_386_NONE,R_386_8,R_386_16, andR_386_32.Unlike
x86-64,i386usesElf32_Relrather thanElf64_Rela. The addend is stored in the field being relocated, so it must be read and sign-extended from that field width before evaluatingS + 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