This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]