[PATCH] D47507: [MC] [X86] Teach leaq _GLOBAL_OFFSET_TABLE(%rip), %r15 to use R_X86_64_GOTPC32 instead of R_X86_64_PC32

Eric Christopher via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 7 17:45:16 PDT 2018


echristo added inline comments.


================
Comment at: lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp:355-356
     ImmOffset -= 4;
+    if (StartsWithGlobalOffsetTable(Expr) != GOT_None)
+      FixupKind = MCFixupKind(X86::reloc_global_offset_table);
+  }
----------------
MaskRay wrote:
> ruiu wrote:
> > 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?
> When `%rip` is mentioned, r_addend should be relative to the PC of the **next** instruction thus the `ImmOffset -= 4` here (accounting for a 4-byte PC offset). This is different from the cases above (no PC is involved unless the magic _GLOBAL_OFFSET_TABLE_ appears, where r_addend should be relative to the PC of the **currenct** instruction ).
> 
> I think keeping them separate as is is not bad.
Perhaps not right above, but I think the code might be clearer if we just add the change in Fixup right before this block and add the condition to this block.

Thoughts?


Repository:
  rL LLVM

https://reviews.llvm.org/D47507





More information about the llvm-commits mailing list