diff options
Diffstat (limited to 'ldso')
-rw-r--r-- | ldso/ldso/dl-elf.c | 11 | ||||
-rw-r--r-- | ldso/ldso/dl-hash.c | 10 | ||||
-rw-r--r-- | ldso/ldso/hash.c | 10 | ||||
-rw-r--r-- | ldso/ldso/ld_hash.h | 6 | ||||
-rw-r--r-- | ldso/ldso/ld_string.h | 10 | ||||
-rw-r--r-- | ldso/ldso/ldso.c | 27 | ||||
-rw-r--r-- | ldso/ldso/readelflib1.c | 11 | ||||
-rw-r--r-- | ldso/ldso/sh/dl-sysdep.h | 62 | ||||
-rw-r--r-- | ldso/ldso/sh/elfinterp.c | 32 | ||||
-rw-r--r-- | ldso/ldso/sh/ld_sysdep.h | 62 |
10 files changed, 183 insertions, 58 deletions
diff --git a/ldso/ldso/dl-elf.c b/ldso/ldso/dl-elf.c index 8c2314184..a04ce5510 100644 --- a/ldso/ldso/dl-elf.c +++ b/ldso/ldso/dl-elf.c @@ -371,7 +371,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure, } _dl_read(infile, header, sizeof(header)); - epnt = (elfhdr *) header; + epnt = (elfhdr *) (intptr_t) header; if (epnt->e_ident[0] != 0x7f || epnt->e_ident[1] != 'E' || epnt->e_ident[2] != 'L' || @@ -398,7 +398,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure, return NULL; }; - ppnt = (elf_phdr *) & header[epnt->e_phoff]; + ppnt = (elf_phdr *)(intptr_t) & header[epnt->e_phoff]; piclib = 1; for (i = 0; i < epnt->e_phnum; i++) { @@ -446,7 +446,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure, flags |= MAP_FIXED; /* Get the memory to store the library */ - ppnt = (elf_phdr *) & header[epnt->e_phoff]; + ppnt = (elf_phdr *)(intptr_t) & header[epnt->e_phoff]; for (i = 0; i < epnt->e_phnum; i++) { if (ppnt->p_type == PT_LOAD) { @@ -543,6 +543,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure, #if defined(__mips__) { + int i = 1; Elf32_Dyn *dpnt = (Elf32_Dyn *) dynamic_addr; @@ -571,7 +572,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure, back again later. */ if (dynamic_info[DT_TEXTREL]) { - ppnt = (elf_phdr *) & header[epnt->e_phoff]; + ppnt = (elf_phdr *)(intptr_t) & header[epnt->e_phoff]; for (i = 0; i < epnt->e_phnum; i++, ppnt++) { if (ppnt->p_type == PT_LOAD && !(ppnt->p_flags & PF_W)) _dl_mprotect((void *) ((piclib ? libaddr : 0) + @@ -584,7 +585,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure, tpnt = _dl_add_elf_hash_table(libname, (char *) libaddr, dynamic_info, dynamic_addr, dynamic_size); - tpnt->ppnt = (elf_phdr *) (tpnt->loadaddr + epnt->e_phoff); + tpnt->ppnt = (elf_phdr *)(intptr_t) (tpnt->loadaddr + epnt->e_phoff); tpnt->n_phent = epnt->e_phnum; /* diff --git a/ldso/ldso/dl-hash.c b/ldso/ldso/dl-hash.c index 94744de3c..282555f93 100644 --- a/ldso/ldso/dl-hash.c +++ b/ldso/ldso/dl-hash.c @@ -78,7 +78,7 @@ unsigned long _dl_elf_hash(const char *name) /* * Check to see if a library has already been added to the hash chain. */ -struct elf_resolve *_dl_check_hashed_files(char *libname) +struct elf_resolve *_dl_check_hashed_files(const char *libname) { struct elf_resolve *tpnt; int len = _dl_strlen(libname); @@ -98,7 +98,7 @@ struct elf_resolve *_dl_check_hashed_files(char *libname) * externals properly. */ -struct elf_resolve *_dl_add_elf_hash_table(char *libname, +struct elf_resolve *_dl_add_elf_hash_table(const char *libname, char *loadaddr, unsigned long *dynamic_info, unsigned long dynamic_addr, unsigned long dynamic_size) { @@ -128,7 +128,7 @@ struct elf_resolve *_dl_add_elf_hash_table(char *libname, tpnt->libtype = loaded_file; if (dynamic_info[DT_HASH] != 0) { - hash_addr = (unsigned long *) (dynamic_info[DT_HASH] + loadaddr); + hash_addr = (unsigned long *) (intptr_t)(dynamic_info[DT_HASH] + loadaddr); tpnt->nbucket = *hash_addr++; tpnt->nchain = *hash_addr++; tpnt->elf_buckets = hash_addr; @@ -162,7 +162,7 @@ struct elf_resolve *_dl_add_elf_hash_table(char *libname, * relocations or when we call an entry in the PLT table for the first time. */ -char *_dl_find_hash(char *name, struct dyn_elf *rpnt1, +char *_dl_find_hash(const char *name, struct dyn_elf *rpnt1, struct elf_resolve *f_tpnt, enum caller_type caller_type) { struct elf_resolve *tpnt; @@ -245,7 +245,7 @@ char *_dl_find_hash(char *name, struct dyn_elf *rpnt1, * Avoid calling .urem here. */ do_rem(hn, elf_hash_number, tpnt->nbucket); - symtab = (Elf32_Sym *) (tpnt->dynamic_info[DT_SYMTAB] + tpnt->loadaddr); + symtab = (Elf32_Sym *) (intptr_t) (tpnt->dynamic_info[DT_SYMTAB] + tpnt->loadaddr); strtab = (char *) (tpnt->dynamic_info[DT_STRTAB] + tpnt->loadaddr); /* * This crap is required because the first instance of a diff --git a/ldso/ldso/hash.c b/ldso/ldso/hash.c index 94744de3c..282555f93 100644 --- a/ldso/ldso/hash.c +++ b/ldso/ldso/hash.c @@ -78,7 +78,7 @@ unsigned long _dl_elf_hash(const char *name) /* * Check to see if a library has already been added to the hash chain. */ -struct elf_resolve *_dl_check_hashed_files(char *libname) +struct elf_resolve *_dl_check_hashed_files(const char *libname) { struct elf_resolve *tpnt; int len = _dl_strlen(libname); @@ -98,7 +98,7 @@ struct elf_resolve *_dl_check_hashed_files(char *libname) * externals properly. */ -struct elf_resolve *_dl_add_elf_hash_table(char *libname, +struct elf_resolve *_dl_add_elf_hash_table(const char *libname, char *loadaddr, unsigned long *dynamic_info, unsigned long dynamic_addr, unsigned long dynamic_size) { @@ -128,7 +128,7 @@ struct elf_resolve *_dl_add_elf_hash_table(char *libname, tpnt->libtype = loaded_file; if (dynamic_info[DT_HASH] != 0) { - hash_addr = (unsigned long *) (dynamic_info[DT_HASH] + loadaddr); + hash_addr = (unsigned long *) (intptr_t)(dynamic_info[DT_HASH] + loadaddr); tpnt->nbucket = *hash_addr++; tpnt->nchain = *hash_addr++; tpnt->elf_buckets = hash_addr; @@ -162,7 +162,7 @@ struct elf_resolve *_dl_add_elf_hash_table(char *libname, * relocations or when we call an entry in the PLT table for the first time. */ -char *_dl_find_hash(char *name, struct dyn_elf *rpnt1, +char *_dl_find_hash(const char *name, struct dyn_elf *rpnt1, struct elf_resolve *f_tpnt, enum caller_type caller_type) { struct elf_resolve *tpnt; @@ -245,7 +245,7 @@ char *_dl_find_hash(char *name, struct dyn_elf *rpnt1, * Avoid calling .urem here. */ do_rem(hn, elf_hash_number, tpnt->nbucket); - symtab = (Elf32_Sym *) (tpnt->dynamic_info[DT_SYMTAB] + tpnt->loadaddr); + symtab = (Elf32_Sym *) (intptr_t) (tpnt->dynamic_info[DT_SYMTAB] + tpnt->loadaddr); strtab = (char *) (tpnt->dynamic_info[DT_STRTAB] + tpnt->loadaddr); /* * This crap is required because the first instance of a diff --git a/ldso/ldso/ld_hash.h b/ldso/ldso/ld_hash.h index b19d680a2..fab9a22ab 100644 --- a/ldso/ldso/ld_hash.h +++ b/ldso/ldso/ld_hash.h @@ -110,13 +110,13 @@ extern struct dyn_elf * _dl_symbol_tables; extern struct elf_resolve * _dl_loaded_modules; extern struct dyn_elf * _dl_handles; -extern struct elf_resolve * _dl_check_hashed_files(char * libname); -extern struct elf_resolve * _dl_add_elf_hash_table(char * libname, +extern struct elf_resolve * _dl_check_hashed_files(const char * libname); +extern struct elf_resolve * _dl_add_elf_hash_table(const char * libname, char * loadaddr, unsigned long * dynamic_info, unsigned long dynamic_addr, unsigned long dynamic_size); enum caller_type{symbolrel=0,copyrel=1,resolver=2}; -extern char * _dl_find_hash(char * name, struct dyn_elf * rpnt1, +extern char * _dl_find_hash(const char * name, struct dyn_elf * rpnt1, struct elf_resolve * f_tpnt, enum caller_type); extern int _dl_linux_dynamic_link(void); diff --git a/ldso/ldso/ld_string.h b/ldso/ldso/ld_string.h index 1de9f8d76..3eaad8f24 100644 --- a/ldso/ldso/ld_string.h +++ b/ldso/ldso/ld_string.h @@ -4,8 +4,8 @@ #include <sys/types.h> /* for size_t */ extern void *_dl_malloc(int size); -extern char *_dl_getenv(char *symbol, char **envp); -extern void _dl_unsetenv(char *symbol, char **envp); +extern char *_dl_getenv(const char *symbol, char **envp); +extern void _dl_unsetenv(const char *symbol, char **envp); extern char *_dl_strdup(const char *string); extern void _dl_dprintf(int, const char *, ...); @@ -65,7 +65,7 @@ static inline char * _dl_strcpy(char * dst,const char *src) static inline int _dl_strcmp(const char * s1,const char * s2) { - unsigned register char c1, c2; + register unsigned char c1, c2; do { c1 = (unsigned char) *s1++; @@ -80,8 +80,8 @@ static inline int _dl_strcmp(const char * s1,const char * s2) static inline int _dl_strncmp(const char * s1,const char * s2,size_t len) { - unsigned register char c1 = '\0'; - unsigned register char c2 = '\0'; + register unsigned char c1 = '\0'; + register unsigned char c2 = '\0'; while (len > 0) { c1 = (unsigned char) *s1++; diff --git a/ldso/ldso/ldso.c b/ldso/ldso/ldso.c index 9c94e7e97..be0c92806 100644 --- a/ldso/ldso/ldso.c +++ b/ldso/ldso/ldso.c @@ -160,8 +160,6 @@ void *(*_dl_malloc_function) (int size) = NULL; struct r_debug *_dl_debug_addr = NULL; unsigned long *_dl_brkp; unsigned long *_dl_envp; -char *_dl_getenv(char *symbol, char **envp); -void _dl_unsetenv(char *symbol, char **envp); int _dl_fixup(struct elf_resolve *tpnt); void _dl_debug_state(void); char *_dl_get_last_path_component(char *path); @@ -471,7 +469,7 @@ LD_BOOT(unsigned long args) /* First cover the shared library/dynamic linker. */ if (tpnt->dynamic_info[DT_TEXTREL]) { header = (elfhdr *) auxvt[AT_BASE].a_un.a_ptr; - ppnt = (elf_phdr *) (auxvt[AT_BASE].a_un.a_ptr + + ppnt = (elf_phdr *) ((int)auxvt[AT_BASE].a_un.a_ptr + header->e_phoff); for (i = 0; i < header->e_phnum; i++, ppnt++) { if (ppnt->p_type == PT_LOAD && !(ppnt->p_flags & PF_W)) { @@ -516,7 +514,7 @@ LD_BOOT(unsigned long args) goof = 0; for (indx = 0; indx < 2; indx++) { - int i; + unsigned int i; ELF_RELOC *rpnt; unsigned long *reloc_addr; unsigned long symbol_addr; @@ -755,7 +753,7 @@ static void _dl_get_ready_to_run(struct elf_resolve *tpnt, struct elf_resolve *a /* Determine if the shared lib loader is a symlink */ _dl_memset(buf, 0, sizeof(buf)); readsize = _dl_readlink(tpnt->libname, buf, sizeof(buf)); - if (readsize > 0 && readsize < sizeof(buf)-1) { + if (readsize > 0 && readsize < (int)(sizeof(buf)-1)) { pnt1 = _dl_strrchr(buf, '/'); if (pnt1 && buf != pnt1) { #ifdef LD_DEBUG @@ -1161,13 +1159,12 @@ static void _dl_get_ready_to_run(struct elf_resolve *tpnt, struct elf_resolve *a up each symbol individually. */ - _dl_brkp = (unsigned long *) _dl_find_hash("___brk_addr", NULL, NULL, symbolrel); + _dl_brkp = (unsigned long *) (intptr_t) _dl_find_hash("___brk_addr", NULL, NULL, symbolrel); if (_dl_brkp) { *_dl_brkp = brk_addr; } - _dl_envp = - (unsigned long *) _dl_find_hash("__environ", NULL, NULL, symbolrel); + _dl_envp = (unsigned long *) (intptr_t) _dl_find_hash("__environ", NULL, NULL, symbolrel); if (_dl_envp) { *_dl_envp = (unsigned long) envp; @@ -1175,7 +1172,7 @@ static void _dl_get_ready_to_run(struct elf_resolve *tpnt, struct elf_resolve *a #ifdef DO_MPROTECT_HACKS { - int j; + unsigned int j; elf_phdr *myppnt; /* We had to set the protections of all pages to R/W for dynamic linking. @@ -1191,7 +1188,7 @@ static void _dl_get_ready_to_run(struct elf_resolve *tpnt, struct elf_resolve *a } #endif - _dl_atexit = (int (*)(void *)) _dl_find_hash("atexit", NULL, NULL, symbolrel); + _dl_atexit = (int (*)(void *)) (intptr_t) _dl_find_hash("atexit", NULL, NULL, symbolrel); /* * OK, fix one more thing - set up the debug_addr structure to point @@ -1233,7 +1230,7 @@ static void _dl_get_ready_to_run(struct elf_resolve *tpnt, struct elf_resolve *a tpnt->init_flag |= INIT_FUNCS_CALLED; if (tpnt->dynamic_info[DT_INIT]) { - _dl_elf_init = (int (*)(void)) (tpnt->loadaddr + tpnt->dynamic_info[DT_INIT]); + _dl_elf_init = (int (*)(void)) (intptr_t) (tpnt->loadaddr + tpnt->dynamic_info[DT_INIT]); #if defined (SUPPORT_LD_DEBUG) if(_dl_debug) _dl_dprintf(_dl_debug_file,"\ncalling init: %s\n\n", tpnt->libname); @@ -1354,10 +1351,10 @@ void *_dl_malloc(int size) return retval; } -char *_dl_getenv(char *symbol, char **envp) +char *_dl_getenv(const char *symbol, char **envp) { char *pnt; - char *pnt1; + const char *pnt1; while ((pnt = *envp++)) { pnt1 = symbol; @@ -1370,10 +1367,10 @@ char *_dl_getenv(char *symbol, char **envp) return 0; } -void _dl_unsetenv(char *symbol, char **envp) +void _dl_unsetenv(const char *symbol, char **envp) { char *pnt; - char *pnt1; + const char *pnt1; char **newenvp = envp; for (pnt = *envp; pnt; pnt = *++envp) { diff --git a/ldso/ldso/readelflib1.c b/ldso/ldso/readelflib1.c index 8c2314184..a04ce5510 100644 --- a/ldso/ldso/readelflib1.c +++ b/ldso/ldso/readelflib1.c @@ -371,7 +371,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure, } _dl_read(infile, header, sizeof(header)); - epnt = (elfhdr *) header; + epnt = (elfhdr *) (intptr_t) header; if (epnt->e_ident[0] != 0x7f || epnt->e_ident[1] != 'E' || epnt->e_ident[2] != 'L' || @@ -398,7 +398,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure, return NULL; }; - ppnt = (elf_phdr *) & header[epnt->e_phoff]; + ppnt = (elf_phdr *)(intptr_t) & header[epnt->e_phoff]; piclib = 1; for (i = 0; i < epnt->e_phnum; i++) { @@ -446,7 +446,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure, flags |= MAP_FIXED; /* Get the memory to store the library */ - ppnt = (elf_phdr *) & header[epnt->e_phoff]; + ppnt = (elf_phdr *)(intptr_t) & header[epnt->e_phoff]; for (i = 0; i < epnt->e_phnum; i++) { if (ppnt->p_type == PT_LOAD) { @@ -543,6 +543,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure, #if defined(__mips__) { + int i = 1; Elf32_Dyn *dpnt = (Elf32_Dyn *) dynamic_addr; @@ -571,7 +572,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure, back again later. */ if (dynamic_info[DT_TEXTREL]) { - ppnt = (elf_phdr *) & header[epnt->e_phoff]; + ppnt = (elf_phdr *)(intptr_t) & header[epnt->e_phoff]; for (i = 0; i < epnt->e_phnum; i++, ppnt++) { if (ppnt->p_type == PT_LOAD && !(ppnt->p_flags & PF_W)) _dl_mprotect((void *) ((piclib ? libaddr : 0) + @@ -584,7 +585,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure, tpnt = _dl_add_elf_hash_table(libname, (char *) libaddr, dynamic_info, dynamic_addr, dynamic_size); - tpnt->ppnt = (elf_phdr *) (tpnt->loadaddr + epnt->e_phoff); + tpnt->ppnt = (elf_phdr *)(intptr_t) (tpnt->loadaddr + epnt->e_phoff); tpnt->n_phent = epnt->e_phnum; /* diff --git a/ldso/ldso/sh/dl-sysdep.h b/ldso/ldso/sh/dl-sysdep.h index 00938b655..a0ff05fdb 100644 --- a/ldso/ldso/sh/dl-sysdep.h +++ b/ldso/ldso/sh/dl-sysdep.h @@ -77,7 +77,67 @@ struct elf_resolve; extern unsigned long _dl_linux_resolver(struct elf_resolve * tpnt, int reloc_entry); -#define do_rem(result, n, base) result = (n % base) +static __inline__ unsigned int +_dl_urem(unsigned int n, unsigned int base) +{ +register unsigned int __r0 __asm__ ("r0"); +register unsigned int __r4 __asm__ ("r4") = n; +register unsigned int __r5 __asm__ ("r5") = base; + + __asm__ (" + mov #0, r0 + div0u + + ! get one bit from the msb of the numerator into the T + ! bit and divide it by whats in %2. Put the answer bit + ! into the T bit so it can come out again at the bottom + + rotcl r4 ; div1 r5, r0 + rotcl r4 ; div1 r5, r0 + rotcl r4 ; div1 r5, r0 + rotcl r4 ; div1 r5, r0 + rotcl r4 ; div1 r5, r0 + rotcl r4 ; div1 r5, r0 + rotcl r4 ; div1 r5, r0 + rotcl r4 ; div1 r5, r0 + + rotcl r4 ; div1 r5, r0 + rotcl r4 ; div1 r5, r0 + rotcl r4 ; div1 r5, r0 + rotcl r4 ; div1 r5, r0 + rotcl r4 ; div1 r5, r0 + rotcl r4 ; div1 r5, r0 + rotcl r4 ; div1 r5, r0 + rotcl r4 ; div1 r5, r0 + + rotcl r4 ; div1 r5, r0 + rotcl r4 ; div1 r5, r0 + rotcl r4 ; div1 r5, r0 + rotcl r4 ; div1 r5, r0 + rotcl r4 ; div1 r5, r0 + rotcl r4 ; div1 r5, r0 + rotcl r4 ; div1 r5, r0 + rotcl r4 ; div1 r5, r0 + + rotcl r4 ; div1 r5, r0 + rotcl r4 ; div1 r5, r0 + rotcl r4 ; div1 r5, r0 + rotcl r4 ; div1 r5, r0 + rotcl r4 ; div1 r5, r0 + rotcl r4 ; div1 r5, r0 + rotcl r4 ; div1 r5, r0 + rotcl r4 ; div1 r5, r0 + rotcl r4 + mov r4, r0 +" + : "=r" (__r0) + : "r" (__r4), "r" (__r5) + : "r4", "cc"); + + return n - (base * __r0); +} + +#define do_rem(result, n, base) ((result) = _dl_urem((n), (base))) /* 4096 bytes alignment */ #define PAGE_ALIGN 0xfffff000 diff --git a/ldso/ldso/sh/elfinterp.c b/ldso/ldso/sh/elfinterp.c index 2a0ab9f7a..7dc1b4130 100644 --- a/ldso/ldso/sh/elfinterp.c +++ b/ldso/ldso/sh/elfinterp.c @@ -47,7 +47,7 @@ _dl_reltypes(int type) static char buf[22]; const char *str; - if (type >= (sizeof (_dl_reltypes_tab)/sizeof(_dl_reltypes_tab[0])) || + if (type >= (int)(sizeof (_dl_reltypes_tab)/sizeof(_dl_reltypes_tab[0])) || NULL == (str = _dl_reltypes_tab[type])) { str =_dl_simple_ltoa( buf, (unsigned long)(type)); @@ -124,11 +124,11 @@ unsigned long _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry) rel_addr = (char *) (tpnt->dynamic_info[DT_JMPREL] + tpnt->loadaddr); - this_reloc = (ELF_RELOC *) (rel_addr + reloc_entry); + this_reloc = (ELF_RELOC *)(intptr_t)(rel_addr + reloc_entry); reloc_type = ELF32_R_TYPE(this_reloc->r_info); symtab_index = ELF32_R_SYM(this_reloc->r_info); - symtab = (Elf32_Sym *) (tpnt->dynamic_info[DT_SYMTAB] + tpnt->loadaddr); + symtab = (Elf32_Sym *)(intptr_t) (tpnt->dynamic_info[DT_SYMTAB] + tpnt->loadaddr); strtab = (char *) (tpnt->dynamic_info[DT_STRTAB] + tpnt->loadaddr); if (reloc_type != R_SH_JMP_SLOT) { @@ -183,7 +183,7 @@ _dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope, int (*reloc_fnc) (struct elf_resolve *tpnt, struct dyn_elf *scope, ELF_RELOC *rpnt, Elf32_Sym *symtab, char *strtab)) { - int i; + unsigned int i; char *strtab; int goof = 0; Elf32_Sym *symtab; @@ -191,10 +191,10 @@ _dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope, int symtab_index; /* Now parse the relocation information */ - rpnt = (ELF_RELOC *) (rel_addr + tpnt->loadaddr); + rpnt = (ELF_RELOC *)(intptr_t) (rel_addr + tpnt->loadaddr); rel_size = rel_size / sizeof(ELF_RELOC); - symtab = (Elf32_Sym *) (tpnt->dynamic_info[DT_SYMTAB] + tpnt->loadaddr); + symtab = (Elf32_Sym *)(intptr_t) (tpnt->dynamic_info[DT_SYMTAB] + tpnt->loadaddr); strtab = (char *) (tpnt->dynamic_info[DT_STRTAB] + tpnt->loadaddr); for (i = 0; i < rel_size; i++, rpnt++) { @@ -254,7 +254,7 @@ _dl_do_reloc (struct elf_resolve *tpnt,struct dyn_elf *scope, unsigned long symbol_addr; int goof = 0; - reloc_addr = (unsigned long *) (tpnt->loadaddr + (unsigned long) rpnt->r_offset); + reloc_addr = (unsigned long *)(intptr_t) (tpnt->loadaddr + (unsigned long) rpnt->r_offset); reloc_type = ELF32_R_TYPE(rpnt->r_info); symtab_index = ELF32_R_SYM(rpnt->r_info); symbol_addr = 0; @@ -318,10 +318,13 @@ static int _dl_do_lazy_reloc (struct elf_resolve *tpnt, struct dyn_elf *scope, ELF_RELOC *rpnt, Elf32_Sym *symtab, char *strtab) { - int reloc_type; + int reloc_type; unsigned long *reloc_addr; + (void)scope; + (void)symtab; + (void)strtab; - reloc_addr = (unsigned long *) (tpnt->loadaddr + (unsigned long) rpnt->r_offset); + reloc_addr = (unsigned long *)(intptr_t) (tpnt->loadaddr + (unsigned long) rpnt->r_offset); reloc_type = ELF32_R_TYPE(rpnt->r_info); #if defined (SUPPORT_LD_DEBUG) @@ -365,7 +368,7 @@ _dl_do_copy (struct elf_resolve *tpnt, struct dyn_elf *scope, unsigned long symbol_addr; int goof = 0; - reloc_addr = (unsigned long *) (tpnt->loadaddr + (unsigned long) rpnt->r_offset); + reloc_addr = (unsigned long *)(intptr_t) (tpnt->loadaddr + (unsigned long) rpnt->r_offset); reloc_type = ELF32_R_TYPE(rpnt->r_info); if (reloc_type != R_SH_COPY) return 0; @@ -398,19 +401,22 @@ _dl_do_copy (struct elf_resolve *tpnt, struct dyn_elf *scope, void _dl_parse_lazy_relocation_information(struct elf_resolve *tpnt, unsigned long rel_addr, unsigned long rel_size, int type) { - (void)_dl_parse(tpnt, NULL, rel_addr, rel_size, _dl_do_lazy_reloc); + (void) type; + (void)_dl_parse(tpnt, NULL, rel_addr, rel_size, _dl_do_lazy_reloc); } int _dl_parse_relocation_information(struct elf_resolve *tpnt, unsigned long rel_addr, unsigned long rel_size, int type) { - return _dl_parse(tpnt, tpnt->symbol_scope, rel_addr, rel_size, _dl_do_reloc); + (void) type; + return _dl_parse(tpnt, tpnt->symbol_scope, rel_addr, rel_size, _dl_do_reloc); } int _dl_parse_copy_information(struct dyn_elf *xpnt, unsigned long rel_addr, unsigned long rel_size, int type) { - return _dl_parse(xpnt->dyn, xpnt->next, rel_addr, rel_size, _dl_do_copy); + (void) type; + return _dl_parse(xpnt->dyn, xpnt->next, rel_addr, rel_size, _dl_do_copy); } diff --git a/ldso/ldso/sh/ld_sysdep.h b/ldso/ldso/sh/ld_sysdep.h index 00938b655..a0ff05fdb 100644 --- a/ldso/ldso/sh/ld_sysdep.h +++ b/ldso/ldso/sh/ld_sysdep.h @@ -77,7 +77,67 @@ struct elf_resolve; extern unsigned long _dl_linux_resolver(struct elf_resolve * tpnt, int reloc_entry); -#define do_rem(result, n, base) result = (n % base) +static __inline__ unsigned int +_dl_urem(unsigned int n, unsigned int base) +{ +register unsigned int __r0 __asm__ ("r0"); +register unsigned int __r4 __asm__ ("r4") = n; +register unsigned int __r5 __asm__ ("r5") = base; + + __asm__ (" + mov #0, r0 + div0u + + ! get one bit from the msb of the numerator into the T + ! bit and divide it by whats in %2. Put the answer bit + ! into the T bit so it can come out again at the bottom + + rotcl r4 ; div1 r5, r0 + rotcl r4 ; div1 r5, r0 + rotcl r4 ; div1 r5, r0 + rotcl r4 ; div1 r5, r0 + rotcl r4 ; div1 r5, r0 + rotcl r4 ; div1 r5, r0 + rotcl r4 ; div1 r5, r0 + rotcl r4 ; div1 r5, r0 + + rotcl r4 ; div1 r5, r0 + rotcl r4 ; div1 r5, r0 + rotcl r4 ; div1 r5, r0 + rotcl r4 ; div1 r5, r0 + rotcl r4 ; div1 r5, r0 + rotcl r4 ; div1 r5, r0 + rotcl r4 ; div1 r5, r0 + rotcl r4 ; div1 r5, r0 + + rotcl r4 ; div1 r5, r0 + rotcl r4 ; div1 r5, r0 + rotcl r4 ; div1 r5, r0 + rotcl r4 ; div1 r5, r0 + rotcl r4 ; div1 r5, r0 + rotcl r4 ; div1 r5, r0 + rotcl r4 ; div1 r5, r0 + rotcl r4 ; div1 r5, r0 + + rotcl r4 ; div1 r5, r0 + rotcl r4 ; div1 r5, r0 + rotcl r4 ; div1 r5, r0 + rotcl r4 ; div1 r5, r0 + rotcl r4 ; div1 r5, r0 + rotcl r4 ; div1 r5, r0 + rotcl r4 ; div1 r5, r0 + rotcl r4 ; div1 r5, r0 + rotcl r4 + mov r4, r0 +" + : "=r" (__r0) + : "r" (__r4), "r" (__r5) + : "r4", "cc"); + + return n - (base * __r0); +} + +#define do_rem(result, n, base) ((result) = _dl_urem((n), (base))) /* 4096 bytes alignment */ #define PAGE_ALIGN 0xfffff000 |