mirror of
git://sourceware.org/git/glibc.git
synced 2025-02-11 12:50:58 +08:00
aarch64: handle STO_AARCH64_VARIANT_PCS
Backport of commit82bc69c012
and commit30ba037546
without using DT_AARCH64_VARIANT_PCS for optimizing the symbol table check. This is needed so the internal abi between ld.so and libc.so is unchanged. Avoid lazy binding of symbols that may follow a variant PCS with different register usage convention from the base PCS. Currently the lazy binding entry code does not preserve all the registers required for AdvSIMD and SVE vector calls. Saving and restoring all registers unconditionally may break existing binaries, even if they never use vector calls, because of the larger stack requirement for lazy resolution, which can be significant on an SVE system. The solution is to mark all symbols in the symbol table that may follow a variant PCS so the dynamic linker can handle them specially. In this patch such symbols are always resolved at load time, not lazily. So currently LD_AUDIT for variant PCS symbols are not supported, for that the _dl_runtime_profile entry needs to be changed e.g. to unconditionally save/restore all registers (but pass down arg and retval registers to pltentry/exit callbacks according to the base PCS). This patch also removes a __builtin_expect from the modified code because the branch prediction hint did not seem useful. * sysdeps/aarch64/dl-machine.h (elf_machine_lazy_rel): Check STO_AARCH64_VARIANT_PCS and bind such symbols at load time.
This commit is contained in:
parent
b95c8a3150
commit
298e659172
@ -1,3 +1,8 @@
|
||||
2019-07-12 Szabolcs Nagy <szabolcs.nagy@arm.com>
|
||||
|
||||
* sysdeps/aarch64/dl-machine.h (elf_machine_lazy_rel): Check
|
||||
STO_AARCH64_VARIANT_PCS and bind such symbols at load time.
|
||||
|
||||
2019-06-13 Szabolcs Nagy <szabolcs.nagy@arm.com>
|
||||
|
||||
* elf/elf.h (STO_AARCH64_VARIANT_PCS): Define.
|
||||
|
@ -388,10 +388,37 @@ elf_machine_lazy_rel (struct link_map *map,
|
||||
/* Check for unexpected PLT reloc type. */
|
||||
if (__builtin_expect (r_type == AARCH64_R(JUMP_SLOT), 1))
|
||||
{
|
||||
if (__builtin_expect (map->l_mach.plt, 0) == 0)
|
||||
*reloc_addr += l_addr;
|
||||
else
|
||||
*reloc_addr = map->l_mach.plt;
|
||||
if (map->l_mach.plt == 0)
|
||||
{
|
||||
/* Prelinking. */
|
||||
*reloc_addr += l_addr;
|
||||
return;
|
||||
}
|
||||
|
||||
if (1) /* DT_AARCH64_VARIANT_PCS is not available, so always check. */
|
||||
{
|
||||
/* Check the symbol table for variant PCS symbols. */
|
||||
const Elf_Symndx symndx = ELFW (R_SYM) (reloc->r_info);
|
||||
const ElfW (Sym) *symtab =
|
||||
(const void *)D_PTR (map, l_info[DT_SYMTAB]);
|
||||
const ElfW (Sym) *sym = &symtab[symndx];
|
||||
if (__glibc_unlikely (sym->st_other & STO_AARCH64_VARIANT_PCS))
|
||||
{
|
||||
/* Avoid lazy resolution of variant PCS symbols. */
|
||||
const struct r_found_version *version = NULL;
|
||||
if (map->l_info[VERSYMIDX (DT_VERSYM)] != NULL)
|
||||
{
|
||||
const ElfW (Half) *vernum =
|
||||
(const void *)D_PTR (map, l_info[VERSYMIDX (DT_VERSYM)]);
|
||||
version = &map->l_versions[vernum[symndx] & 0x7fff];
|
||||
}
|
||||
elf_machine_rela (map, reloc, sym, version, reloc_addr,
|
||||
skip_ifunc);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
*reloc_addr = map->l_mach.plt;
|
||||
}
|
||||
else if (__builtin_expect (r_type == AARCH64_R(TLSDESC), 1))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user