[llvm] r367437 - [AARCH64] Switch relocations R_AARCH64_TLS_TPREL64 and R_AARCH64_DTPMOD64
Peter Smith via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 31 07:42:57 PDT 2019
Author: psmith
Date: Wed Jul 31 07:42:57 2019
New Revision: 367437
URL: http://llvm.org/viewvc/llvm-project?rev=367437&view=rev
Log:
[AARCH64] Switch relocations R_AARCH64_TLS_TPREL64 and R_AARCH64_DTPMOD64
The ELF for the Arm 64-bit Architecture document originally specified
R_AARCH64_TLS_DTPREL64 = 0x404
R_AARCH64_TLS_DTPMOD64 = 0x405
LLVM correctly followed the document. Unfortunately in binutils these
two codes were reversed:
R_AARCH64_TLS_DTPMOD64 = 0x404
R_AARCH64_TLS_DTPREL64 = 0x405
Given that binaries had shipped this change has become the defacto standard
interpretation of these relocation codes for any toolchain that wanted to
remain compatible with GNU.
To recognize this the latest version of the ABI document has renamed
the relocations to R_AARCH64_TLS_IMPDEF1 and R_AARCH64_TLS_IMPDEF2
permitting a toolchain to choose between the two relocation types, and
recommending that toolchains follow the GNU interpretation for maximum
compatibility.
Given that upstream llvm has never implemented the standard TLS model for
AArch64 so we have no binary legacy, synchronize with GCC so that we don't
create incompatible objects in the future. So far the only visible change
is in llvm-readobj as it can decode these relocations. Tthis change will
mean that llvm-readobj decodes the same way as GNU readelf.
fixes PR40507
Modified:
llvm/trunk/include/llvm/BinaryFormat/ELFRelocs/AArch64.def
llvm/trunk/test/tools/llvm-readobj/Inputs/relocs.py
llvm/trunk/test/tools/llvm-readobj/reloc-types-elf-aarch64.test
Modified: llvm/trunk/include/llvm/BinaryFormat/ELFRelocs/AArch64.def
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/BinaryFormat/ELFRelocs/AArch64.def?rev=367437&r1=367436&r2=367437&view=diff
==============================================================================
--- llvm/trunk/include/llvm/BinaryFormat/ELFRelocs/AArch64.def (original)
+++ llvm/trunk/include/llvm/BinaryFormat/ELFRelocs/AArch64.def Wed Jul 31 07:42:57 2019
@@ -124,8 +124,11 @@ ELF_RELOC(R_AARCH64_COPY,
ELF_RELOC(R_AARCH64_GLOB_DAT, 0x401)
ELF_RELOC(R_AARCH64_JUMP_SLOT, 0x402)
ELF_RELOC(R_AARCH64_RELATIVE, 0x403)
-ELF_RELOC(R_AARCH64_TLS_DTPREL64, 0x404)
-ELF_RELOC(R_AARCH64_TLS_DTPMOD64, 0x405)
+// 0x404 and 0x405 are now R_AARCH64_TLS_IMPDEF1 and R_AARCH64_TLS_IMPDEF2
+// We follow GNU and define TLS_IMPDEF1 as TLS_DTPMOD64 and TLS_IMPDEF2 as
+// TLS_DTPREL64
+ELF_RELOC(R_AARCH64_TLS_DTPMOD64, 0x404)
+ELF_RELOC(R_AARCH64_TLS_DTPREL64, 0x405)
ELF_RELOC(R_AARCH64_TLS_TPREL64, 0x406)
ELF_RELOC(R_AARCH64_TLSDESC, 0x407)
ELF_RELOC(R_AARCH64_IRELATIVE, 0x408)
Modified: llvm/trunk/test/tools/llvm-readobj/Inputs/relocs.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-readobj/Inputs/relocs.py?rev=367437&r1=367436&r2=367437&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-readobj/Inputs/relocs.py (original)
+++ llvm/trunk/test/tools/llvm-readobj/Inputs/relocs.py Wed Jul 31 07:42:57 2019
@@ -710,8 +710,8 @@ class Relocs_Elf_AArch64(Enum):
R_AARCH64_GLOB_DAT = 0x401
R_AARCH64_JUMP_SLOT = 0x402
R_AARCH64_RELATIVE = 0x403
- R_AARCH64_TLS_DTPREL64 = 0x404
- R_AARCH64_TLS_DTPMOD64 = 0x405
+ R_AARCH64_TLS_DTPMOD64 = 0x404
+ R_AARCH64_TLS_DTPREL64 = 0x405
R_AARCH64_TLS_TPREL64 = 0x406
R_AARCH64_TLSDESC = 0x407
R_AARCH64_IRELATIVE = 0x408
Modified: llvm/trunk/test/tools/llvm-readobj/reloc-types-elf-aarch64.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-readobj/reloc-types-elf-aarch64.test?rev=367437&r1=367436&r2=367437&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-readobj/reloc-types-elf-aarch64.test (original)
+++ llvm/trunk/test/tools/llvm-readobj/reloc-types-elf-aarch64.test Wed Jul 31 07:42:57 2019
@@ -122,8 +122,8 @@
# CHECK: Type: R_AARCH64_GLOB_DAT (1025)
# CHECK: Type: R_AARCH64_JUMP_SLOT (1026)
# CHECK: Type: R_AARCH64_RELATIVE (1027)
-# CHECK: Type: R_AARCH64_TLS_DTPREL64 (1028)
-# CHECK: Type: R_AARCH64_TLS_DTPMOD64 (1029)
+# CHECK: Type: R_AARCH64_TLS_DTPMOD64 (1028)
+# CHECK: Type: R_AARCH64_TLS_DTPREL64 (1029)
# CHECK: Type: R_AARCH64_TLS_TPREL64 (1030)
# CHECK: Type: R_AARCH64_TLSDESC (1031)
# CHECK: Type: R_AARCH64_IRELATIVE (1032)
@@ -382,9 +382,9 @@ Sections:
- Offset: 0x00000000000001D4
Type: R_AARCH64_RELATIVE
- Offset: 0x00000000000001D8
- Type: R_AARCH64_TLS_DTPREL64
- - Offset: 0x00000000000001DC
Type: R_AARCH64_TLS_DTPMOD64
+ - Offset: 0x00000000000001DC
+ Type: R_AARCH64_TLS_DTPREL64
- Offset: 0x00000000000001E0
Type: R_AARCH64_TLS_TPREL64
- Offset: 0x00000000000001E4
More information about the llvm-commits
mailing list