diff options
Diffstat (limited to 'ldso')
-rw-r--r-- | ldso/include/dl-string.h | 17 | ||||
-rw-r--r-- | ldso/include/dl-syscall.h | 2 | ||||
-rw-r--r-- | ldso/ldso/dl-elf.c | 2 | ||||
-rw-r--r-- | ldso/ldso/sparc/dl-syscalls.h | 26 | ||||
-rw-r--r-- | ldso/ldso/sparc/dl-sysdep.h | 51 | ||||
-rw-r--r-- | ldso/ldso/sparc/elfinterp.c | 10 |
6 files changed, 92 insertions, 16 deletions
diff --git a/ldso/include/dl-string.h b/ldso/include/dl-string.h index cbb867010..05f8d7d32 100644 --- a/ldso/include/dl-string.h +++ b/ldso/include/dl-string.h @@ -204,15 +204,18 @@ static inline char *_dl_get_last_path_component(char *path) } /* Early on, we can't call printf, so use this to print out - * numbers using the SEND_STDERR() macro */ + * numbers using the SEND_STDERR() macro. Avoid using mod + * or using long division */ static inline char *_dl_simple_ltoa(char * local, unsigned long i) { /* 21 digits plus null terminator, good for 64-bit or smaller ints */ - char *p = &local[22]; + char *p = &local[21]; *p-- = '\0'; do { - *p-- = '0' + i % 10; - i /= 10; + char temp; + do_rem(temp, i, 10); + *p-- = '0' + temp; + i /= 10; } while (i > 0); return p + 1; } @@ -220,15 +223,15 @@ static inline char *_dl_simple_ltoa(char * local, unsigned long i) static inline char *_dl_simple_ltoahex(char * local, unsigned long i) { /* 21 digits plus null terminator, good for 64-bit or smaller ints */ - char *p = &local[22]; + char *p = &local[21]; *p-- = '\0'; do { - char temp = i % 0x10; + char temp = i & 0xf; if (temp <= 0x09) *p-- = '0' + temp; else *p-- = 'a' - 0x0a + temp; - i /= 0x10; + i >>= 4; } while (i > 0); *p-- = 'x'; *p-- = '0'; diff --git a/ldso/include/dl-syscall.h b/ldso/include/dl-syscall.h index 184c12fb1..fbe852d18 100644 --- a/ldso/include/dl-syscall.h +++ b/ldso/include/dl-syscall.h @@ -104,7 +104,7 @@ static inline _syscall0(gid_t, _dl_getpid); static inline _syscall3(int, _dl_readlink, const char *, path, char *, buf, size_t, bufsiz); #ifdef __NR_mmap -#if defined(__powerpc__) || defined(__mips__) || defined(__sh__) +#if defined(__powerpc__) || defined(__mips__) || defined(__sh__) || defined(__sparc__) /* PowerPC, MIPS and SuperH have a different calling convention for mmap(). */ #define __NR__dl_mmap __NR_mmap static inline _syscall6(void *, _dl_mmap, void *, start, size_t, length, diff --git a/ldso/ldso/dl-elf.c b/ldso/ldso/dl-elf.c index dc20252d0..d27e4ccb3 100644 --- a/ldso/ldso/dl-elf.c +++ b/ldso/ldso/dl-elf.c @@ -720,7 +720,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure, _dl_dprintf(2, "\n\tfile='%s'; generating link map\n", libname); _dl_dprintf(2, "\t\tdynamic: %x base: %x size: %x\n", dynamic_addr, libaddr, dynamic_size); - _dl_dprintf(2, "\t\t entry: %x phdr: %x phnum: %d\n\n", + _dl_dprintf(2, "\t\t entry: %x phdr: %x phnum: %x\n\n", epnt->e_entry + libaddr, tpnt->ppnt, tpnt->n_phent); } diff --git a/ldso/ldso/sparc/dl-syscalls.h b/ldso/ldso/sparc/dl-syscalls.h index 218e8a289..cf21061fd 100644 --- a/ldso/ldso/sparc/dl-syscalls.h +++ b/ldso/ldso/sparc/dl-syscalls.h @@ -158,3 +158,29 @@ if (__res < -255 || __res>=0) \ _dl_errno = -__res; \ return -1; \ } + +#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ + type5,arg5,type6,arg6) \ +type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \ +{ \ +long __res; \ +register long __g1 __asm__ ("g1") = __NR_##name; \ +register long __o0 __asm__ ("o0") = (long)(arg1); \ +register long __o1 __asm__ ("o1") = (long)(arg2); \ +register long __o2 __asm__ ("o2") = (long)(arg3); \ +register long __o3 __asm__ ("o3") = (long)(arg4); \ +register long __o4 __asm__ ("o4") = (long)(arg5); \ +register long __o5 __asm__ ("o5") = (long)(arg6); \ +__asm__ __volatile__ ("t 0x10\n\t" \ + "bcc 1f\n\t" \ + "mov %%o0, %0\n\t" \ + "sub %%g0, %%o0, %0\n\t" \ + "1:\n\t" \ + : "=r" (__res), "=&r" (__o0) \ + : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__o3), "r" (__o4), "r" (__o5), "r" (__g1) \ + : "cc"); \ +if (__res < -255 || __res>=0) \ + return (type) __res; \ +/*errno = -__res; */\ +return -1; \ +} diff --git a/ldso/ldso/sparc/dl-sysdep.h b/ldso/ldso/sparc/dl-sysdep.h index c6ac89e11..ddf74e21e 100644 --- a/ldso/ldso/sparc/dl-sysdep.h +++ b/ldso/ldso/sparc/dl-sysdep.h @@ -41,9 +41,51 @@ extern unsigned int _dl_linux_resolver(unsigned int reloc_entry, /* * Define this if you want a dynamic loader that works on Solaris. */ +#ifndef __linux__ #define SOLARIS_COMPATIBLE +#endif + +#ifndef COMPILE_ASM +/* Cheap modulo implementation, taken from arm/ld_sysdep.h. */ +static inline unsigned long +sparc_mod(unsigned long m, unsigned long p) +{ + unsigned long i, t, inc; + + i = p; + t = 0; + + while (!(i & (1 << 31))) { + i <<= 1; + t++; + } + + t--; + + for (inc = t; inc > 2; inc--) { + i = p << inc; -#define do_rem(result, n, base) result = (n % base) + if (i & (1 << 31)) + break; + + while (m >= i) { + m -= i; + i <<= 1; + if (i & (1 << 31)) + break; + if (i < p) + break; + } + } + + while (m >= p) + m -= p; + + return m; +} + +#define do_rem(result, n, base) result = sparc_mod(n, base); +#endif /* * dbx wants the binder to have a specific name. Mustn't disappoint it. @@ -53,9 +95,10 @@ extern unsigned int _dl_linux_resolver(unsigned int reloc_entry, #endif /* 4096 bytes alignment */ -#define PAGE_ALIGN 0xfffff000 -#define ADDR_ALIGN 0xfff -#define OFFS_ALIGN 0x7ffff000 +/* ...but 8192 is required for mmap() on sparc64 kernel */ +#define PAGE_ALIGN 0xffffe000 +#define ADDR_ALIGN 0x1fff +#define OFFS_ALIGN 0x7fffe000 /* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry, so PLT entries should not be allowed to define the value. diff --git a/ldso/ldso/sparc/elfinterp.c b/ldso/ldso/sparc/elfinterp.c index 41bde4fa8..98435cbd4 100644 --- a/ldso/ldso/sparc/elfinterp.c +++ b/ldso/ldso/sparc/elfinterp.c @@ -72,7 +72,7 @@ unsigned int _dl_linux_resolver(unsigned int reloc_entry, unsigned int * plt) /* * Generate the correct relocation index into the .rela.plt section. */ - reloc_entry = (reloc_entry >> 12) - 0xc; + reloc_entry = (reloc_entry >> 10) - 0xc; this_reloc = (Elf32_Rela *) ((char *) rel_addr + reloc_entry); @@ -82,10 +82,14 @@ unsigned int _dl_linux_resolver(unsigned int reloc_entry, unsigned int * plt) symtab = (Elf32_Sym *) (tpnt->dynamic_info[DT_SYMTAB] + tpnt->loadaddr); strtab = (char *) (tpnt->dynamic_info[DT_STRTAB] + tpnt->loadaddr); +#ifdef __SUPPORT_LD_DEBUG__ + if (_dl_debug_symbols) { _dl_dprintf(2, "tpnt = %x\n", tpnt); _dl_dprintf(2, "reloc = %x\n", this_reloc); _dl_dprintf(2, "symtab = %x\n", symtab); _dl_dprintf(2, "strtab = %x\n", strtab); + } +#endif if (unlikely(reloc_type != R_SPARC_JMP_SLOT)) { @@ -98,10 +102,10 @@ unsigned int _dl_linux_resolver(unsigned int reloc_entry, unsigned int * plt) instr_addr = ((int)this_reloc->r_offset + (int)tpnt->loadaddr); got_addr = (char **) instr_addr; - _dl_dprintf(2, "symtab_index %d\n", symtab_index); - #ifdef __SUPPORT_LD_DEBUG__ if (_dl_debug_symbols) { + _dl_dprintf(2, "symtab_index %x\n", symtab_index); + _dl_dprintf(2, "Resolving symbol %s\n", strtab + symtab[symtab_index].st_name); } |