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

Matthew Gretton-Dann matthew.gretton-dann@arm.com
Thu Jan 14 14:01:00 GMT 2010


Hi,

Please can someone review, approve, and commit the attached patch?

This patch fixes a bug in ld where it incorrectly reports 'relocation
truncated to fit: R_ARM_THM_JUMP24 ...' for certain relocation addends.

The following test case demonstrates the bug:

testcase.s:
	.text
	.syntax unified
	.thumb_func
	.global _start
	.type _start,%function
_start:
	b.w dest

	.section destsect, "x"
	.thumb_func
dest:
	b dest

To demonstrate:

arm-none-linux-gnueabi-as -march=armv7-a -mthumb \
	testcase.s -o testcase.o
arm-none-linux-gnueabi-ld -defsym _start=0x8000 \
	--section-start destsect=0x00900000 \
        testcase.o -o testcase

Output:

testcase.o: In function `_start':
(.text+0x0): relocation truncated to fit: R_ARM_THM_JUMP24 against
`dest'

This should never occur.  Either the calculated branch offset for the
relocation should fit or ld should have created a veneer within range
and relocated to that.

In this particular case the branch is actually in range (and so no
veneer is needed), but the elf32_arm_howto_table_1 in bfd/elf32-arm.c
contains an incorrect value for the number of bits to be relocated (24
instead of 25).  The fix is to just update the table.

The ChangeLog entries are as follows:

bfd/ChangeLog:

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

	* elf32-arm.c (elf32_arm_howto_table_1): Correct bitsize of
	R_ARM_THM_JUMP24 entry.

ld/testsuite/ChangeLog:

2010-01-14  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.patch
Type: text/x-patch
Size: 4247 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20100114/efcbb1fe/attachment.bin>


More information about the Binutils mailing list