[uClibc-cvs] uClibc/ldso/ldso/i386 elfinterp.c,1.21,1.22

Erik Andersen andersen at uclibc.org
Fri Jun 27 11:03:40 UTC 2003


Update of /var/cvs/uClibc/ldso/ldso/i386
In directory winder:/tmp/cvs-serv26413/ldso/i386

Modified Files:
	elfinterp.c 
Log Message:
whitespace and debug updates


Index: elfinterp.c
===================================================================
RCS file: /var/cvs/uClibc/ldso/ldso/i386/elfinterp.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- elfinterp.c	5 Nov 2002 18:21:02 -0000	1.21
+++ elfinterp.c	27 Jun 2003 11:03:37 -0000	1.22
@@ -43,7 +43,7 @@
   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 @@
   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 @@
     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 @@
 	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 @@
 		_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 @@
 			_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 @@
 	  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 @@
 		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 @@
 	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 @@
 		 * 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 @@
 				*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 @@
 {
 	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 @@
 			case R_386_JMP_SLOT:
 				*reloc_addr += (unsigned long) tpnt->loadaddr;
 				break;
-
 			default:
 				return -1; /*call _dl_exit(1) */
 		}
@@ -355,13 +356,13 @@
 _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 @@
 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);
 }
 



More information about the uClibc-cvs mailing list