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

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 1 11:23:45 PDT 2018


MaskRay 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);
+  }
----------------
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.


Repository:
  rL LLVM

https://reviews.llvm.org/D47507





More information about the llvm-commits mailing list