Port-arm archive

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

Re: [PATCH] thumb fixes

On Fri, 2008-09-05 at 11:48 +0300, Mikko Rapeli wrote:
> On Fri, Sep 05, 2008 at 08:49:07AM +0300, Mikko Rapeli wrote:
> > > Note that PLT sequences rely on the target
> > > being either an ARM instruction or that the CPU running the code is v5t
> > > or later (since ldr pc does not interwork correctly on v4t).
> > 
> > I suppose netbsd defaults to v4t, so I hope -march=arm5t will fix this.
> Nope, -march=armv5t didn't help.
> SIGSEGV comes after this branch in main:
> 0x00008de0 <main+24>:   bl      0x8928 <warnx+12>
> And the destination 0x8928 is the undefined instruction in the plt
> section.

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).

> 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).  


Home | Main Index | Thread Index | Old Index