[PATCH] D65459: [AARCH64] Renumber relocation codes R_AARCH64_TLS_TPREL64 and DTPMOD64
Peter Smith via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 30 09:48:58 PDT 2019
peter.smith created this revision.
peter.smith added reviewers: rprichard, LukeCheeseman, ostannard, grimar, t.p.northover.
Herald added subscribers: rupprecht, kristof.beyls, javed.absar, dschuff.
The ELF for the Arm 64-bit Architecture document originally specified
R_AARCH64_TLS_DTPREL64 = 0x404 // 1028
R_AARCH64_TLS_DTPMOD64 = 0x405 // 1029
LLVM correctly followed the document. Unfortunately in binutils(1) these two
codes were reversed:
R_AARCH64_TLS_DTPMOD64 = 0x404 // 1028
R_AARCH64_TLS_DTPREL64 = 0x405 // 1029
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 (2) 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 ELF TLS model for AArch64, we have no binary legacy. Therefore 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 so this change will mean that llvm-readobj decodes the same way as GNU readelf.
(1) https://chromium.googlesource.com/native_client/nacl-binutils/+/binutils-2_25_1/elfcpp/aarch64.h#174
(2) https://developer.arm.com/docs/ihi0056/latest/elf-for-the-arm-64-bit-architecture-aarch64-abi-2019q2-documentation
fixes https://bugs.llvm.org/show_bug.cgi?id=40507
https://reviews.llvm.org/D65459
Files:
include/llvm/BinaryFormat/ELFRelocs/AArch64.def
test/tools/llvm-readobj/Inputs/relocs.py
test/tools/llvm-readobj/reloc-types-elf-aarch64.test
Index: test/tools/llvm-readobj/reloc-types-elf-aarch64.test
===================================================================
--- test/tools/llvm-readobj/reloc-types-elf-aarch64.test
+++ test/tools/llvm-readobj/reloc-types-elf-aarch64.test
@@ -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 @@
- 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
Index: test/tools/llvm-readobj/Inputs/relocs.py
===================================================================
--- test/tools/llvm-readobj/Inputs/relocs.py
+++ test/tools/llvm-readobj/Inputs/relocs.py
@@ -710,8 +710,8 @@
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
Index: include/llvm/BinaryFormat/ELFRelocs/AArch64.def
===================================================================
--- include/llvm/BinaryFormat/ELFRelocs/AArch64.def
+++ include/llvm/BinaryFormat/ELFRelocs/AArch64.def
@@ -124,8 +124,11 @@
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)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65459.212367.patch
Type: text/x-patch
Size: 2876 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190730/a47c2965/attachment.bin>
More information about the llvm-commits
mailing list