Page MenuHomeFreeBSD

llvm: Backport upstream r229195 to fix arm64 TLS relocations
ClosedPublic

Authored by emaste on Mar 30 2015, 3:22 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Apr 20, 4:05 PM
Unknown Object (File)
Feb 24 2024, 7:06 AM
Unknown Object (File)
Nov 13 2023, 10:44 AM
Unknown Object (File)
Oct 24 2023, 9:00 PM
Unknown Object (File)
Sep 5 2023, 3:50 AM
Unknown Object (File)
Aug 10 2023, 7:27 AM
Unknown Object (File)
Jul 25 2023, 12:02 AM
Unknown Object (File)
Jul 24 2023, 9:58 PM
Subscribers
None

Details

Summary

As is described at http://llvm.org/bugs/show_bug.cgi?id=22408, the GNU linkers ld.bfd and ld.gold currently only support a subset of the whole range of AArch64 ELF TLS relocations. Furthermore, they assume that some of the code sequences to access thread-local variables are produced in a very specific sequence. When the sequence is not as the linker expects, it can silently mis-relaxe/mis-optimize the instructions.
Even if that wouldn't be the case, it's good to produce the exact sequence, as that ensures that linkers can perform optimizing relaxations.

This patch:

  • implements support for 16MiB TLS area size instead of 4GiB TLS area size. Ideally clang would grow an -mtls-size option to allow support for both, but that's not part of this patch.
  • by default doesn't produce local dynamic access patterns, as even modern ld.bfd and ld.gold linkers do not support the associated relocations. An option (-aarch64-elf-ldtls-generation) is added to enable generation of local dynamic code sequence, but is off by default.
  • makes sure that the exact expected code sequence for local dynamic and general dynamic accesses is produced, by making use of a new pseudo instruction. The patch also removes two (AArch64ISD::TLSDESC_BLR, AArch64ISD::TLSDESC_CALL) pre-existing AArch64-specific pseudo SDNode instructions that are superseded by the new one (TLSDESC_CALLSEQ).

Submitted by: Kristof Beyls

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

emaste retitled this revision from to llvm: Backport upstream r229195 to fix arm64 TLS relocations.
emaste updated this object.
emaste edited the test plan for this revision. (Show Details)
emaste added reviewers: dim, andrew.

Note that this is necessary but not sufficient for us to enable TLS. Enabling TLS in cdefs.h and gnu/lib/libgomp/config.h shows missing rtld support for R_AARCH64_TLS_TPREL64.

# /bin/sh
/bin/sh: Unhandled relocation 1030

https://github.com/FreeBSDFoundation/freebsd/issues/22

dim edited edge metadata.

Tested on my patched 3.6.0 tree, check-all found no problems. So it's good to go. :)

This revision is now accepted and ready to land.Mar 30 2015, 7:17 PM
emaste updated this revision to Diff 4521.

Closed by commit rS280865 (authored by @emaste).