[uClibc-cvs] uClibc/ldso/ldso/i386 dl-sysdep.h, 1.9, 1.10 elfinterp.c, 1.29, 1.30

Erik Andersen andersen at uclibc.org
Sat Feb 14 11:30:35 UTC 2004


Update of /var/cvs/uClibc/ldso/ldso/i386
In directory nail:/tmp/cvs-serv9702/ldso/i386

Modified Files:
	dl-sysdep.h elfinterp.c 
Log Message:
Joakim Tjernlund writes:

Hi it is me again.

This is the latest ldso patch. the NEW weak symbol handling works now
with a little special handling in _dl_find_hash(). You get to chose
if you want the new or old handling :)

There was 2 missing _dl_check_if_named_library_is_loaded() calls in _dlopen().

I then disabled the _dl_check_if_named_library_is_loaded() in dl-elf.c since
it is rendundant.

Question, why does some _dl_linux_resolver(), like i386, have 2 calls
to _dl_find_hash()? I think that is wrong, isn't it?

I really hope you can check this out soon ...



Index: dl-sysdep.h
===================================================================
RCS file: /var/cvs/uClibc/ldso/ldso/i386/dl-sysdep.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- dl-sysdep.h	17 Dec 2003 08:05:41 -0000	1.9
+++ dl-sysdep.h	14 Feb 2004 11:30:32 -0000	1.10
@@ -79,3 +79,12 @@
 #define PAGE_ALIGN 0xfffff000
 #define ADDR_ALIGN 0xfff
 #define OFFS_ALIGN 0x7ffff000
+
+/* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry or
+   TLS variable, so undefined references should not be allowed to
+   define the value.
+   ELF_RTYPE_CLASS_NOCOPY iff TYPE should not be allowed to resolve to one
+   of the main executable's symbols, as for a COPY reloc.  */
+#define elf_machine_type_class(type) \
+  ((((type) == R_386_JMP_SLOT) * ELF_RTYPE_CLASS_PLT)			      \
+   | (((type) == R_386_COPY) * ELF_RTYPE_CLASS_COPY))

Index: elfinterp.c
===================================================================
RCS file: /var/cvs/uClibc/ldso/ldso/i386/elfinterp.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- elfinterp.c	7 Feb 2004 10:40:16 -0000	1.29
+++ elfinterp.c	14 Feb 2004 11:30:32 -0000	1.30
@@ -133,7 +133,7 @@
 	strtab = (char *) (tpnt->dynamic_info[DT_STRTAB] + tpnt->loadaddr);
 	symname= strtab + symtab[symtab_index].st_name;
 
-	if (reloc_type != R_386_JMP_SLOT) {
+	if (unlikely(reloc_type != R_386_JMP_SLOT)) {
 		_dl_dprintf(2, "%s: Incorrect relocation type in jump relocations\n",
 				_dl_progname);
 		_dl_exit(1);
@@ -145,15 +145,11 @@
 	got_addr = (char **) instr_addr;
 
 	/* Get the address of the GOT entry */
-	new_addr = _dl_find_hash(symname, tpnt->symbol_scope, tpnt, resolver);
-	if (!new_addr) {
-		new_addr = _dl_find_hash(symname, NULL, NULL, resolver);
-		if (new_addr) {
-			return (unsigned long) new_addr;
-		}
+	new_addr = _dl_find_hash(symname, tpnt->symbol_scope, ELF_RTYPE_CLASS_PLT);
+	if (unlikely(!new_addr)) {
 		_dl_dprintf(2, "%s: can't resolve symbol '%s'\n", _dl_progname, symname);
 		_dl_exit(1);
-	}
+	};
 
 #if defined (__SUPPORT_LD_DEBUG__)
 	if ((unsigned long) got_addr < 0x40000000)
@@ -263,7 +259,7 @@
 	if (symtab_index) {
 
 		symbol_addr = (unsigned long) _dl_find_hash(symname, scope,
-				(reloc_type == R_386_JMP_SLOT ? tpnt : NULL), symbolrel);
+							    elf_machine_type_class(reloc_type));
 
 		/*
 		 * We want to allow undefined references to weak symbols - this might
@@ -377,7 +373,7 @@
 	symname      = strtab + symtab[symtab_index].st_name;
 
 	if (symtab_index) {
-		symbol_addr = (unsigned long) _dl_find_hash(symname, scope, NULL, copyrel);
+		symbol_addr = (unsigned long) _dl_find_hash(symname, scope, ELF_RTYPE_CLASS_COPY);
 		if (!symbol_addr) goof++;
 	}
 	if (!goof) {




More information about the uClibc-cvs mailing list