Skip to content

[X86] Add support for R_X86_64_GOTPC32 relocation#1344

Draft
Saharsh Burra (bsaharsh) wants to merge 1 commit into
qualcomm:mainfrom
bsaharsh:support/x86_64-GOTPC32
Draft

[X86] Add support for R_X86_64_GOTPC32 relocation#1344
Saharsh Burra (bsaharsh) wants to merge 1 commit into
qualcomm:mainfrom
bsaharsh:support/x86_64-GOTPC32

Conversation

@bsaharsh

Copy link
Copy Markdown
Contributor

Add handling for R_X86_64_GOTPC32 (type 26) in the ELD x86-64 backend. This relocation is emitted for leaq _GLOBAL_OFFSET_TABLE_(%rip), %rbx to compute the GOT base address, which is then used by PIC/PIE code for GOT-relative accesses.

Changes:

  • x86_64RelocationInfo.h: add GOTPC32 entry at index 26 with Size=32
  • x86_64RelocationFunctions.h: declare relocGOTPC32, wire dispatch table
  • x86_64Relocator.cpp: add isRelocSupported case, bare return scan cases, and relocGOTPC32 apply function implementing GOT_base + A - P

Note: This patch depends on PR #1123 which adds GLOBAL_OFFSET_TABLE symbol support for x86-64. Without that patch, GOTPC32 relocations will fail with an undefined reference to GLOBAL_OFFSET_TABLE.

Resolves #1304

Add handling for R_X86_64_GOTPC32 (type 26) in the ELD x86-64 backend.
This relocation is emitted for `leaq _GLOBAL_OFFSET_TABLE_(%rip), %rbx`
to compute the GOT base address, which is then used by PIC/PIE code for
GOT-relative accesses.

Changes:
- x86_64RelocationInfo.h: add GOTPC32 entry at index 26 with Size=32
- x86_64RelocationFunctions.h: declare relocGOTPC32, wire dispatch table
- x86_64Relocator.cpp: add isRelocSupported case, bare return scan cases,
  and relocGOTPC32 apply function implementing GOT_base + A - P

Note: This patch depends on PR qualcomm#1123 which adds _GLOBAL_OFFSET_TABLE_
symbol support for x86-64. Without that patch, GOTPC32 relocations will
fail with an undefined reference to _GLOBAL_OFFSET_TABLE_.

Resolves qualcomm#1304

Signed-off-by: bsaharsh <bsaharsh@qti.qualcomm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

eld does not support R_X86_64_GOTPC32 relocation

1 participant