Port-arm archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: [PATCH] thumb fixes

On Fri, Sep 05, 2008 at 10:39:09AM +0100, Richard Earnshaw wrote:
> Hmm, I remember now.  I think this is an LD bug.  When thumb code calls
> a PLT entry it needs to use an interworking call sequence (the BL needs
> to be turned into BLX on v5t).  LD doesn't realize this because the PLT
> sequence is internally generated.
> I believe this has been fixed in FSF binutils, but probably not in
> NetBSD's in-tree version (and I can't remember if this was ever fixed in
> a GPLv2 release).

Ok, I was already browsing through
and others which are involved in generating the plt stuff. 

> > If there only was a way to force the plt section to be in ARM mode...
> The PLT *is* in ARM mode...  Your problem is that you're calling it from
> Thumb :-(


> There is a work-around, but it costs a bit in both performance and code
> size.  You can build all your thumb code with -mlong-calls.  Doing this
> will mean that the compiler will only use BL when it can prove that the
> call will be non-interworking at compile time (ie a static function).  

-mlong-calls indeed fixes /bin/cat, when ld.elf_so is in ARM mode.
/bin/sh instead segfaults, but that problem seems to be within libc
which propably has a number of problematic entry and exit points.
I'm running /bin/sh with libraries and linkers in a chroot, so gdb
can not get me a backtrace easily.

With -mlong-calls the plt sections looks ok:

00008908 <.plt>:
    8908:       e52de004        str     lr, [sp, #-4]!
    890c:       e59fe004        ldr     lr, [pc, #4]    ; 8918 <.plt+0x10>
    8910:       e08fe00e        add     lr, pc, lr
    8914:       e5bef008        ldr     pc, [lr, #8]!
    8918:       000091f0        streqd  r9, [r0], -r0
    891c:       e28fc600        add     ip, pc, #0      ; 0x0
    8920:       e28cca09        add     ip, ip, #36864  ; 0x9000
    8924:       e5bcf1f0        ldr     pc, [ip, #496]!
    8928:       e28fc600        add     ip, pc, #0      ; 0x0
    892c:       e28cca09        add     ip, ip, #36864  ; 0x9000
    8930:       e5bcf1e8        ldr     pc, [ip, #488]!
    8934:       e28fc600        add     ip, pc, #0      ; 0x0
    8938:       e28cca09        add     ip, ip, #36864  ; 0x9000
    893c:       e5bcf1e0        ldr     pc, [ip, #480]!
    8940:       e28fc600        add     ip, pc, #0      ; 0x0
    8944:       e28cca09        add     ip, ip, #36864  ; 0x9000
    8948:       e5bcf1d8        ldr     pc, [ip, #472]!


Home | Main Index | Thread Index | Old Index