This is similar to D46319 (ARM). x86-64 psABI p40 gives an example:
leaq _GLOBAL_OFFSET_TABLE(%rip), %r15 # GOTPC32 reloc
GNU as creates such R_X86_64_GOTPC32. However, MC currently emits R_X86_64_PC32.
Differential D47507
[MC] [X86] Teach leaq _GLOBAL_OFFSET_TABLE(%rip), %r15 to use R_X86_64_GOTPC32 instead of R_X86_64_PC32 MaskRay on May 29 2018, 5:44 PM. Authored by
Details This is similar to D46319 (ARM). x86-64 psABI p40 gives an example: leaq _GLOBAL_OFFSET_TABLE(%rip), %r15 # GOTPC32 reloc GNU as creates such R_X86_64_GOTPC32. However, MC currently emits R_X86_64_PC32.
Diff Detail
Event TimelineComment Actions I'm not very familiar with this code, so please take it with a grain of salt.
Comment Actions Apologies I don't know x86 well enough to be authoritative here. It looks like at least the test case needs to use %rip to see a meaningful difference in the output of mc.
Comment Actions The r_addend offsets do not change before/after the patch. Yes, with _GLOBAL_OFFSET_TABLE_(%rax) (is this a malform?), r_addend is different in GNU as (RIP is relative to the location) and llvm-mc (before or after the patch: relative to the currect instruction): leaq _GLOBAL_OFFSET_TABLE_(%rax), %r15 But for: leaq _GLOBAL_OFFSET_TABLE_(%rip), %r15 Both GNU as and llvm-mc think it should be relative to the RIP of the next instruction. Comment Actions Added the test`leaq _GLOBAL_OFFSET_TABLE_(%rip), %r15` along with leaq _GLOBAL_OFFSET_TABLE_(%rax), %r15 The behavior of GNU as is weird (it is relative neither the current instruction nor the next, but the relocation position). I think the current llvm-mc behavior is fine and it is consistent with another test test/MC/ELF/global-offset.s.
Comment Actions One inline comment then OK.
|
Is this the right place to add this code? There's code in this function that also set the same value to FixupKind. Can't you merge them?