Subject: -current MIPS ld.elf_so fix/workaround
To: None <,>
From: Rafal Boni <>
List: tech-toolchain
Date: 04/12/2003 18:10:55
	I haven't had a chance to figure out if this is quite the right
	thing or not -- at least from the POV of the specified behaviour,
	but the following small patch makes my ld.elf_so behave correctly
	in the face of the application overriding symbols from shared libs,
	as is done in at least the following places:
		* perl (used during build, the broken ld.elf_so caused the
		  perl build to fall over).
		* bash/tcsh (both define their own free/malloc -- with the
		  -current ld.elf_so, parts of the app use the app-defined
		  malloc/free while other parts use the libc free).

	I'll try and figure out what the right things from a spec POV are
	soon, but at least this gets me up and running (which is the key
	things for me now 8-) again.

	This addresses a bunch of PR's in GNATS as well, so if someone 
	wants to pick this up ASAP, verify that this is indeed correct,
	check it in and close those PR's, I won't complain... I will try
	and get to all that, but probably not in the next week or ten

	BTW, this is on a system post-binutils- update and with
	the stock 2.59.3 gcc.


Index: arch/mips/mips_reloc.c
RCS file: /cvsroot/src/libexec/ld.elf_so/arch/mips/mips_reloc.c,v
retrieving revision 1.37
diff -b -u -r1.37 mips_reloc.c
--- arch/mips/mips_reloc.c	2002/10/05 11:59:05	1.37
+++ arch/mips/mips_reloc.c	2003/04/12 21:44:36
@@ -183,7 +183,7 @@
 		if (ELF_ST_TYPE(sym->st_info) == STT_FUNC &&
-		    broken && sym->st_shndx == SHN_UNDEF) {
+		    sym->st_shndx == SHN_UNDEF) {
 			 * You might think this is stupid, as it intentionally
@@ -202,14 +202,18 @@
 			*got = def->st_value + (Elf_Addr)defobj->relocbase;
 		} else
 		if (ELF_ST_TYPE(sym->st_info) == STT_FUNC &&
-		    sym->st_value != 0) {
+		    *got != sym->st_value) {
 			 * If there are non-PLT references to the function,
 			 * st_value should be 0, forcing us to resolve the
 			 * address immediately.
+			 * 
+			 * XXXrkb: this can't be right?!?
-			*got = sym->st_value + (Elf_Addr)obj->relocbase;
+			*got += (Elf_Addr)obj->relocbase;
 		} else if (sym->st_info == ELF_ST_INFO(STB_GLOBAL, STT_SECTION)) {
 			/* Symbols with index SHN_ABS are not relocated. */
 			if (sym->st_shndx != SHN_ABS)

Rafal Boni                                           
  We are all worms.  But I do believe I am a glowworm.  -- Winston Churchill