summaryrefslogtreecommitdiff
path: root/ldso/ldso/sparc/elfinterp.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2004-06-12 08:38:39 +0000
committerEric Andersen <andersen@codepoet.org>2004-06-12 08:38:39 +0000
commit018f4ef5f8b9c7fb3e0fa3574bfd2c17f24b4253 (patch)
tree867d2f0fba3a98909872dc2e6abe8a0da8bb2c10 /ldso/ldso/sparc/elfinterp.c
parent2ca977faefda1b8c807291e3ee4a817d919b44de (diff)
Jakub Bogusz from pld-linux dot org writes:
Hello, I managed to get ldso (and thus shared linking to uClibc) to work on sparc (actually sparc64 kernel with 32-bit userspace), at least on simple "hello world" program (more complex ones not tested). Some notes on attached patch (against 0.9.26, would require some work to apply on current CVS - but I tested 0.9.26, not CVS): - ELF magic cannot be examined by _dl_strncmp so early, probably because of string constant, like on ppc/mips/sh (note that early SEND_STDERR still crashes when trying to do _dl_strlen - I suppose that string constants require relocation; but adding load_addr didn't help, just ELF header was displayed instead of crash) - mmap() is syscall6 like on ppc/mips/sh, not old i386 mmap() - for generic sparc (i.e. not sparcv8/sparcv9) gcc produces .udiv/.urem calls for unsigned integer / and % operators - so these operations must be avoided. I copied do_rem definition from arm header. But / and % are used also in _dl_simple_ltoa() and _dl_simple_ltoahex(); in ltoahex gcc optimizes it to shifts (but I think it's safer to use shifts explicitly, not rely on optimization...). I changed % in ltoa to do_rem, but as there was no do_div definition, I changed all "%d" specifiers to "%x" to avoid crashes (this changes wouldn't be needed if _dl_simple_ltoa() were fixed to not use division on sparc). - "#define SOLARIS_COMPATIBLE" in ld_sysdep.h broke ldso on Linux because of redefining _dl_linux_resolve only in some places (it was still referenced in INIT_GOT before redefinition). So _dl_linux_resolve redefinition should be moved before INIT_GOT definition or removed. - sparc64 kernel requires mmap() addresses to be aligned to 8192, not 4096, otherwise mmap() call failed - reloc_entry must be shifted by 10, not 12 (I found similar operation in glibc sources) Aside of sparc-specific fixes: - I moved some _dl_dprintf()s inside if(_dl_debug_*) conditions (to avoid debugging messages when LD_DEBUG is not defined) - it seems that there was possible off-by-one in ltoa and ltoahex? they are called with char[22] as 1st argument, and then '\0' is stored in local[22] (_before_ p decrementation)... or am I missing something? If not, fix is included in patch.
Diffstat (limited to 'ldso/ldso/sparc/elfinterp.c')
-rw-r--r--ldso/ldso/sparc/elfinterp.c10
1 files changed, 7 insertions, 3 deletions
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);
}