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

[X86] Support i386 GOT-base relocations by BhoumikPatidar · Pull Request #2032 · qualcomm/eld · GitHub

/ eld Public

[X86] Support i386 GOT-base relocations - #2032

Open
Bhoumik Patidar (BhoumikPatidar) wants to merge 3 commits into
qualcomm:mainfrom
BhoumikPatidar:x86_32_got_base_relocations
Open

Bhoumik Patidar (BhoumikPatidar) wants to merge 3 commits into
qualcomm:mainfrom
BhoumikPatidar:x86_32_got_base_relocations

Conversation

Copy link
Copy Markdown
Contributor

Add the ELF32 dynamic-section and GOT-base support required by i386 links.

i386 dynamic relocation sections use Elf32_Rel records and 4-byte alignment. Configure the generic dynamic-section builder accordingly, then implement R_386_GOTOFF as S + A - GOT and R_386_GOTPC as GOT + A - P.

Create _GLOBAL_OFFSET_TABLE_ only when a supported GOT-base relocation needs it. The symbol points to the generated GOTPLT0 fragment, which is the GOT base used by these relocations.

This patch provides only the GOT base and its linker-defined symbol. It does not provide individual symbol GOT entries or PLT support.

Resolves #2031
Progress On #1961

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>
Implement R_386_PC8, R_386_PC16, and R_386_PC32 for i386 ELF32 links.
Use signed range checks for narrow PC-relative relocations. PC8 must fit in a signed 8-bit field, while
PC16 accepts a signed 17-bit result before truncating it to 16 bits, as required by 16-bit real-mode code.
PC32 uses the full 32-bit field.

Signed-off-by: Bhoumik Patidar <bpatidar@qti.qualcomm.com>
Add the ELF32 dynamic-section and GOT-base support required by i386 links.

i386 dynamic relocation sections use Elf32_Rel records and 4-byte alignment. Configure the generic dynamic-section builder accordingly, then implement R_386_GOTOFF as S + A - GOT and R_386_GOTPC as GOT + A - P.

Create _GLOBAL_OFFSET_TABLE_ only when a supported GOT-base relocation needs it. The symbol points to the generated GOTPLT0 fragment, which is the GOT base used by these relocations.

This patch provides only the GOT base and its linker-defined symbol. It does not provide individual symbol GOT entries or PLT support.

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

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 GOT-base relocations

2 participants


Back | FazBrowse Home | New Git URL