summaryrefslogtreecommitdiff
path: root/sysdeps/riscv/dl-machine.h
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/riscv/dl-machine.h')
-rw-r--r--sysdeps/riscv/dl-machine.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/sysdeps/riscv/dl-machine.h b/sysdeps/riscv/dl-machine.h
index c0c9bd93ad..0e6c0bb155 100644
--- a/sysdeps/riscv/dl-machine.h
+++ b/sysdeps/riscv/dl-machine.h
@@ -53,6 +53,9 @@
|| (__WORDSIZE == 64 && (type) == R_RISCV_TLS_TPREL64))) \
| (ELF_RTYPE_CLASS_COPY * ((type) == R_RISCV_COPY)))
+//* Translate a processor specific dynamic tag to the index in l_info array. */
+#define DT_RISCV(x) (DT_RISCV_##x - DT_LOPROC + DT_NUM)
+
/* Return nonzero iff ELF header is compatible with the running host. */
static inline int __attribute_used__
elf_machine_matches_host (const ElfW(Ehdr) *ehdr)
@@ -281,6 +284,29 @@ elf_machine_lazy_rel (struct link_map *map, struct r_scope_elem *scope[],
/* Check for unexpected PLT reloc type. */
if (__glibc_likely (r_type == R_RISCV_JUMP_SLOT))
{
+ if (__glibc_unlikely (map->l_info[DT_RISCV (VARIANT_CC)] != NULL))
+ {
+ /* Check the symbol table for variant CC 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_RISCV_VARIANT_CC))
+ {
+ /* Avoid lazy resolution of variant CC 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, scope, reloc, sym, version, reloc_addr,
+ skip_ifunc);
+ return;
+ }
+ }
+
if (__glibc_unlikely (map->l_mach.plt == 0))
{
if (l_addr)