Module Name:    src
Committed By:   jdc
Date:           Wed Aug  8 06:24:51 UTC 2012

Modified Files:
        src/libexec/ld.elf_so [netbsd-6]: headers.c
        src/libexec/ld.elf_so/arch/sparc64 [netbsd-6]: mdreloc.c

Log Message:
Pull up revisions:
  src/libexec/ld.elf_so/headers.c revision 1.42
  src/libexec/ld.elf_so/arch/sparc64/mdreloc.c revision 1.53
(requested by martin in ticket #447).

Remove a debug assert that does not hold for PIE (e.g. phdr = 0x40, but
obj has not been mapped at 0, so obj->phdr is 0x100040).
OK: skrll

Add special handling needed for OLO10 relocations.
First part of fixing PR port-sparc64/46724.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.41.4.1 src/libexec/ld.elf_so/headers.c
cvs rdiff -u -r1.52 -r1.52.6.1 src/libexec/ld.elf_so/arch/sparc64/mdreloc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/libexec/ld.elf_so/headers.c
diff -u src/libexec/ld.elf_so/headers.c:1.41 src/libexec/ld.elf_so/headers.c:1.41.4.1
--- src/libexec/ld.elf_so/headers.c:1.41	Sat Jun 25 05:45:12 2011
+++ src/libexec/ld.elf_so/headers.c	Wed Aug  8 06:24:51 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: headers.c,v 1.41 2011/06/25 05:45:12 nonaka Exp $	 */
+/*	$NetBSD: headers.c,v 1.41.4.1 2012/08/08 06:24:51 jdc Exp $	 */
 
 /*
  * Copyright 1996 John D. Polstra.
@@ -40,7 +40,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: headers.c,v 1.41 2011/06/25 05:45:12 nonaka Exp $");
+__RCSID("$NetBSD: headers.c,v 1.41.4.1 2012/08/08 06:24:51 jdc Exp $");
 #endif /* not lint */
 
 #include <err.h>
@@ -356,7 +356,6 @@ _rtld_digest_phdr(const Elf_Phdr *phdr, 
 		    obj->phsize, (long)obj->relocbase));
 		break;
 	}
-	assert(obj->phdr == phdr);
 	
 	for (ph = phdr; ph < phlimit; ++ph) {
 		vaddr = (Elf_Addr)(uintptr_t)(obj->relocbase + ph->p_vaddr);

Index: src/libexec/ld.elf_so/arch/sparc64/mdreloc.c
diff -u src/libexec/ld.elf_so/arch/sparc64/mdreloc.c:1.52 src/libexec/ld.elf_so/arch/sparc64/mdreloc.c:1.52.6.1
--- src/libexec/ld.elf_so/arch/sparc64/mdreloc.c:1.52	Wed Mar 30 08:37:52 2011
+++ src/libexec/ld.elf_so/arch/sparc64/mdreloc.c	Wed Aug  8 06:24:51 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: mdreloc.c,v 1.52 2011/03/30 08:37:52 martin Exp $	*/
+/*	$NetBSD: mdreloc.c,v 1.52.6.1 2012/08/08 06:24:51 jdc Exp $	*/
 
 /*-
  * Copyright (c) 2000 Eduardo Horvath.
@@ -32,7 +32,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: mdreloc.c,v 1.52 2011/03/30 08:37:52 martin Exp $");
+__RCSID("$NetBSD: mdreloc.c,v 1.52.6.1 2012/08/08 06:24:51 jdc Exp $");
 #endif /* not lint */
 
 #include <errno.h>
@@ -323,6 +323,10 @@ _rtld_relocate_nonplt_objects(Obj_Entry 
 		if (type == R_TYPE(NONE))
 			continue;
 
+		/* OLO10 relocations have extra info */
+		if ((type & 0x00ff) == R_SPARC_OLO10)
+			type = R_SPARC_OLO10;
+
 		/* We do JMP_SLOTs in _rtld_bind() below */
 		if (type == R_TYPE(JMP_SLOT))
 			continue;
@@ -335,8 +339,10 @@ _rtld_relocate_nonplt_objects(Obj_Entry 
 		 * We use the fact that relocation types are an `enum'
 		 * Note: R_SPARC_TLS_TPOFF64 is currently numerically largest.
 		 */
-		if (type > R_TYPE(TLS_TPOFF64))
-			return (-1);
+		if (type > R_TYPE(TLS_TPOFF64)) {
+			dbg(("unknown relocation type %x at %p", type, rela));
+			return -1;
+		}
 
 		value = rela->r_addend;
 
@@ -422,6 +428,11 @@ _rtld_relocate_nonplt_objects(Obj_Entry 
 			value += (Elf_Addr)(defobj->relocbase + def->st_value);
 		}
 
+		if (type == R_SPARC_OLO10) {
+			value = (value & 0x3ff)
+			    + (((Elf64_Xword)rela->r_info<<32)>>40);
+		}
+
 		if (RELOC_PC_RELATIVE(type)) {
 			value -= (Elf_Addr)where;
 		}

Reply via email to