[lld] 0e6536f - [Hexagon] Add R_HEX_GD_PLT_B22/32_PCREL relocations
Sid Manning via llvm-commits
llvm-commits at lists.llvm.org
Tue May 5 09:48:09 PDT 2020
Author: Sid Manning
Date: 2020-05-05T11:47:51-05:00
New Revision: 0e6536fd97f999096ec3cb29aebf89ea56d56193
URL: https://github.com/llvm/llvm-project/commit/0e6536fd97f999096ec3cb29aebf89ea56d56193
DIFF: https://github.com/llvm/llvm-project/commit/0e6536fd97f999096ec3cb29aebf89ea56d56193.diff
LOG: [Hexagon] Add R_HEX_GD_PLT_B22/32_PCREL relocations
Extended versions of GD_PLT_B22_PCREL. These surface when -mlong-calls
is used.
Differential Revision: https://reviews.llvm.org/D79191
Added:
Modified:
lld/ELF/Arch/Hexagon.cpp
lld/ELF/Relocations.cpp
lld/test/ELF/hexagon-tls-gd-nonpreemptible.s
Removed:
################################################################################
diff --git a/lld/ELF/Arch/Hexagon.cpp b/lld/ELF/Arch/Hexagon.cpp
index 27b20baceeed..60cc581f94fe 100644
--- a/lld/ELF/Arch/Hexagon.cpp
+++ b/lld/ELF/Arch/Hexagon.cpp
@@ -120,6 +120,8 @@ RelExpr Hexagon::getRelExpr(RelType type, const Symbol &s,
case R_HEX_B22_PCREL_X:
case R_HEX_B32_PCREL_X:
case R_HEX_GD_PLT_B22_PCREL:
+ case R_HEX_GD_PLT_B22_PCREL_X:
+ case R_HEX_GD_PLT_B32_PCREL_X:
return R_PLT_PC;
case R_HEX_IE_32_6_X:
case R_HEX_IE_16_X:
@@ -311,16 +313,18 @@ void Hexagon::relocate(uint8_t *loc, const Relocation &rel,
case R_HEX_B15_PCREL_X:
or32le(loc, applyMask(0x00df20fe, val & 0x3f));
break;
- case R_HEX_GD_PLT_B22_PCREL:
case R_HEX_B22_PCREL:
+ case R_HEX_GD_PLT_B22_PCREL:
case R_HEX_PLT_B22_PCREL:
checkInt(loc, val, 22, rel);
or32le(loc, applyMask(0x1ff3ffe, val >> 2));
break;
case R_HEX_B22_PCREL_X:
+ case R_HEX_GD_PLT_B22_PCREL_X:
or32le(loc, applyMask(0x1ff3ffe, val & 0x3f));
break;
case R_HEX_B32_PCREL_X:
+ case R_HEX_GD_PLT_B32_PCREL_X:
or32le(loc, applyMask(0x0fff3fff, val >> 6));
break;
case R_HEX_GOTREL_HI16:
diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp
index ff0680191587..eb30166fcc4c 100644
--- a/lld/ELF/Relocations.cpp
+++ b/lld/ELF/Relocations.cpp
@@ -1344,8 +1344,11 @@ static void scanReloc(InputSectionBase &sec, OffsetGetter &getOffset, RelTy *&i,
addend &= ~0x8000;
// R_HEX_GD_PLT_B22_PCREL (call a at GDPLT) is transformed into
// call __tls_get_addr even if the symbol is non-preemptible.
- if (!(config->emachine == EM_HEXAGON && type == R_HEX_GD_PLT_B22_PCREL))
- expr = fromPlt(expr);
+ if (!(config->emachine == EM_HEXAGON &&
+ (type == R_HEX_GD_PLT_B22_PCREL ||
+ type == R_HEX_GD_PLT_B22_PCREL_X ||
+ type == R_HEX_GD_PLT_B32_PCREL_X)))
+ expr = fromPlt(expr);
}
}
diff --git a/lld/test/ELF/hexagon-tls-gd-nonpreemptible.s b/lld/test/ELF/hexagon-tls-gd-nonpreemptible.s
index ba0eee999c80..ff5e6dbaac71 100644
--- a/lld/test/ELF/hexagon-tls-gd-nonpreemptible.s
+++ b/lld/test/ELF/hexagon-tls-gd-nonpreemptible.s
@@ -3,6 +3,7 @@
# RUN: llvm-mc -filetype=obj -triple=hexagon-unknown-elf %s -o %t.o
# RUN: ld.lld -shared %t.o -o %t.so
# RUN: llvm-readobj -r %t.so | FileCheck --check-prefix=RELOC %s
+# RUN: llvm-readobj -r %t.o | FileCheck --check-prefix=REL %s
# RUN: llvm-objdump -d --no-show-raw-insn --print-imm-hex %t.so | FileCheck %s
## Prior to D77021 lld would error "relocation R_HEX_GD_PLT_B22_PCREL cannot refer to absolute symbol".
@@ -17,17 +18,28 @@
# RELOC-NEXT: R_HEX_JMP_SLOT __tls_get_addr 0x0
# RELOC-NEXT: }
+# REL: R_HEX_B32_PCREL_X _GLOBAL_OFFSET_TABLE_ 0x0
+# REL-NEXT: R_HEX_6_PCREL_X _GLOBAL_OFFSET_TABLE_ 0x4
+# REL-NEXT: R_HEX_GD_GOT_32_6_X a 0x0
+# REL-NEXT: R_HEX_GD_GOT_16_X a 0x0
+# REL-NEXT: R_HEX_GD_PLT_B22_PCREL a 0x0
+# REL-NEXT: R_HEX_GD_PLT_B32_PCREL_X a 0x0
+# REL-NEXT: R_HEX_GD_PLT_B22_PCREL_X a 0x4
+
# CHECK: { immext(#{{.*}})
# CHECK-NEXT: r2 = add(pc,##{{.*}}) }
# CHECK-NEXT: { immext(#{{.*}})
# CHECK-NEXT: r0 = add(r2,##-{{.*}}) }
# CHECK-NEXT: { call {{.*}} }
+# CHECK-NEXT: { immext({{.*}})
+# CHECK-NEXT: call {{.*}} }
# CHECK-NEXT: { r0 = memw(r0+#0x0) }
_start:
r2 = add(pc,##_GLOBAL_OFFSET_TABLE_ at PCREL)
r0 = add(r2,##a at GDGOT)
call a at GDPLT
+ call ##a at GDPLT
r0 = memw(r0+#0)
## a is non-preemptible due to STV_HIDDEN visibility.
More information about the llvm-commits
mailing list