This is an archive of the discontinued LLVM Phabricator instance.

[AARCH64] Renumber relocation codes R_AARCH64_TLS_TPREL64 and DTPMOD64
ClosedPublic

Authored by peter.smith on Jul 30 2019, 9:47 AM.

Details

Summary

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

Diff Detail

Event Timeline

peter.smith created this revision.Jul 30 2019, 9:47 AM
rprichard accepted this revision.Jul 30 2019, 4:19 PM

Looks good to me.

This revision is now accepted and ready to land.Jul 30 2019, 4:19 PM
MaskRay accepted this revision.Jul 31 2019, 3:06 AM

Renumber relocation codes R_AARCH64_TLS_TPREL64 and DTPMOD64

A small typo: s/R_AARCH64_TLS_TPREL64/R_AARCH64_TLS_DTPREL64/

peter.smith closed this revision.Jul 31 2019, 7:44 AM

Thanks for the review, committed r367437. Forgot to put differential revision so it won't automatically get closed, apologies.