[PATCH] D46319: [MC][ARM] Emit R_ARM_BASE_PREL for _GLOBAL_OFFSET_TABLE_ expressions
Peter Smith via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 14 03:09:39 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG31c8e1189619: [MC][ARM] Emit R_ARM_BASE_PREL for _GLOBAL_OFFSET_TABLE_ expressions (authored by psmith).
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.
Changed prior to commit:
https://reviews.llvm.org/D46319?vs=144732&id=257257#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D46319/new/
https://reviews.llvm.org/D46319
Files:
llvm/lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp
llvm/test/MC/ARM/symbol-variants.s
Index: llvm/test/MC/ARM/symbol-variants.s
===================================================================
--- llvm/test/MC/ARM/symbol-variants.s
+++ llvm/test/MC/ARM/symbol-variants.s
@@ -96,8 +96,16 @@
@CHECK: 70 R_ARM_TLS_LDM32 f28
@CHECK: 74 R_ARM_TLS_LDM32 f29
+@ relative
+.word f30 - (.Lsym+8)
+ at CHECK: 78 R_ARM_REL32 f30
+
+@ _GLOBAL_OFFSET_TABLE_ relative
+.word _GLOBAL_OFFSET_TABLE_ - (.Lsym+8)
+ at CHECK: 7c R_ARM_BASE_PREL _GLOBAL_OFFSET_TABLE_
+
@ got_prel
-.word f30(GOT_PREL) + (. - .Lsym)
- ldr r3, =f31(GOT_PREL)
-@ CHECK: 78 R_ARM_GOT_PREL f30
-@ CHECK: 80 R_ARM_GOT_PREL f31
+.word f31(GOT_PREL) + (. - .Lsym)
+ ldr r3, =f32(GOT_PREL)
+ at CHECK: 80 R_ARM_GOT_PREL f31
+ at CHECK: 88 R_ARM_GOT_PREL f32
Index: llvm/lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp
===================================================================
--- llvm/lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp
+++ llvm/lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp
@@ -93,8 +93,15 @@
switch (Modifier) {
default:
llvm_unreachable("Unsupported Modifier");
- case MCSymbolRefExpr::VK_None:
+ case MCSymbolRefExpr::VK_None: {
+ if (const MCSymbolRefExpr *SymRef = Target.getSymA()) {
+ // For GNU AS compatibility expressions such as
+ // _GLOBAL_OFFSET_TABLE_ - label emit a R_ARM_BASE_PREL relocation.
+ if (SymRef->getSymbol().getName() == "_GLOBAL_OFFSET_TABLE_")
+ return ELF::R_ARM_BASE_PREL;
+ }
return ELF::R_ARM_REL32;
+ }
case MCSymbolRefExpr::VK_GOTTPOFF:
return ELF::R_ARM_TLS_IE32;
case MCSymbolRefExpr::VK_ARM_GOT_PREL:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46319.257257.patch
Type: text/x-patch
Size: 1671 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200414/ac7909fb/attachment.bin>
More information about the llvm-commits
mailing list