PATCH for Re: binutils 2.15 / gcc-3.3.5 (3.4.3) produce text relocations on arm

Daniel Jacobowitz drow@false.org
Fri Mar 18 23:52:00 GMT 2005


On Mon, Mar 14, 2005 at 12:44:39PM +0100, Peter S. Mazinger wrote:
> On Wed, 5 Jan 2005, Peter S. Mazinger wrote:
> 
> > On Tue, 4 Jan 2005, Daniel Jacobowitz wrote:
> > > Then could you check whether any of the relocations are actually in the
> > > text segment?
> > 
> > How to do that?

Via readelf.  readelf -l will show you the offsets and sizes of the
segments.  readelf -Dr will show you the offsets of relocation entries. 
Are any in the text segment?

> > 
> > Could you provide me a patch for the ARM bug you have found (setting 
> > DT_TEXTREL incorrectly)?

Attached.

This is patch 2/2 for today's duplicated-code-in-BFD hatred series.  I
tried to resync with other ports' copies of this code and it proved
surprisingly twisty, so I took the simple way out.  We were creating
reloc_copied structures with ->count = 0, which are useless and messed
up the counting algorithm.

Tested arm-linux, binutils and glibc testsuites.  Richard or Nick, is
this patch OK?

> Nothing changed in the meantime ;-(
> I have tested binutils-cvs (as of 20050222) and no better.
> 
> Finally it seems that the DT_TEXTREL entry is coming from assembler 
> sources, C code seems to be linked correctly.

Your assembly sources may be broken (non-PIC) then.

> on another note:
> MAXPAGESIZE=0x8000 (as of bfd/elf.c) for arm, please change that in 
> ld/emulparams/armelf.sh.

Nathan noticed the odd MAXPAGESIZE setting in arm-elf today also.  I
don't know the history.

-- 
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