[patch] R_ARM_REL32 and Thumb functions.

Paul Brook paul@codesourcery.com
Fri Apr 28 19:03:00 GMT 2006


> >      case BFD_RELOC_32_PCREL:
> > +      /* Set the low bit of the value if the target is a thumb function.
> >  */ +      if (fixP->fx_done && fixP->fx_addsy &&
> > THUMB_IS_FUNC(fixP->fx_addsy)) +	value |= 1;
>
> AFAICT, this is close, but not quite what AAELF says.  The relocation
> expression is
>
> 	((S + A) | T) - .
>
> That is, the T bit is orred in before the address of the place is
> subtracted.
>
> Normally, this doesn't change anything since the relocation is used with
> .word which has 4-byte alignment.  However, if a .4byte directive is
> used, then there are no alignment constraints and the order of
> processing becomes significant.

It turns out this code never triggers because we force an external relocation. 
However the bfd code to process R_ARM_REL32 has a similar bug.

Updated patch attached.
Tested with cross to arm-none-eabi.
Ok?

Paul

2006-04-28  Paul Brook  <paul@codesourcery.com>

bfd/
	* elf32-arm.c (elf32_arm_final_link_relocate): Set Thumb function bit
	for R_ARM_REL32.
gas/
	* config/tc-arm.c (arm_optimize_expr): New function.
	* config/tc-arm.h (md_optimize_expr): Define
	(arm_optimize_expr): Add prototype.
	(TC_FORCE_RELOCATION_SUB_SAME): Define.
ld/testsuite/
	* ld-arm/arm-elf.exp: Add thumb-rel32.
	* ld-arm/thumb-rel32.d: New test.
	* ld-arm/thumb-rel32.s: New test.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.rel32
Type: text/x-diff
Size: 4735 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20060428/13f65ac9/attachment.bin>


More information about the Binutils mailing list