[uClibc-cvs] CVS update of uClibc/ldso/ldso (dl-elf.c powerpc/dl-sysdep.h sparc/dl-sysdep.h)

Erik Andersen andersen at codepoet.org
Fri Aug 6 16:12:12 UTC 2004


    Date: Friday, August 6, 2004 @ 10:12:12
  Author: andersen
    Path: /var/cvs/uClibc/ldso/ldso

Modified: dl-elf.c (1.74 -> 1.75) powerpc/dl-sysdep.h (1.11 -> 1.12)
          sparc/dl-sysdep.h (1.8 -> 1.9)

Joakim Tjernlund writes:

PPC32, SPARC32/64 and S390 includes the PLT in its RELA size. This caused ldso
to always do unlazy relocation of the JMPRELs. This patch fixes it.


Index: uClibc/ldso/ldso/dl-elf.c
diff -u uClibc/ldso/ldso/dl-elf.c:1.74 uClibc/ldso/ldso/dl-elf.c:1.75
--- uClibc/ldso/ldso/dl-elf.c:1.74	Thu Jul 29 21:32:40 2004
+++ uClibc/ldso/ldso/dl-elf.c	Fri Aug  6 10:12:10 2004
@@ -734,6 +734,7 @@
 {
 	int goof = 0;
 	struct elf_resolve *tpnt;
+	unsigned long reloc_size;
 
 	if (rpnt->next)
 		goof += _dl_fixup(rpnt->next, flag);
@@ -754,13 +755,21 @@
 		return goof;
 	}
 
+/* On some machines, notably SPARC & PPC, DT_REL* includes DT_JMPREL in its
+   range.  Note that according to the ELF spec, this is completely legal! */
+#ifdef ELF_MACHINE_PLTREL_OVERLAP
+	reloc_size = tpnt->dynamic_info[DT_RELOC_TABLE_SIZE] - 
+		tpnt->dynamic_info [DT_PLTRELSZ];
+#else
+	reloc_size = tpnt->dynamic_info[DT_RELOC_TABLE_SIZE];
+#endif
 	if (tpnt->dynamic_info[DT_RELOC_TABLE_ADDR]) {
 		if (tpnt->init_flag & RELOCS_DONE)
 			return goof;
 		tpnt->init_flag |= RELOCS_DONE;
 		goof += _dl_parse_relocation_information(rpnt,
 				tpnt->dynamic_info[DT_RELOC_TABLE_ADDR],
-				tpnt->dynamic_info[DT_RELOC_TABLE_SIZE], 0);
+				reloc_size, 0);
 	}
 
 	if (tpnt->dynamic_info[DT_JMPREL]) {
Index: uClibc/ldso/ldso/powerpc/dl-sysdep.h
diff -u uClibc/ldso/ldso/powerpc/dl-sysdep.h:1.11 uClibc/ldso/ldso/powerpc/dl-sysdep.h:1.12
--- uClibc/ldso/ldso/powerpc/dl-sysdep.h:1.11	Tue Feb 17 03:55:56 2004
+++ uClibc/ldso/ldso/powerpc/dl-sysdep.h	Fri Aug  6 10:12:11 2004
@@ -87,3 +87,7 @@
     || (type) == R_PPC_REL24				\
     || (type) == R_PPC_ADDR24) * ELF_RTYPE_CLASS_PLT)	\
    | (((type) == R_PPC_COPY) * ELF_RTYPE_CLASS_COPY))
+
+/* The SVR4 ABI specifies that the JMPREL relocs must be inside the
+   DT_RELA table.  */
+#define ELF_MACHINE_PLTREL_OVERLAP 1
Index: uClibc/ldso/ldso/sparc/dl-sysdep.h
diff -u uClibc/ldso/ldso/sparc/dl-sysdep.h:1.8 uClibc/ldso/ldso/sparc/dl-sysdep.h:1.9
--- uClibc/ldso/ldso/sparc/dl-sysdep.h:1.8	Sat Jun 12 02:38:39 2004
+++ uClibc/ldso/ldso/sparc/dl-sysdep.h	Fri Aug  6 10:12:11 2004
@@ -107,3 +107,6 @@
 #define elf_machine_type_class(type) \
   ((((type) == R_SPARC_JMP_SLOT) * ELF_RTYPE_CLASS_PLT)			      \
    | (((type) == R_SPARC_COPY) * ELF_RTYPE_CLASS_COPY))
+
+/* The SPARC overlaps DT_RELA and DT_PLTREL.  */
+#define ELF_MACHINE_PLTREL_OVERLAP 1



More information about the uClibc-cvs mailing list