This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: ARM long branch stubs: pic take 2
- From: Richard Earnshaw <rearnsha at arm dot com>
- To: Christophe LYON <christophe dot lyon at st dot com>
- Cc: Binutils <binutils at sourceware dot org>
- Date: Wed, 25 Feb 2009 17:33:25 +0000
- Subject: Re: ARM long branch stubs: pic take 2
- References: <49A561EB.2070809@st.com>
On Wed, 2009-02-25 at 16:21 +0100, Christophe LYON wrote:
> +/* V4T Thumb -> ARM long branch stub, PIC. */
> +static const insn_sequence elf32_arm_stub_long_branch_v4t_thumb_arm_pic[] =
> + {
> + THUMB16_INSN(0x4778), /* bx pc */
> + THUMB16_INSN(0x46c0), /* nop */
> + ARM_INSN(0xe59fc004), /* ldr ip, [pc, #4] */
> + ARM_INSN(0xe08cc00f), /* add ip, ip, pc */
> + ARM_INSN(0xe1a0f00c), /* mov pc, ip */
> + DATA_WORD(0, R_ARM_REL32, 0), /* dcd R_ARM_REL32(X) */
> + };
We can do slightly better than that:
.thumb
bx pc
nop
.arm
ldr ip, [pc, #0]
add pc, pc, ip
dcd R_ARM_REL32(X)
Which is OK because we know the target address is ARM.
R.