Spurious R_386_NONE relocations

Jeff Baker jbaker@qnx.com
Wed Aug 25 15:02:00 GMT 2004


I'm going to have to ammend my previous statement.  I'm not quite sure 
what went on with the testing of this patch yesterday, but today I can't 
produce a working shared object anymore.

This patch causes the appropriate data to be nulled, but many NONE 
relocations are still produced.  Using a loader set to ignore NONE 
relocations causes the program to SEGV calling the global constructor 
for the class contained in the shared object.

Alan Modra wrote:
> On Tue, Aug 24, 2004 at 10:50:54AM -0400, Jeff Baker wrote:
> 
>>>OK, this one isn't a linker over-allocation problem, but rather a
> 
> lack
> 
>>>of edit facility for 2.95.x exception handling info.  I attached a
> 
> patch
> 
>>>to http://sources.redhat.com/bugzilla/show_bug.cgi?id=343 that may
> 
> fix
> 
>>>your runtime problem.
>>
>>That patch seems to do the trick.  Thanks a lot for your help.
> 
> 
> Applying.
> 
> bfd/ChangeLog
> 	* elf32-i386.c (elf_i386_relocate_section): Zero section
> contents
> 	for R_386_32 and R_386_PC32 relocs against symbols defined in
> 	discarded sections.
> 
> Index: bfd/elf32-i386.c
> ===================================================================
> RCS file: /cvs/src/src/bfd/elf32-i386.c,v
> retrieving revision 1.125
> diff -u -p -r1.125 elf32-i386.c
> --- bfd/elf32-i386.c	13 Aug 2004 03:15:57 -0000	1.125
> +++ bfd/elf32-i386.c	25 Aug 2004 14:08:20 -0000
> @@ -2319,8 +2319,19 @@ elf_i386_relocate_section (bfd *output_b
>  	  /* r_symndx will be zero only for relocs against symbols
>  	     from removed linkonce sections, or sections discarded by
>  	     a linker script.  */
> -	  if (r_symndx == 0
> -	      || (input_section->flags & SEC_ALLOC) == 0)
> +	  if (r_symndx == 0)
> +	    {
> +	      /* Zero the section contents.  eh_frame generated by old
> +		 versions of gcc isn't edited by elf-eh-frame.c, so
> +		 FDEs for discarded linkonce functions might remain.
> +		 Putting zeros here will zero such FDE's address range.
> +		 This is a hint to unwinders and other consumers of
> +		 exception handling info that the FDE is invalid.  */
> +	      bfd_put_32 (input_bfd, 0, contents + rel->r_offset);
> +	      continue;
> +	    }
> +
> +	  if ((input_section->flags & SEC_ALLOC) == 0)
>  	    break;
>  
>  	  if ((info->shared
> 



More information about the Binutils mailing list