[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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@367437 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Peter Smith 2019-07-31 14:42:57 +00:00
parent e649ed6fe9
commit ae598863db
3 changed files with 11 additions and 8 deletions

View File

@ -124,8 +124,11 @@ ELF_RELOC(R_AARCH64_COPY, 0x400)
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)

View File

@ -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

View File

@ -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