Fix arm-pe reloc generations for redefined symbols

Richard Earnshaw rearnsha@arm.com
Tue May 9 14:44:00 GMT 2006


On Tue, 2006-05-09 at 12:46, Nick Clifton wrote:
> Hi Guys,
> 
>   Whilst checking my arm-wince-pe toolchain in order to review the
>   recent patch submissions I found that the redef2.s test was causing
>   the assembler to abort().  Upon investigation I found that the
>   problem was that a reloc was being generated against a symbol which
>   had been cloned, and only the clone was placed into the symbol
>   table, not the original.
> 
>   I am going to apply the attached patch to fix this problem.  The
>   patch tells the assembler to adjust an fixups against symbols which
>   are not on the symbol chain (and which will not therefore be put
>   into the symbol table).
> 
> Cheers
>   Nick
> 
> gas/ChangeLog
> 2006-05-09  Nick Clifton  <nickc@redhat.com>
> 
> 	* config/tc-arm.c (arm_fix_adjustable): For COFF, convert fixups
> 	against symbols which are not going to be placed into the symbol
> 	table.
> 
> bfd/ChangeLog
> 2006-05-09  Nick Clifton  <nickc@redhat.com>
> 
> 	* coffcode.h (coff_write_relocs): Produce an error message if a an
> 	out-of-range symbol index is detected in a reloc.
> 
> 
> ______________________________________________________________________
> Index: gas/config/tc-arm.c
> ===================================================================
> RCS file: /cvs/src/src/gas/config/tc-arm.c,v
> retrieving revision 1.265
> diff -c -3 -p -r1.265 tc-arm.c
> *** gas/config/tc-arm.c	5 May 2006 18:54:44 -0000	1.265
> --- gas/config/tc-arm.c	9 May 2006 11:44:57 -0000
> + 
> +   /* This is a hack for the gas/all/redef2.s test.  This test causes symbols
> +      to be cloned, and without this test relocs would still be generated
> +      against the original pre-cloned symbol.  Such symbols would not appear
> +      in the symbol table however, and so a valid reloc could not be
> +      generated.  So check to see if the fixup is against a symbol which has
> +      been removed from the symbol chain, and if it is, then allow it to be
> +      adjusted into a reloc against a section symbol. */
> +   if (fixP->fx_addsy != NULL)
> +     {
> +       symbolS * sym;
> + 
> +       for (sym = symbol_rootP; sym != NULL; sym = symbol_next (sym))
> + 	if (sym == fixP->fx_addsy)
> + 	  break;
> +       if (sym == NULL)
> + 	return 1;
> +     }
> +   
>     return 0;
>   }
>   #endif
> 
> ______________________________________________________________________

Surely there's a better way of doing this.  This test is O(S*F) which is
really going to slow up assembly on large files, for a nasty corner
case.

R.



More information about the Binutils mailing list