[uClibc-cvs] uClibc/ldso/ldso/powerpc dl-sysdep.h, 1.9, 1.10 elfinterp.c, 1.36, 1.37

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


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

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/powerpc/dl-sysdep.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- dl-sysdep.h	29 Jan 2004 08:20:11 -0000	1.9
+++ dl-sysdep.h	14 Feb 2004 11:30:34 -0000	1.10
@@ -125,3 +125,16 @@
 #define PAGE_ALIGN 0xfffff000
 #define ADDR_ALIGN 0xfff
 #define OFFS_ALIGN 0x7ffff000
+
+/* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry, so
+   PLT entries 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.  */
+/* We never want to use a PLT entry as the destination of a
+   reloc, when what is being relocated is a branch. This is
+   partly for efficiency, but mostly so we avoid loops.  */
+#define elf_machine_type_class(type) \
+  ((((type) == R_PPC_JMP_SLOT				\
+    || (type) == R_PPC_REL24				\
+    || (type) == R_PPC_ADDR24) * ELF_RTYPE_CLASS_PLT)	\
+   | (((type) == R_PPC_COPY) * ELF_RTYPE_CLASS_COPY))

Index: elfinterp.c
===================================================================
RCS file: /var/cvs/uClibc/ldso/ldso/powerpc/elfinterp.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- elfinterp.c	31 Jan 2004 03:15:07 -0000	1.36
+++ elfinterp.c	14 Feb 2004 11:30:34 -0000	1.37
@@ -209,8 +209,8 @@
 #endif
 
 	/* Get the address of the GOT entry */
-	finaladdr = (Elf32_Addr) _dl_find_hash(strtab + symtab[symtab_index].st_name,
-						tpnt->symbol_scope, tpnt, resolver);
+	finaladdr = (Elf32_Addr) _dl_find_hash(symname,
+			tpnt->symbol_scope, ELF_RTYPE_CLASS_PLT);
 	if (!finaladdr) {
 		_dl_dprintf(2, "%s: can't resolve symbol '%s'\n", _dl_progname, symname);
 		_dl_exit(1);
@@ -223,11 +223,8 @@
 	delta = finaladdr - (Elf32_Word)reloc_addr;
 	if (delta<<6>>6 == delta) {
 		*reloc_addr = OPCODE_B(delta);
-#if 0
-	/* this will almost never be true */
-	} else if (finaladdr <= 0x01fffffc || finaladdr >= 0xfe000000) {
+	} else if (finaladdr <= 0x01fffffc) {
 		*reloc_addr = OPCODE_BA (finaladdr);
-#endif
 	} else {
 		/* Warning: we don't handle double-sized PLT entries */
 		Elf32_Word *plt, *data_words, index, offset;
@@ -261,7 +258,6 @@
 	char *symname;
 	Elf32_Addr *reloc_addr;
 	Elf32_Addr finaladdr;
-	struct dyn_elf *sym_scope;
 
 	unsigned long symbol_addr;
 #if defined (__SUPPORT_LD_DEBUG__)
@@ -278,19 +274,8 @@
 	symtab_index = ELF32_R_SYM(rpnt->r_info);
 	symname      = strtab + symtab[symtab_index].st_name;
 
-#if 1
-	sym_scope = scope->dyn->symbol_scope;
-#else
-	/* Funny, this works too and appears to be much faster. */
-	sym_scope = scope;
-#endif
-	if (reloc_type == R_PPC_COPY) {
-		sym_scope = scope->next;
-		tpnt = NULL; /* To be or not to be ...*/
-	}
-	symbol_addr = (unsigned long) _dl_find_hash(symname, sym_scope,
-						    (reloc_type == R_PPC_JMP_SLOT ? tpnt : NULL),
-						    (reloc_type == R_PPC_COPY ? copyrel : symbolrel));
+	symbol_addr = (unsigned long) _dl_find_hash(symname, scope->dyn->symbol_scope,
+						    elf_machine_type_class(reloc_type));
 	/*
 	 * We want to allow undefined references to weak symbols - this might
 	 * have been intentional.  We should not be linking local symbols
@@ -320,11 +305,8 @@
 
 		if (delta<<6>>6 == delta) {
 			*reloc_addr = OPCODE_B(delta);
-#if 0
-		/* this will almost never be true */
-		} else if (finaladdr <= 0x01fffffc || finaladdr >= 0xfe000000) {
+		} else if (finaladdr <= 0x01fffffc) {
 			*reloc_addr = OPCODE_BA (finaladdr);
-#endif
 		} else {
 			/* Warning: we don't handle double-sized PLT entries */
 			Elf32_Word *plt, *data_words, index, offset;
@@ -384,7 +366,7 @@
 		_dl_dprintf(2, "%s ", _dl_reltypes(reloc_type));
 #endif
 		if (symtab_index)
-			_dl_dprintf(2, "'%s'\n", strtab + symtab[symtab_index].st_name);
+			_dl_dprintf(2, "'%s'\n", symname);
 		return -1;
 	};
 




More information about the uClibc-cvs mailing list