From bd2b38e3cde5aa7d6d54933ee1b82180fd8d7a75 Mon Sep 17 00:00:00 2001 From: Bernd Schmidt Date: Fri, 8 Feb 2008 13:43:39 +0000 Subject: Fix the recent dladdr changes so that they compile on FD-PIC targets. --- ldso/include/dl-hash.h | 2 +- ldso/ldso/bfin/dl-sysdep.h | 4 ++-- ldso/ldso/dl-hash.c | 3 ++- ldso/ldso/ldso.c | 8 ++++---- ldso/libdl/libdl.c | 2 +- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/ldso/include/dl-hash.h b/ldso/include/dl-hash.h index 193ae2d59..2c0f306b6 100644 --- a/ldso/include/dl-hash.h +++ b/ldso/include/dl-hash.h @@ -34,7 +34,7 @@ struct elf_resolve { struct elf_resolve * next; struct elf_resolve * prev; /* Nothing after this address is used by gdb. */ - DL_LOADADDR_TYPE mapaddr; /* Address at which ELF segments (either main app and DSO) are mapped into */ + ElfW(Addr) mapaddr; /* Address at which ELF segments (either main app and DSO) are mapped into */ enum {elf_lib, elf_executable,program_interpreter, loaded_file} libtype; struct dyn_elf * symbol_scope; unsigned short usage_count; diff --git a/ldso/ldso/bfin/dl-sysdep.h b/ldso/ldso/bfin/dl-sysdep.h index 9d89a9e3e..38ed51300 100644 --- a/ldso/ldso/bfin/dl-sysdep.h +++ b/ldso/ldso/bfin/dl-sysdep.h @@ -95,7 +95,7 @@ struct funcdesc_ht; #define DL_LOADADDR_TYPE struct elf32_fdpic_loadaddr #define DL_RELOC_ADDR(LOADADDR, ADDR) \ - (__reloc_pointer ((void*)(ADDR), (LOADADDR).map)) + ((ElfW(Addr))__reloc_pointer ((void*)(ADDR), (LOADADDR).map)) #define DL_ADDR_TO_FUNC_PTR(ADDR, LOADADDR) \ ((void(*)(void)) _dl_funcdesc_for ((void*)(ADDR), (LOADADDR).got_value)) @@ -189,7 +189,7 @@ while (0) #define DL_FIND_HASH_VALUE(TPNT, TYPE_CLASS, SYM) \ (((TYPE_CLASS) & ELF_RTYPE_CLASS_DLSYM) \ && ELF32_ST_TYPE((SYM)->st_info) == STT_FUNC \ - ? _dl_funcdesc_for (DL_RELOC_ADDR ((TPNT)->loadaddr, (SYM)->st_value), \ + ? _dl_funcdesc_for ((void *)DL_RELOC_ADDR ((TPNT)->loadaddr, (SYM)->st_value), \ (TPNT)->loadaddr.got_value) \ : DL_RELOC_ADDR ((TPNT)->loadaddr, (SYM)->st_value)) diff --git a/ldso/ldso/dl-hash.c b/ldso/ldso/dl-hash.c index 559996289..5ccef1f64 100644 --- a/ldso/ldso/dl-hash.c +++ b/ldso/ldso/dl-hash.c @@ -152,7 +152,8 @@ struct elf_resolve *_dl_add_elf_hash_table(const char *libname, hash_addr += tpnt->nbucket; tpnt->chains = hash_addr; } - tpnt->loadaddr = tpnt->mapaddr = loadaddr; + tpnt->loadaddr = loadaddr; + tpnt->mapaddr = DL_RELOC_ADDR(loadaddr, 0); for (i = 0; i < DYNAMIC_SIZE; i++) tpnt->dynamic_info[i] = dynamic_info[i]; return tpnt; diff --git a/ldso/ldso/ldso.c b/ldso/ldso/ldso.c index 15e03f560..b93fff881 100644 --- a/ldso/ldso/ldso.c +++ b/ldso/ldso/ldso.c @@ -135,7 +135,7 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr, char **argv DL_GET_READY_TO_RUN_EXTRA_PARMS) { - DL_LOADADDR_TYPE app_loadaddr = NULL; + ElfW(Addr) app_mapaddr = 0; ElfW(Phdr) *ppnt; ElfW(Dyn) *dpnt; char *lpntstr; @@ -277,8 +277,8 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr, relro_addr = ppnt->p_vaddr; relro_size = ppnt->p_memsz; } - if (!app_loadaddr && (ppnt->p_type == PT_LOAD)) { - app_loadaddr = ppnt->p_vaddr; + if (!app_mapaddr && (ppnt->p_type == PT_LOAD)) { + app_mapaddr = DL_RELOC_ADDR (app_tpnt->loadaddr, ppnt->p_vaddr); } if (ppnt->p_type == PT_DYNAMIC) { dpnt = (ElfW(Dyn) *) DL_RELOC_ADDR(app_tpnt->loadaddr, ppnt->p_vaddr); @@ -326,7 +326,7 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr, _dl_symbol_tables = rpnt = (struct dyn_elf *) _dl_malloc(sizeof(struct dyn_elf)); _dl_memset(rpnt, 0, sizeof(struct dyn_elf)); rpnt->dyn = _dl_loaded_modules; - app_tpnt->mapaddr = app_loadaddr; + app_tpnt->mapaddr = app_mapaddr; app_tpnt->rtld_flags = unlazy | RTLD_GLOBAL; app_tpnt->usage_count++; app_tpnt->symbol_scope = _dl_symbol_tables; diff --git a/ldso/libdl/libdl.c b/ldso/libdl/libdl.c index 6dc60587b..4f164d702 100644 --- a/ldso/libdl/libdl.c +++ b/ldso/libdl/libdl.c @@ -743,7 +743,7 @@ int dladdr(const void *__address, Dl_info * __info) /* Set the info for the object the address lies in */ __info->dli_fname = pelf->libname; - __info->dli_fbase = (void *) DL_LOADADDR_BASE(pelf->mapaddr); + __info->dli_fbase = pelf->mapaddr; symtab = (ElfW(Sym) *) (pelf->dynamic_info[DT_SYMTAB]); strtab = (char *) (pelf->dynamic_info[DT_STRTAB]); -- cgit v1.2.3