[lld] c1a5f73 - [ELF][ARM] Represent R_ARM_LDO32 as R_DTPREL instead of R_ABS
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 6 09:50:54 PDT 2020
Author: Fangrui Song
Date: 2020-07-06T09:47:53-07:00
New Revision: c1a5f73a4ae70d8f808c1bac091c3f4b683815b4
URL: https://github.com/llvm/llvm-project/commit/c1a5f73a4ae70d8f808c1bac091c3f4b683815b4
DIFF: https://github.com/llvm/llvm-project/commit/c1a5f73a4ae70d8f808c1bac091c3f4b683815b4.diff
LOG: [ELF][ARM] Represent R_ARM_LDO32 as R_DTPREL instead of R_ABS
Follow-up to D82899. Note, we need to disable R_DTPREL relaxation
because ARM psABI does not define TLS relaxation.
Reviewed By: grimar, psmith
Differential Revision: https://reviews.llvm.org/D83138
Added:
Modified:
lld/ELF/Arch/ARM.cpp
lld/ELF/Relocations.cpp
lld/test/ELF/debug-dead-reloc-tls-arm.s
Removed:
################################################################################
diff --git a/lld/ELF/Arch/ARM.cpp b/lld/ELF/Arch/ARM.cpp
index 0dfdbf3d01e2..fd90557cc4f6 100644
--- a/lld/ELF/Arch/ARM.cpp
+++ b/lld/ELF/Arch/ARM.cpp
@@ -121,6 +121,8 @@ RelExpr ARM::getRelExpr(RelType type, const Symbol &s,
return R_TLSGD_PC;
case R_ARM_TLS_LDM32:
return R_TLSLD_PC;
+ case R_ARM_TLS_LDO32:
+ return R_DTPREL;
case R_ARM_BASE_PREL:
// B(S) + A - P
// FIXME: currently B(S) assumed to be .got, this may not hold for all
diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp
index dfae234fd60c..42341f67afee 100644
--- a/lld/ELF/Relocations.cpp
+++ b/lld/ELF/Relocations.cpp
@@ -238,7 +238,7 @@ handleTlsRelocation(RelType type, Symbol &sym, InputSectionBase &c,
}
// Local-Dynamic relocs can be relaxed to Local-Exec.
- if (expr == R_DTPREL && !config->shared) {
+ if (expr == R_DTPREL && canRelax && !config->shared) {
c.relocations.push_back(
{target->adjustRelaxExpr(type, nullptr, R_RELAX_TLS_LD_TO_LE), type,
offset, addend, &sym});
diff --git a/lld/test/ELF/debug-dead-reloc-tls-arm.s b/lld/test/ELF/debug-dead-reloc-tls-arm.s
index 146133a5c8c0..7fa5bcaae19e 100644
--- a/lld/test/ELF/debug-dead-reloc-tls-arm.s
+++ b/lld/test/ELF/debug-dead-reloc-tls-arm.s
@@ -7,8 +7,7 @@
# RUN: llvm-objdump -s %t | FileCheck %s
# CHECK: Contents of section .debug_info:
-## FIXME: Use ffffffff
-# CHECK-NEXT: 0000 00000000
+# CHECK-NEXT: 0000 ffffffff
.globl _start
_start:
More information about the llvm-commits
mailing list