summaryrefslogtreecommitdiff
path: root/ldso
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2003-06-27 11:03:37 +0000
committerEric Andersen <andersen@codepoet.org>2003-06-27 11:03:37 +0000
commit5e143e6c4e7c15b26ecaad21fb61f2e2e2bf6942 (patch)
treecea31bcee27e3e6bf083defa15f1e6e3fccbbaff /ldso
parent017c8132edae466e2892faec7ef6b834dfecbd34 (diff)
whitespace and debug updates
Diffstat (limited to 'ldso')
-rw-r--r--ldso/ldso/i386/elfinterp.c88
1 files changed, 46 insertions, 42 deletions
diff --git a/ldso/ldso/i386/elfinterp.c b/ldso/ldso/i386/elfinterp.c
index 4ee2be82f..7538a6480 100644
--- a/ldso/ldso/i386/elfinterp.c
+++ b/ldso/ldso/i386/elfinterp.c
@@ -43,7 +43,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));
@@ -57,7 +57,7 @@ void debug_sym(Elf32_Sym *symtab,char *strtab,int symtab_index)
if(_dl_debug_symbols)
{
if(symtab_index){
- _dl_dprintf(_dl_debug_file, "\n%s\tvalue=%x\tsize=%x\tinfo=%x\tother=%x\tshndx=%x",
+ _dl_dprintf(_dl_debug_file, "\n%s\n\tvalue=%x\tsize=%x\tinfo=%x\tother=%x\tshndx=%x",
strtab + symtab[symtab_index].st_name,
symtab[symtab_index].st_value,
symtab[symtab_index].st_size,
@@ -77,17 +77,19 @@ static void debug_reloc(Elf32_Sym *symtab,char *strtab, ELF_RELOC *rpnt)
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, "\n%s\toffset=%x\taddend=%x %s",
+ _dl_dprintf(_dl_debug_file, "%s\toffset=%x\taddend=%x",
_dl_reltypes(ELF32_R_TYPE(rpnt->r_info)),
rpnt->r_offset,
- rpnt->r_addend,
- sym);
+ rpnt->r_addend);
#else
- _dl_dprintf(_dl_debug_file, "\n%s\toffset=%x %s",
+ _dl_dprintf(_dl_debug_file, "%s\toffset=%x",
_dl_reltypes(ELF32_R_TYPE(rpnt->r_info)),
- rpnt->r_offset,
- sym);
+ rpnt->r_offset);
#endif
}
}
@@ -112,31 +114,30 @@ unsigned long _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry)
ELF_RELOC *this_reloc;
char *strtab;
Elf32_Sym *symtab;
- ELF_RELOC *rel_addr;
int symtab_index;
+ char *rel_addr;
char *new_addr;
char **got_addr;
unsigned long instr_addr;
- rel_addr = (ELF_RELOC *) (tpnt->dynamic_info[DT_JMPREL] + tpnt->loadaddr);
+ rel_addr = (char *) (tpnt->dynamic_info[DT_JMPREL] + tpnt->loadaddr);
- this_reloc = rel_addr + (reloc_entry >> 3);
+ 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_386_JMP_SLOT) {
_dl_dprintf(2, "%s: Incorrect relocation type in jump relocations\n",
- _dl_progname);
+ _dl_progname);
_dl_exit(1);
- };
+ }
/* Address of jump instruction to fix up */
instr_addr = ((unsigned long) this_reloc->r_offset +
- (unsigned long) tpnt->loadaddr);
+ (unsigned long) tpnt->loadaddr);
got_addr = (char **) instr_addr;
/* Get the address of the GOT entry */
@@ -146,7 +147,7 @@ unsigned long _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry)
_dl_dprintf(2, "%s: can't resolve symbol '%s'\n",
_dl_progname, strtab + symtab[symtab_index].st_name);
_dl_exit(1);
- };
+ }
#if defined (__SUPPORT_LD_DEBUG__)
if ((unsigned long) got_addr < 0x40000000)
@@ -156,7 +157,7 @@ unsigned long _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry)
_dl_dprintf(_dl_debug_file, "\nresolve function: %s",
strtab + symtab[symtab_index].st_name);
if(_dl_debug_detail) _dl_dprintf(_dl_debug_file,
- "\tpatch %x ==> %x @ %x", *got_addr, new_addr, got_addr);
+ "\n\tpatch %x ==> %x @ %x\n", *got_addr, new_addr, got_addr);
}
}
if (!_dl_debug_nofixups) {
@@ -175,18 +176,18 @@ _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;
ELF_RELOC *rpnt;
int symtab_index;
- /* Now parse the relocation information */
- rpnt = (ELF_RELOC *) (rel_addr + tpnt->loadaddr);
+ /* Now parse the relocation information */
+ 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++) {
@@ -229,12 +230,13 @@ _dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope,
else if (res >0)
{
_dl_dprintf(2, "can't resolve symbol\n");
- goof += res;
+ //goof += res;
}
}
return goof;
}
+
static int
_dl_do_reloc (struct elf_resolve *tpnt,struct dyn_elf *scope,
ELF_RELOC *rpnt, Elf32_Sym *symtab, char *strtab)
@@ -245,10 +247,10 @@ _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_type = ELF32_R_TYPE(rpnt->r_info);
+ 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;
+ symbol_addr = 0;
if (symtab_index) {
@@ -260,7 +262,12 @@ _dl_do_reloc (struct elf_resolve *tpnt,struct dyn_elf *scope,
* have been intentional. We should not be linking local symbols
* here, so all bases should be covered.
*/
+
if (!symbol_addr && ELF32_ST_BIND(symtab[symtab_index].st_info) == STB_GLOBAL) {
+#if defined (__SUPPORT_LD_DEBUG__)
+ _dl_dprintf(2, "library '%s': NOT resolving global symbol '%s'\n",
+ tpnt->libname, strtab + symtab[symtab_index].st_name);
+#endif
goof++;
}
}
@@ -286,16 +293,8 @@ _dl_do_reloc (struct elf_resolve *tpnt,struct dyn_elf *scope,
*reloc_addr += (unsigned long) tpnt->loadaddr;
break;
case R_386_COPY:
-#if 0
- /* Do this later */
- _dl_dprintf(2, "Doing copy for symbol ");
- if (symtab_index) _dl_dprintf(2, strtab + symtab[symtab_index].st_name);
- _dl_dprintf(2, "\n");
- _dl_memcpy((void *) symtab[symtab_index].st_value,
- (void *) symbol_addr, symtab[symtab_index].st_size);
-#endif
+ /* handled later on */
break;
-
default:
return -1; /*call _dl_exit(1) */
}
@@ -315,8 +314,11 @@ _dl_do_lazy_reloc (struct elf_resolve *tpnt, struct dyn_elf *scope,
{
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__)
@@ -329,7 +331,6 @@ _dl_do_lazy_reloc (struct elf_resolve *tpnt, struct dyn_elf *scope,
case R_386_JMP_SLOT:
*reloc_addr += (unsigned long) tpnt->loadaddr;
break;
-
default:
return -1; /*call _dl_exit(1) */
}
@@ -355,13 +356,13 @@ static int
_dl_do_copy (struct elf_resolve *tpnt, struct dyn_elf *scope,
ELF_RELOC *rpnt, Elf32_Sym *symtab, char *strtab)
{
- int reloc_type;
+ int reloc_type;
int symtab_index;
unsigned long *reloc_addr;
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_386_COPY)
return 0;
@@ -393,18 +394,21 @@ _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);
}