Skip to content

Commit

Permalink
tools/mpy_ld.py: Support R_X86_64_GOTPCREL reloc for x86-64 arch.
Browse files Browse the repository at this point in the history
This can be treated by the linker the same as R_X86_64_REX_GOTPCRELX,
according to https://reviews.llvm.org/D18301.

Signed-off-by: Damien George <damien@micropython.org>
  • Loading branch information
dpgeorge committed May 20, 2021
1 parent 47b7783 commit 04927df
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tools/mpy_ld.py
Expand Up @@ -73,6 +73,7 @@
R_ARM_BASE_PREL = 25 # aka R_ARM_GOTPC
R_ARM_GOT_BREL = 26 # aka R_ARM_GOT32
R_ARM_THM_JUMP24 = 30
R_X86_64_GOTPCREL = 9
R_X86_64_REX_GOTPCRELX = 42
R_386_GOT32X = 43

Expand Down Expand Up @@ -132,7 +133,7 @@ def __init__(self, name, mpy_feature, qstr_entry_size, word_size, arch_got, asm_
| MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE,
2,
8,
(R_X86_64_REX_GOTPCRELX,),
(R_X86_64_GOTPCREL, R_X86_64_REX_GOTPCRELX),
asm_jump_x86,
),
"armv7m": ArchData(
Expand Down Expand Up @@ -536,7 +537,10 @@ def do_relocation_text(env, text_addr, r):
# Relcation pointing to GOT
reloc = addr = env.got_entries[s.name].offset

elif env.arch.name == "EM_X86_64" and r_info_type == R_X86_64_REX_GOTPCRELX:
elif env.arch.name == "EM_X86_64" and r_info_type in (
R_X86_64_GOTPCREL,
R_X86_64_REX_GOTPCRELX,
):
# Relcation pointing to GOT
got_entry = env.got_entries[s.name]
addr = env.got_section.addr + got_entry.offset
Expand Down

0 comments on commit 04927df

Please sign in to comment.