This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Implementing long branch stubs with PLTs
- From: Will Newton <will dot newton at gmail dot com>
- To: binutils at sourceware dot org
- Date: Thu, 16 Jul 2009 17:12:34 +0100
- Subject: Implementing long branch stubs with PLTs
Hi all,
I have a question about implementing long branch stubs in ld in the
presence of PLTs. Say I have an executable like this:
0x001000 .plt
0x020000 .text
...
0x100000 foo
0x100200 bar
Where foo and bar are global symbols.
If foo calls bar then it looks like what happens in my implementation
is that the check in type_of_stub (as in elf32-arm.c, elf32-hppa.c and
elf64-ppc.c) calculates the difference between the addresses of foo
and bar and concludes that they are close enough that a standard
branch instruction will be sufficient. However when it comes to the
relocate_section hook the address used for bar is not 0x100200, but
the PLT entry for bar, which is much further away (e.g. at 0x001000)
and may cause the link to fail if the branch offset is out of range.
My question is: how do the arm, hppa and ppc ports avoid this problem?
I cannot find any code in those ports that appears to explicitly deal
with branches to global symbols via a PLT.
Thanks,