This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [ARM] Wrong BLX destination
- From: Simon Marchi <simon dot marchi at polymtl dot ca>
- To: Christophe Lyon <christophe dot lyon at linaro dot org>
- Cc: binutils at sourceware dot org
- Date: Wed, 09 Mar 2016 10:35:44 -0500
- Subject: Re: [ARM] Wrong BLX destination
- Authentication-results: sourceware.org; auth=none
- References: <CAKdteOZgr1AmECQO7yoA9=bos9Ea93WO7Do=WkHJq9Xt+xDpsw at mail dot gmail dot com>
On 2016-03-09 03:07, Christophe Lyon wrote:
Hi,
I haven't looked at this for a while, but:
- which relocations are encoded by gas? (objdump -r). I suspect you
have the ARM version of call (as opposed to the thumb one)
Indeed:
00000000 R_ARM_CALL hello1
- I think you have to use the .thumb_func assembly directive right
before helloX definition, and probably give it a function type too
The linker will take care of making the call point to the right
address, provided it has the right relocations.
When adding .thumb_func before the helloX definitions, the branches are
now
8220: eb00013c bl 8718 <__hello1_from_arm>
8224: eb000135 bl 8700 <__hello2_from_arm>
8228: eb000137 bl 870c <__hello3_from_arm>
and this additional code was added somewhere:
00008700 <__hello2_from_arm>:
8700: e59fc000 ldr ip, [pc] ; 8708
<__hello2_from_arm+0x8>
8704: e12fff1c bx ip
8708: 0000827f .word 0x0000827f
0000870c <__hello3_from_arm>:
870c: e59fc000 ldr ip, [pc] ; 8714
<__hello3_from_arm+0x8>
8710: e12fff1c bx ip
8714: 00008281 .word 0x00008281
00008718 <__hello1_from_arm>:
8718: e59fc000 ldr ip, [pc] ; 8720
<__hello1_from_arm+0x8>
871c: e12fff1c bx ip
8720: 0000827d .word 0x0000827d
So while it doesn't simply use BLX with the H bit set, it seems that it
would now work properly with this indirection.
Thanks for the tip!
Simon