|
@@ -1,7 +1,7 @@
|
|
|
|
|
|
|
|
|
*
|
|
|
- * Copyright (C) 2002, Stefan Allius <allius@atecom.com> and
|
|
|
+ * Copyright (C) 2002, Stefan Allius <allius@atecom.com> and
|
|
|
* Eddie C. Dost <ecd@atecom.com>
|
|
|
*
|
|
|
* All rights reserved.
|
|
@@ -44,9 +44,9 @@ static const char *_dl_reltypes_tab[] =
|
|
|
static const char *
|
|
|
_dl_reltypes(int type)
|
|
|
{
|
|
|
- static char buf[22];
|
|
|
+ static char buf[22];
|
|
|
const char *str;
|
|
|
-
|
|
|
+
|
|
|
if (type >= (int)(sizeof (_dl_reltypes_tab)/sizeof(_dl_reltypes_tab[0])) ||
|
|
|
NULL == (str = _dl_reltypes_tab[type]))
|
|
|
{
|
|
@@ -55,7 +55,7 @@ _dl_reltypes(int type)
|
|
|
return str;
|
|
|
}
|
|
|
|
|
|
-static
|
|
|
+static
|
|
|
void debug_sym(Elf32_Sym *symtab,char *strtab,int symtab_index)
|
|
|
{
|
|
|
if(_dl_debug_symbols)
|
|
@@ -80,12 +80,12 @@ static void debug_reloc(Elf32_Sym *symtab,char *strtab, ELF_RELOC *rpnt)
|
|
|
const char *sym;
|
|
|
symtab_index = ELF32_R_SYM(rpnt->r_info);
|
|
|
sym = symtab_index ? strtab + symtab[symtab_index].st_name : "sym=0x0";
|
|
|
-
|
|
|
+
|
|
|
if(_dl_debug_symbols)
|
|
|
_dl_dprintf(_dl_debug_file, "\n\t");
|
|
|
else
|
|
|
_dl_dprintf(_dl_debug_file, "\n%s\n\t", sym);
|
|
|
-
|
|
|
+
|
|
|
#ifdef ELF_USES_RELOCA
|
|
|
_dl_dprintf(_dl_debug_file, "%s\toffset=%x\taddend=%x",
|
|
|
_dl_reltypes(ELF32_R_TYPE(rpnt->r_info)),
|
|
@@ -137,13 +137,13 @@ unsigned long _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry)
|
|
|
symname = strtab + symtab[symtab_index].st_name;
|
|
|
|
|
|
if (reloc_type != R_SH_JMP_SLOT) {
|
|
|
- _dl_dprintf(2, "%s: Incorrect relocation type in jump relocations\n",
|
|
|
+ _dl_dprintf(2, "%s: Incorrect relocation type in jump relocations\n",
|
|
|
_dl_progname);
|
|
|
_dl_exit(1);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
|
|
|
- instr_addr = ((unsigned long) this_reloc->r_offset +
|
|
|
+ instr_addr = ((unsigned long) this_reloc->r_offset +
|
|
|
(unsigned long) tpnt->loadaddr);
|
|
|
got_addr = (char **) instr_addr;
|
|
|
|
|
@@ -155,7 +155,7 @@ unsigned long _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry)
|
|
|
if (new_addr) {
|
|
|
return (unsigned long) new_addr;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
_dl_dprintf(2, "%s: can't resolve symbol '%s'\n", _dl_progname, symname);
|
|
|
_dl_exit(1);
|
|
|
}
|
|
@@ -166,7 +166,7 @@ unsigned long _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry)
|
|
|
if (_dl_debug_bindings)
|
|
|
{
|
|
|
_dl_dprintf(_dl_debug_file, "\nresolve function: %s", symname);
|
|
|
- if(_dl_debug_detail) _dl_dprintf(_dl_debug_file,
|
|
|
+ if(_dl_debug_detail) _dl_dprintf(_dl_debug_file,
|
|
|
"\n\tpatched %x ==> %x @ %x\n", *got_addr, new_addr, got_addr);
|
|
|
}
|
|
|
}
|
|
@@ -202,9 +202,9 @@ _dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope,
|
|
|
|
|
|
for (i = 0; i < rel_size; i++, rpnt++) {
|
|
|
int res;
|
|
|
-
|
|
|
+
|
|
|
symtab_index = ELF32_R_SYM(rpnt->r_info);
|
|
|
-
|
|
|
+
|
|
|
|
|
|
Make sure we do not do them again */
|
|
|
if (!symtab_index && tpnt->libtype == program_interpreter)
|
|
@@ -223,10 +223,10 @@ _dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope,
|
|
|
if (res==0) continue;
|
|
|
|
|
|
_dl_dprintf(2, "\n%s: ",_dl_progname);
|
|
|
-
|
|
|
+
|
|
|
if (symtab_index)
|
|
|
_dl_dprintf(2, "symbol '%s': ", strtab + symtab[symtab_index].st_name);
|
|
|
-
|
|
|
+
|
|
|
if (res <0)
|
|
|
{
|
|
|
int reloc_type = ELF32_R_TYPE(rpnt->r_info);
|
|
@@ -234,7 +234,7 @@ _dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope,
|
|
|
_dl_dprintf(2, "can't handle reloc type %s\n ", _dl_reltypes(reloc_type));
|
|
|
#else
|
|
|
_dl_dprintf(2, "can't handle reloc type %x\n", reloc_type);
|
|
|
-#endif
|
|
|
+#endif
|
|
|
_dl_exit(-res);
|
|
|
}
|
|
|
else if (res >0)
|
|
@@ -259,7 +259,7 @@ _dl_do_reloc (struct elf_resolve *tpnt,struct dyn_elf *scope,
|
|
|
#if defined (__SUPPORT_LD_DEBUG__)
|
|
|
unsigned long old_val;
|
|
|
#endif
|
|
|
-
|
|
|
+
|
|
|
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);
|
|
@@ -269,7 +269,7 @@ _dl_do_reloc (struct elf_resolve *tpnt,struct dyn_elf *scope,
|
|
|
if (symtab_index) {
|
|
|
|
|
|
|
|
|
- symbol_addr = (unsigned long) _dl_find_hash(symname, scope,
|
|
|
+ symbol_addr = (unsigned long) _dl_find_hash(symname, scope,
|
|
|
(reloc_type == R_SH_JMP_SLOT ? tpnt : NULL), symbolrel);
|
|
|
|
|
|
|
|
@@ -318,8 +318,8 @@ _dl_do_reloc (struct elf_resolve *tpnt,struct dyn_elf *scope,
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
static int
|
|
|
_dl_do_lazy_reloc (struct elf_resolve *tpnt, struct dyn_elf *scope,
|
|
|
ELF_RELOC *rpnt, Elf32_Sym *symtab, char *strtab)
|
|
@@ -335,7 +335,7 @@ _dl_do_lazy_reloc (struct elf_resolve *tpnt, struct dyn_elf *scope,
|
|
|
|
|
|
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__)
|
|
|
old_val = *reloc_addr;
|
|
|
#endif
|
|
@@ -353,7 +353,7 @@ _dl_do_lazy_reloc (struct elf_resolve *tpnt, struct dyn_elf *scope,
|
|
|
_dl_dprintf(_dl_debug_file, "\tpatched: %x ==> %x @ %x", old_val, *reloc_addr, reloc_addr);
|
|
|
#endif
|
|
|
return 0;
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
@@ -365,7 +365,7 @@ _dl_do_lazy_reloc (struct elf_resolve *tpnt, struct dyn_elf *scope,
|
|
|
|
|
|
at all */
|
|
|
static int
|
|
|
-_dl_do_copy (struct elf_resolve *tpnt, struct dyn_elf *scope,
|
|
|
+_dl_do_copy_reloc (struct elf_resolve *tpnt, struct dyn_elf *scope,
|
|
|
ELF_RELOC *rpnt, Elf32_Sym *symtab, char *strtab)
|
|
|
{
|
|
|
int reloc_type;
|
|
@@ -374,15 +374,15 @@ _dl_do_copy (struct elf_resolve *tpnt, struct dyn_elf *scope,
|
|
|
unsigned long symbol_addr;
|
|
|
int goof = 0;
|
|
|
char*symname;
|
|
|
-
|
|
|
+
|
|
|
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)
|
|
|
+ if (reloc_type != R_SH_COPY)
|
|
|
return 0;
|
|
|
symtab_index = ELF32_R_SYM(rpnt->r_info);
|
|
|
symbol_addr = 0;
|
|
|
symname = strtab + symtab[symtab_index].st_name;
|
|
|
-
|
|
|
+
|
|
|
if (symtab_index) {
|
|
|
|
|
|
symbol_addr = (unsigned long) _dl_find_hash(symname, scope, NULL, copyrel);
|
|
@@ -395,7 +395,7 @@ _dl_do_copy (struct elf_resolve *tpnt, struct dyn_elf *scope,
|
|
|
symname, symtab[symtab_index].st_size,
|
|
|
symbol_addr, symtab[symtab_index].st_value);
|
|
|
#endif
|
|
|
- _dl_memcpy((char *) symtab[symtab_index].st_value,
|
|
|
+ _dl_memcpy((char *) symtab[symtab_index].st_value,
|
|
|
(char *) symbol_addr, symtab[symtab_index].st_size);
|
|
|
}
|
|
|
|
|
@@ -403,25 +403,21 @@ _dl_do_copy (struct elf_resolve *tpnt, struct dyn_elf *scope,
|
|
|
}
|
|
|
|
|
|
|
|
|
-void _dl_parse_lazy_relocation_information(struct elf_resolve *tpnt,
|
|
|
+void _dl_parse_lazy_relocation_information(struct dyn_elf *rpnt,
|
|
|
unsigned long rel_addr, unsigned long rel_size, int type)
|
|
|
{
|
|
|
- (void) type;
|
|
|
- (void)_dl_parse(tpnt, NULL, rel_addr, rel_size, _dl_do_lazy_reloc);
|
|
|
+ (void)_dl_parse(rpnt->dyn, NULL, rel_addr, rel_size, _dl_do_lazy_reloc);
|
|
|
}
|
|
|
|
|
|
-int _dl_parse_relocation_information(struct elf_resolve *tpnt,
|
|
|
+int _dl_parse_relocation_information(struct dyn_elf *rpnt,
|
|
|
unsigned long rel_addr, unsigned long rel_size, int type)
|
|
|
{
|
|
|
- (void) type;
|
|
|
- return _dl_parse(tpnt, tpnt->symbol_scope, rel_addr, rel_size, _dl_do_reloc);
|
|
|
+ return _dl_parse(rpnt->dyn, rpnt->dyn->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)
|
|
|
+int _dl_parse_copy_information(struct dyn_elf *rpnt,
|
|
|
+ unsigned long rel_addr, unsigned long rel_size, int type)
|
|
|
{
|
|
|
- (void) type;
|
|
|
- return _dl_parse(xpnt->dyn, xpnt->next, rel_addr, rel_size, _dl_do_copy);
|
|
|
+ return _dl_parse(rpnt->dyn, rpnt->next, rel_addr, rel_size, _dl_do_copy_reloc);
|
|
|
}
|
|
|
|
|
|
-
|