From a60180c2655f71ba2f9ed3ab66d328f48d9ad772 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Wed, 5 Jul 2006 19:17:19 +0000 Subject: patch from Bernd Schmidt to abstract away load address types --- ldso/include/dl-defs.h | 9 +++++++++ ldso/include/dl-elf.h | 6 ++++-- ldso/include/dl-hash.h | 4 ++-- ldso/include/ldso.h | 4 ++-- ldso/ldso/dl-elf.c | 3 ++- ldso/ldso/dl-hash.c | 2 +- ldso/ldso/dl-startup.c | 2 +- ldso/ldso/ldso.c | 8 ++++---- 8 files changed, 25 insertions(+), 13 deletions(-) diff --git a/ldso/include/dl-defs.h b/ldso/include/dl-defs.h index 18f718bef..5cf260183 100644 --- a/ldso/include/dl-defs.h +++ b/ldso/include/dl-defs.h @@ -66,6 +66,15 @@ typedef struct { #endif +/* Machines in which different sections may be relocated by different + * amounts should define this and LD_RELOC_ADDR. If you change this, + * make sure you change struct link_map in include/link.h accordingly + * such that it matches a prefix of struct elf_resolve. + */ +#ifndef DL_LOADADDR_TYPE +# define DL_LOADADDR_TYPE ElfW(Addr) +#endif + /* Initialize a LOADADDR representing the loader itself. It's only * called from DL_BOOT, so additional arguments passed to it may be * referenced. diff --git a/ldso/include/dl-elf.h b/ldso/include/dl-elf.h index de404aec1..7b609d592 100644 --- a/ldso/include/dl-elf.h +++ b/ldso/include/dl-elf.h @@ -94,10 +94,12 @@ extern void _dl_protect_relro (struct elf_resolve *l); #define DYNAMIC_SIZE (DT_NUM+OS_NUM+ARCH_NUM) -extern void _dl_parse_dynamic_info(ElfW(Dyn) *dpnt, unsigned long dynamic_info[], void *debug_addr, ElfW(Addr) load_off); +extern void _dl_parse_dynamic_info(ElfW(Dyn) *dpnt, unsigned long dynamic_info[], + void *debug_addr, DL_LOADADDR_TYPE load_off); static __always_inline -void __dl_parse_dynamic_info(ElfW(Dyn) *dpnt, unsigned long dynamic_info[], void *debug_addr, ElfW(Addr) load_off) +void __dl_parse_dynamic_info(ElfW(Dyn) *dpnt, unsigned long dynamic_info[], + void *debug_addr, DL_LOADADDR_TYPE load_off) { for (; dpnt->d_tag; dpnt++) { if (dpnt->d_tag < DT_NUM) { diff --git a/ldso/include/dl-hash.h b/ldso/include/dl-hash.h index ad5c16318..8f30688d1 100644 --- a/ldso/include/dl-hash.h +++ b/ldso/include/dl-hash.h @@ -28,7 +28,7 @@ struct dyn_elf { struct elf_resolve { /* These entries must be in this order to be compatible with the interface used by gdb to obtain the list of symbols. */ - ElfW(Addr) loadaddr; /* Base address shared object is loaded at. */ + DL_LOADADDR_TYPE loadaddr; /* Base address shared object is loaded at. */ char *libname; /* Absolute file name object was found in. */ ElfW(Dyn) *dynamic_addr; /* Dynamic section of the shared object. */ struct elf_resolve * next; @@ -77,7 +77,7 @@ extern struct elf_resolve * _dl_loaded_modules; extern struct dyn_elf * _dl_handles; extern struct elf_resolve * _dl_add_elf_hash_table(const char * libname, - ElfW(Addr) loadaddr, unsigned long * dynamic_info, + DL_LOADADDR_TYPE loadaddr, unsigned long * dynamic_info, unsigned long dynamic_addr, unsigned long dynamic_size); extern char * _dl_find_hash(const char * name, struct dyn_elf * rpnt1, diff --git a/ldso/include/ldso.h b/ldso/include/ldso.h index 6b1e9cb4e..47b2fb513 100644 --- a/ldso/include/ldso.h +++ b/ldso/include/ldso.h @@ -88,7 +88,7 @@ extern void _dl_unsetenv(const char *symbol, char **envp); extern char *_dl_strdup(const char *string); extern void _dl_dprintf(int, const char *, ...); -extern void _dl_get_ready_to_run(struct elf_resolve *tpnt, ElfW(Addr) load_addr, - ElfW(auxv_t) auxvt[AT_EGID + 1], char **envp, char **argv); +extern void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr, + ElfW(auxv_t) auxvt[AT_EGID + 1], char **envp, char **argv); #endif /* _LDSO_H_ */ diff --git a/ldso/ldso/dl-elf.c b/ldso/ldso/dl-elf.c index 9c5b3b4fb..923e0cfe7 100644 --- a/ldso/ldso/dl-elf.c +++ b/ldso/ldso/dl-elf.c @@ -801,7 +801,8 @@ char *_dl_strdup(const char *string) return retval; } -void _dl_parse_dynamic_info(ElfW(Dyn) *dpnt, unsigned long dynamic_info[], void *debug_addr, ElfW(Addr) load_off) +void _dl_parse_dynamic_info(ElfW(Dyn) *dpnt, unsigned long dynamic_info[], + void *debug_addr, DL_LOADADDR_TYPE load_off) { __dl_parse_dynamic_info(dpnt, dynamic_info, debug_addr, load_off); } diff --git a/ldso/ldso/dl-hash.c b/ldso/ldso/dl-hash.c index be702be50..ccf191a70 100644 --- a/ldso/ldso/dl-hash.c +++ b/ldso/ldso/dl-hash.c @@ -83,7 +83,7 @@ static inline Elf_Symndx _dl_elf_hash(const char *name) * externals properly. */ struct elf_resolve *_dl_add_elf_hash_table(const char *libname, - ElfW(Addr) loadaddr, unsigned long *dynamic_info, unsigned long dynamic_addr, + DL_LOADADDR_TYPE loadaddr, unsigned long *dynamic_info, unsigned long dynamic_addr, attribute_unused unsigned long dynamic_size) { Elf_Symndx *hash_addr; diff --git a/ldso/ldso/dl-startup.c b/ldso/ldso/dl-startup.c index 18658cb26..4115f299c 100644 --- a/ldso/ldso/dl-startup.c +++ b/ldso/ldso/dl-startup.c @@ -114,7 +114,7 @@ static void * __attribute_used__ _dl_start(unsigned long args) { unsigned int argc; char **argv, **envp; - ElfW(Addr) load_addr; + DL_LOADADDR_TYPE load_addr; ElfW(Addr) got; unsigned long *aux_dat; ElfW(Ehdr) *header; diff --git a/ldso/ldso/ldso.c b/ldso/ldso/ldso.c index 4fe2bd1cb..82eb044bb 100644 --- a/ldso/ldso/ldso.c +++ b/ldso/ldso/ldso.c @@ -102,7 +102,7 @@ uintptr_t __guard attribute_relro; #endif static void _dl_run_array_forward(unsigned long array, unsigned long size, - ElfW(Addr) loadaddr) + DL_LOADADDR_TYPE loadaddr) { if (array != 0) { unsigned int j; @@ -173,9 +173,9 @@ static void __attribute__ ((destructor)) __attribute_used__ _dl_fini(void) } } -void _dl_get_ready_to_run(struct elf_resolve *tpnt, ElfW(Addr) load_addr, - ElfW(auxv_t) auxvt[AT_EGID + 1], char **envp, - char **argv) +void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr, + ElfW(auxv_t) auxvt[AT_EGID + 1], char **envp, + char **argv) { ElfW(Phdr) *ppnt; ElfW(Dyn) *dpnt; -- cgit v1.2.3