[AARCH64] Switch relocations R_AARCH64_TLS_TPREL64 and R_AARCH64_DTPMOD64
authorPeter Smith <peter.smith@linaro.org>
Wed, 31 Jul 2019 14:42:57 +0000 (14:42 +0000)
committerPeter Smith <peter.smith@linaro.org>
Wed, 31 Jul 2019 14:42:57 +0000 (14:42 +0000)
commite314a128a9d6dbe5d0f7eb9c5d48b5f6f0b82c11
tree5d2975430e89e641df5d5f392b7f9e3dfe39ca81
parent0707f66ad0afba012cd2e573c924a1712109aa04
[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

llvm-svn: 367437
llvm/include/llvm/BinaryFormat/ELFRelocs/AArch64.def
llvm/test/tools/llvm-readobj/Inputs/relocs.py
llvm/test/tools/llvm-readobj/reloc-types-elf-aarch64.test