Page MenuHomeFreeBSD

Improve R_AARCH64_TLSDESC relocation.

Authored by mmel on Dec 3 2018, 10:24 AM.
Referenced Files
Unknown Object (File)
Wed, May 22, 8:40 AM
Unknown Object (File)
Tue, May 14, 8:35 PM
Unknown Object (File)
Tue, May 14, 9:22 AM
Unknown Object (File)
Wed, May 1, 12:45 AM
Unknown Object (File)
Mon, Apr 29, 10:53 AM
Unknown Object (File)
Sun, Apr 28, 11:55 AM
Unknown Object (File)
Fri, Apr 26, 1:56 AM
Unknown Object (File)
Apr 18 2024, 4:46 AM



The original code did not support dynamically loaded libraries and use
suboptimal access to TLS variables.
New implementation removes lazy resolving of TLS relocation - due to flaw
in TLSDESC design is impossible to switch resolver function at runtime
without expensive locking.

Due to this, 3 specialized resolvers are used.

  • load time resolver, for TLS relocation from libraries loaded with main binary (thus with known TLS offset).
  • undefined thread weak symbol resolved for initial exec symbols.
  • slower lazy resolving for dynamically loaded libraries with fast path for already resolved symbols. It correctly handles undefined thread weak symbols (it should be resolved to NULL).

Unfortunately, here are still some issues which I unable to solve:

  • TLSDESC ABI for resolver function requires preserving all (but X0) registers, including all floating point and optional SVE registers. This is not possible (in universal way) so current code expects that nobody in rtld-elf code uses it, including compiler instrict and/or used libraries. I'm not sure if there is any compiler switch that ensure this.
  • memory allocated by reloc_tlsdesc_alloc() is not freed
  • for TLS_TPREL64 relocation, we don't handle undefined thread weak symbols, but this problem exist in all other architectures.
  • TLSDESC case in reloc_plt() is nonsense, this kind of relocation relocates data, not code. But (GNU compiled) /usr/local/lib/ have TLSDESC relocation in .rela.plt section. I have no idea why.

Diff Detail

rS FreeBSD src repository - subversion
Lint Not Applicable
Tests Not Applicable

Event Timeline

113 ↗(On Diff #51524)

Commit this now ?

231 ↗(On Diff #51524)

Commit this fix now as well (+ line 256) ?

mmel retitled this revision from Improve relocations handling for ARM64. to Improve R_AARCH64_TLSDESC relocation..
mmel edited the summary of this revision. (Show Details)
mmel marked 2 inline comments as done.Dec 8 2018, 3:23 PM
This revision was not accepted when it landed; it landed in state Needs Review.Dec 15 2018, 10:39 AM
This revision was automatically updated to reflect the committed changes.