From 69634db9348550f573141f478cb78eaa8363f16a Mon Sep 17 00:00:00 2001 From: Christophe Lyon Date: Wed, 4 Jul 2018 17:55:29 +0200 Subject: rtld: Use ELF_RTYPE_CLASS_DLSYM MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit rtld must call _dl_find_hash() with ELF_RTYPE_CLASS_DLSYM since we want a function descriptor. * ldso/ldso/ldso.c (_dl_get_ready_to_run): Support __FDPIC__. Signed-off-by: Mickaël Guêné Signed-off-by: Christophe Lyon --- ldso/ldso/ldso.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/ldso/ldso/ldso.c b/ldso/ldso/ldso.c index 06b0ac874..b33547670 100644 --- a/ldso/ldso/ldso.c +++ b/ldso/ldso/ldso.c @@ -444,6 +444,11 @@ void *_dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr, size_t relro_size = 0; struct r_scope_elem *global_scope; struct elf_resolve **local_scope; +#if defined(__FDPIC__) + int rtype_class = ELF_RTYPE_CLASS_DLSYM; +#else + int rtype_class = ELF_RTYPE_CLASS_PLT; +#endif #if defined(USE_TLS) && USE_TLS void *tcbp = NULL; @@ -1422,21 +1427,21 @@ of this helper program; chances are you did not intend to run this program.\n\ /* Find the real malloc function and make ldso functions use that from now on */ _dl_malloc_function = (void* (*)(size_t)) (intptr_t) _dl_find_hash(__C_SYMBOL_PREFIX__ "malloc", - global_scope, NULL, ELF_RTYPE_CLASS_PLT, NULL); + global_scope, NULL, rtype_class, NULL); #if defined(USE_TLS) && USE_TLS /* Find the real functions and make ldso functions use them from now on */ _dl_calloc_function = (void* (*)(size_t, size_t)) (intptr_t) - _dl_find_hash(__C_SYMBOL_PREFIX__ "calloc", global_scope, NULL, ELF_RTYPE_CLASS_PLT, NULL); + _dl_find_hash(__C_SYMBOL_PREFIX__ "calloc", global_scope, NULL, rtype_class, NULL); _dl_realloc_function = (void* (*)(void *, size_t)) (intptr_t) - _dl_find_hash(__C_SYMBOL_PREFIX__ "realloc", global_scope, NULL, ELF_RTYPE_CLASS_PLT, NULL); + _dl_find_hash(__C_SYMBOL_PREFIX__ "realloc", global_scope, NULL, rtype_class, NULL); _dl_free_function = (void (*)(void *)) (intptr_t) - _dl_find_hash(__C_SYMBOL_PREFIX__ "free", global_scope, NULL, ELF_RTYPE_CLASS_PLT, NULL); + _dl_find_hash(__C_SYMBOL_PREFIX__ "free", global_scope, NULL, rtype_class, NULL); _dl_memalign_function = (void* (*)(size_t, size_t)) (intptr_t) - _dl_find_hash(__C_SYMBOL_PREFIX__ "memalign", global_scope, NULL, ELF_RTYPE_CLASS_PLT, NULL); + _dl_find_hash(__C_SYMBOL_PREFIX__ "memalign", global_scope, NULL, rtype_class, NULL); #endif -- cgit v1.2.3