From 59cc1e9342e9782cc4d999a2b0649dccdcfd2c6c Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Thu, 30 Jun 2005 22:32:29 +0000 Subject: create generic ELF_* macros to hide 32/64 bit differences --- ldso/include/dl-elf.h | 20 ++++++++++++++++++++ ldso/ldso/dl-hash.c | 4 ++-- ldso/ldso/dl-startup.c | 4 ++-- 3 files changed, 24 insertions(+), 4 deletions(-) (limited to 'ldso') diff --git a/ldso/include/dl-elf.h b/ldso/include/dl-elf.h index 4382eee42..77dc7fb14 100644 --- a/ldso/include/dl-elf.h +++ b/ldso/include/dl-elf.h @@ -35,6 +35,26 @@ extern int _dl_linux_resolve(void); extern int _dl_fixup(struct dyn_elf *rpnt, int flag); extern void _dl_protect_relro (struct elf_resolve *l); +/* + * Bitsize related settings for things ElfW() + * does not handle already + */ +#if __WORDSIZE == 64 +# define ELF_ST_BIND(val) ELF64_ST_TYPE(val) +# define ELF_ST_TYPE(val) ELF64_ST_TYPE(val) +# define ELF_R_SYM(i) ELF64_R_SYM(i) +# ifndef ELF_CLASS +# define ELF_CLASS ELFCLASS64 +# endif +#else +# define ELF_ST_BIND(val) ELF32_ST_TYPE(val) +# define ELF_ST_TYPE(val) ELF32_ST_TYPE(val) +# define ELF_R_SYM(i) ELF32_R_SYM(i) +# ifndef ELF_CLASS +# define ELF_CLASS ELFCLASS32 +# endif +#endif + /* * Datatype of a relocation on this platform */ diff --git a/ldso/ldso/dl-hash.c b/ldso/ldso/dl-hash.c index 04cd3d64e..256f432f7 100644 --- a/ldso/ldso/dl-hash.c +++ b/ldso/ldso/dl-hash.c @@ -190,10 +190,10 @@ char *_dl_find_hash(const char *name, struct dyn_elf *rpnt, struct elf_resolve * continue; if (sym->st_value == 0) continue; - if (ELF32_ST_TYPE(sym->st_info) > STT_FUNC) + if (ELF_ST_TYPE(sym->st_info) > STT_FUNC) continue; - switch (ELF32_ST_BIND(sym->st_info)) { + switch (ELF_ST_BIND(sym->st_info)) { case STB_WEAK: #if 0 /* Perhaps we should support old style weak symbol handling diff --git a/ldso/ldso/dl-startup.c b/ldso/ldso/dl-startup.c index 8b54bc9ee..f55330124 100644 --- a/ldso/ldso/dl-startup.c +++ b/ldso/ldso/dl-startup.c @@ -164,7 +164,7 @@ static void * __attribute_used__ _dl_start(unsigned long args) header = (ElfW(Ehdr) *) auxvt[AT_BASE].a_un.a_ptr; /* Check the ELF header to make sure everything looks ok. */ - if (!header || header->e_ident[EI_CLASS] != ELFCLASS32 || + if (!header || header->e_ident[EI_CLASS] != ELF_CLASS || header->e_ident[EI_VERSION] != EV_CURRENT /* Do not use an inline _dl_strncmp here or some arches * will blow chunks, i.e. those that need to relocate all @@ -255,7 +255,7 @@ static void * __attribute_used__ _dl_start(unsigned long args) rpnt = (ELF_RELOC *) (rel_addr + load_addr); for (i = 0; i < rel_size; i += sizeof(ELF_RELOC), rpnt++) { reloc_addr = (unsigned long *) (load_addr + (unsigned long) rpnt->r_offset); - symtab_index = ELF32_R_SYM(rpnt->r_info); + symtab_index = ELF_R_SYM(rpnt->r_info); symbol_addr = 0; sym = NULL; if (symtab_index) { -- cgit v1.2.3