ARM: Fix DT_TEXTREL generation

Daniel Jacobowitz drow@false.org
Sat Mar 26 00:35:00 GMT 2005


I posted this patch a couple days ago, but at the bottom of a thread ...
tsk tsk.

This patch prevents the incorrect generation of a DT_TEXTREL tag in ARM
shared libraries.  The problem was that p->count was correctly updated,
but we would sometimes create new relocs_copied entries with a zero count;
and when checking for text relocations, we don't look at the count, just
whether the pointer is non-NULL.  The cleanest fix is to avoid creating a
new relocs_copied structure if we aren't going to increment it.

OK for HEAD?  Any objection to fixing this on 2.16 also?

-- 
Daniel Jacobowitz
CodeSourcery, LLC

2005-03-18  Daniel Jacobowitz  <dan@codesourcery.com>

	* elf32-arm.c (elf32_arm_check_relocs): Increment count for all
	relocation types.  Don't count relocations which will use a PLT.

Index: binutils/bfd/elf32-arm.c
===================================================================
--- binutils.orig/bfd/elf32-arm.c	2005-03-18 13:20:03.152084693 -0500
+++ binutils/bfd/elf32-arm.c	2005-03-18 17:00:25.694851664 -0500
@@ -4093,18 +4093,9 @@ elf32_arm_check_relocs (bfd *abfd, struc
                relocs_copied field of the hash table entry.  */
 	    if ((info->shared || htab->root.is_relocatable_executable)
 		&& (sec->flags & SEC_ALLOC) != 0
-		&& ((r_type != R_ARM_PC24
-		     && r_type != R_ARM_PLT32
-#ifndef OLD_ARM_ABI
-		     && r_type != R_ARM_CALL
-		     && r_type != R_ARM_JUMP24
-		     && r_type != R_ARM_PREL31
-#endif
-		     && r_type != R_ARM_REL32
-		     && r_type != R_ARM_THM_PC22)
-		    || (h != NULL
-			&& (! info->symbolic
-			    || !h->def_regular))))
+		&& (r_type == R_ARM_ABS32
+		    || (h != NULL && ! h->needs_plt
+			&& (! info->symbolic || ! h->def_regular))))
 	      {
 		struct elf32_arm_relocs_copied *p, **head;
 
@@ -4184,9 +4175,7 @@ elf32_arm_check_relocs (bfd *abfd, struc
 		    p->count = 0;
 		  }
 
-		if (r_type == R_ARM_ABS32
-		    || r_type == R_ARM_REL32)
-		  p->count += 1;
+		p->count += 1;
 	      }
 	    break;
 



More information about the Binutils mailing list