From b117088a91a51b8cbd2a1bc6cb147927e994be1c Mon Sep 17 00:00:00 2001 From: Michael Matz Date: Thu, 31 Dec 2020 00:46:23 +0100 Subject: [PATCH] Explain some reloc hackery just changes a comment; it's not specific to __dso_handle, but general to all hidden defined symbols for shared libraries. --- tccelf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tccelf.c b/tccelf.c index 698a333d..2b929886 100644 --- a/tccelf.c +++ b/tccelf.c @@ -1048,7 +1048,9 @@ static int prepare_dynamic_rel(TCCState *s1, Section *sr) { ElfW(Sym) *sym = &((ElfW(Sym) *)symtab_section->data)[sym_index]; - /* support __dso_handle in atexit() */ + /* Hidden defined symbols can and must be resolved locally. + We're misusing a PLT32 reloc for this, as that's always + resolved to its address even in shared libs. */ if (sym->st_shndx != SHN_UNDEF && ELFW(ST_VISIBILITY)(sym->st_other) == STV_HIDDEN) { rel->r_info = ELFW(R_INFO)(sym_index, R_X86_64_PLT32);