[Patch/RFA]: Patch to fix R_ARM_THM_JUMP24 relocation truncated bug

Matthew Gretton-Dann matthew.gretton-dann@arm.com
Mon Jan 18 14:40:00 GMT 2010


On Fri, 2010-01-15 at 11:04 +1030, Alan Modra wrote:
> On Thu, Jan 14, 2010 at 02:01:11PM +0000, Matthew Gretton-Dann wrote:
> >    HOWTO (R_ARM_THM_JUMP24,	/* type */
> >  	 1,			/* rightshift */
> >  	 2,			/* size (0 = byte, 1 = short, 2 = long) */
> > -	 24,			/* bitsize */
> > +	 25,			/* bitsize */
> >  	 TRUE,			/* pc_relative */
> >  	 0,			/* bitpos */
> >  	 complain_overflow_signed,/* complain_on_overflow */
> 
> This is odd.  Normally, bitsize determines the allowed field value
> after the rightshift has been applied.  Hmm, I see elf32-arm.c does
> it's own checking for these relocs and gets it wrong.  It would be
> better to leave bitsize as 24 and remove the right shift on the
> reloc_signed_max calculation.  You'd then need to adjust the
> R_ARM_THM_JUMP24 howto.

Thank you for your comments.  Please find attached an updated patch for
review and further comments.

As well as removing the right shift on the reloc_signed_max calculation
I reviewed the bitsize for the affected relocations - R_ARM_THM_JUMP24,
R_ARM_THM_CALL, R_ARM_THM_XPC22.  This resulted in leaving the bitsize
for R_ARM_THM_JUMP24 and R_ARM_THM_XPC22 alone (at 24 and 22
respectively), whilst the bitsize for R_ARM_THM_CALL is now 24 (instead
of 25).

Suggested new ChangeLog entries look like:

bfd/ChangeLog:

2010-01-18  Matthew Gretton-Dann <matthew.gretton-dann@arm.com>

        * elf32-arm.c (elf32_arm_howto_table_1): Correct bitsize of
        R_ARM_THM_CALL entry.
        (elf32_arm_final_link_relocate): Correct calculation of
        reloc_signed_max when doing a R_ARM_THM_CALL, R_ARM_THM_XPC22,
        or R_ARM_THM_JUMP24 relocation.

ld/testsuite/ChangeLog:

2010-01-18  Matthew Gretton-Dann <matthew.gretton-dann@arm.com>

        * ld-arm/jump-reloc-veneers-long.d: New test.
        * ld-arm/jump-reloc-veneers-short1.d: Likewise.
        * ld-arm/jump-reloc-veneers-short2.d: Likewise.
        * ld-arm/jump-reloc-veneers.s: Likewise.
        * ld-arm/arm-elf.exp (armelftests): Run them.

Thanks,

Matt

-- 
Matthew Gretton-Dann
Principal Engineer - Tools, PD Software
ARM Limited
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 1001-jump-veneers-4.patch
Type: text/x-patch
Size: 4526 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20100118/7566f587/attachment.bin>


More information about the Binutils mailing list