]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
Add new relocations to linker (excluding relaxations)
authorMatthew Malcomson <matthew.malcomson@arm.com>
Fri, 5 Aug 2022 16:19:33 +0000 (17:19 +0100)
committerJohn Baldwin <jhb@FreeBSD.org>
Thu, 1 Sep 2022 23:31:36 +0000 (16:31 -0700)
commit28e8998a01b421ba04759719ec71f04ef538a55d
treed4ce9f86278982ae2a450803e822b661072edd48
parent319d73f26a062c5032a888ce6ab1f75af46307e6
Add new relocations to linker (excluding relaxations)

Some notes on the implementation decisions:

Use _bfd_aarch64_elf_resolve_relocation on :size: relocations
  This is unnecessary, since all that function does in the case of
  :size: relocations is to return the value it was given as an argument.
  For the analogous MOVW_G0 relocations this function adds the addend
  and emits a warning in the case of a weak undefined TLS symbol.

TPREL128/TLSDESC relocs now add size of symbol in fragment to satisfy
the ABI requirement.
  This only happens when we know the size of the relevant symbol, we
  also emit the location of the symbol in a TPREL128 fragment when that
  is known too.

See PR for documentation https://github.com/ARM-software/abi-aa/pull/80

Implementation note:
Handling the size of a symbol according to whether the static linker
knows what it is was very slightly tricky.  Using the macro
`SYMBOL_REFERENCES_LOCAL` to check whether we knew the size of a symbol
is a problem.  That macro treats PROTECTED visibility symbols as *not*
local.  This is in order to handle the case where a reference to a
protected function symbol could end up having the value of an
executable's PLT (in order to handle function equality and hard-coded
addresses in an executable).

Since TLS symbols can not be function symbols (n.b. this refers to the
TLS object and not the resolver), this requirement does not apply.  That
means we should check this property with something like
`SYMBOL_CALLS_LOCAL` (which is the existing macro to treat protected
symbols differently).

Given the confusing nomenclature here, we add a new AArch64 backend
macro called `TLS_SYMBOL_REFERENCES_LOCAL` so that we have a nice name
for it.

N.b. in this patch we adjust all uses of `SYMBOL_REFERENCES_LOCAL` which
are known to be acting on TLS symbols.  This includes some places where
it does not matter whether a symbol is protected or not because the
condition also requires that we're in an executable (like in deciding
whether a relocation can be relaxed).  This was done simply for
conformity and neatness.
bfd/elfnn-aarch64.c
bfd/elfxx-aarch64.c