Port-arm archive

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

Re: [PATCH] thumb fixes

On Tue, Aug 26, 2008 at 03:08:15PM +0300, Mikko Rapeli wrote:
> The cross compilation problem was caused by crtbeginT.o and crtend.o
> which at the moment don't work in thumb mode. If they and a number of
> other objects are compiled with thumb-interwork only, a statically
> linked userspace compiled to thumb works. On target my userspace was
> compiled with thumb-interwork only, so the crt* files worked.

Also crtbegin.o doesn't work in thumb mode, so after building that in
ARM and thumb-interwork mode I can run a dynamically linked /bin/echo in 
thumb mode with mostly thumb compiled libc iff ld.elf_so
is in ARM mode. Though echo is the only on which works and
with /bin/cat I get into trouble in the .plt ELF section:

# LD_LIBRARY_PATH=/root/thumb gdb ./cat17
sp = 0x7fffebac, argc = 2, argv = 0x7fffebb8 <gdb> relocbase 0x20230000
got is at 0x20246938, dynamic is at 0x202468c0
_ctype_ is 0x2023dde2
env[0] = 0x7ffffc74 ENV=/root/.shrc
env[1] = 0x7ffffc84 BLOCKSIZE=1k
env[2] = 0x7ffffc91 PWD=/root/thumb
env[3] = 0x7ffffca1 LD_LIBRARY_PATH=/root/thumb
env[4] = 0x7ffffcbd
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/pkg/sbin:/usr/pkg/bnenv[5] =
0x7ffffd29 HOST=
env[6] = 0x7ffffd2f TERM=vt100
env[7] = 0x7ffffd3a
TERMCAP=vt100|vt100-am:am:bs:ms:xn:xo:co#80:it#8:li#24:vt#3\ added path
GNU gdb 6.5
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you
welcome to change it and/or distribute copies of it under certain
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for
This GDB was configured as "arm--netbsdelf"...
(gdb) b main
Breakpoint 1 at 0x8e28: file
/home/mira/src/netbsd/netbsd-thumb/bin/cat/cat.c, .
(gdb) r
Starting program: /root/thumb/cat17
sp = 0x7fffeb74, argc = 3, argv = 0x7fffeb80 </bin/sh> relocbase
got is at 0x20046938, dynamic is at 0x200468c0
_ctype_ is 0x2003dde2
env[0] = 0x7ffffc5f ENV=/root/.shrc
env[1] = 0x7ffffc6f BLOCKSIZE=1k
env[2] = 0x7ffffc7c PWD=/root/thumb
env[3] = 0x7ffffc8c LD_LIBRARY_PATH=/root/thumb
env[4] = 0x7ffffca8
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/pkg/sbin:/usr/pkg/bnenv[5] =
0x7ffffd14 HOST=
env[6] = 0x7ffffd1a TERM=vt100
env[7] = 0x7ffffd25
TERMCAP=vt100|vt100-am:am:bs:ms:xn:xo:co#80:it#8:li#24:vt#3\env[8] =
0x7fffffda LINES=24
env[9] = 0x7fffffe3 COLUMNS=80
 added path "/usr/lib"
sp = 0x7fffeb8c, argc = 1, argv = 0x7fffeb98 </root/thumb/cat17>
relocbase 0x200got is at 0x2002e938, dynamic is at 0x2002e8c0
_ctype_ is 0x20025de2
env[0] = 0x7ffffc5e ENV=/root/.shrc
env[1] = 0x7ffffc6e BLOCKSIZE=1k
env[2] = 0x7ffffc7b PWD=/root/thumb
env[3] = 0x7ffffc8b LD_LIBRARY_PATH=/root/thumb
env[4] = 0x7ffffca7
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/pkg/sbin:/usr/pkg/bnenv[5] =
0x7ffffd13 HOST=
env[6] = 0x7ffffd19 TERM=vt100
env[7] = 0x7ffffd24
TERMCAP=vt100|vt100-am:am:bs:ms:xn:xo:co#80:it#8:li#24:vt#3\env[8] =
0x7fffffd9 LINES=24
env[9] = 0x7fffffe2 COLUMNS=80
 added path "/usr/lib"

Breakpoint 1, main (argc=1, argv=0x7fffeb98)
    at /home/mira/src/netbsd/netbsd-thumb/bin/cat/cat.c:80
80      /home/mira/src/netbsd/netbsd-thumb/bin/cat/cat.c: No such file
or direc.        in /home/mira/src/netbsd/netbsd-thumb/bin/cat/cat.c
(gdb) stepi
0x00008e2a      80      in
(gdb) stepi
0x00008e2c      80      in
(gdb) stepi
0x00008e2e      80      in
(gdb) stepi
0x00008e30      80      in
(gdb) stepi

Program received signal SIGSEGV, Segmentation fault.
0x00009e28 in ?? ()
(gdb) bt
#0  0x00009e28 in ?? ()
(gdb) disassemble 0x00009e28
No function contains specified address.
(gdb) disassemble 0x00008e2a
Dump of assembler code for function main:
0x00008e18 <main+0>:    push    {r4, r7, lr}
0x00008e1a <main+2>:    sub     sp, #44
0x00008e1c <main+4>:    add     r7, sp, #0
0x00008e1e <main+6>:    adds    r3, r7, #0
0x00008e20 <main+8>:    adds    r3, #8
0x00008e22 <main+10>:   str     r0, [r3, #0]
0x00008e24 <main+12>:   adds    r3, r7, #4
0x00008e26 <main+14>:   str     r1, [r3, #0]
0x00008e28 <main+16>:   adds    r3, r7, #4
0x00008e2a <main+18>:   ldr     r3, [r3, #0]
0x00008e2c <main+20>:   ldr     r3, [r3, #0]
0x00008e2e <main+22>:   adds    r0, r3, #0
0x00008e30 <main+24>:   bl      0x8928 <warnx+12>
0x00008e34 <main+28>:   ldr     r3, [pc, #404]  (0x8fcc <main+436>)
0x00008e36 <main+30>:   movs    r0, #0
0x00008e38 <main+32>:   adds    r1, r3, #0
0x00008e3a <main+34>:   bl      0x8988 <fprintf+12>
0x00008e3e <main+38>:   b.n     0x8ed8 <main+192>
0x00008e40 <main+40>:   adds    r3, r7, #0
0x00008e42 <main+42>:   adds    r3, #40

I suppose 0x8928 is in plt ELF section where objdump also shows a few
undefined instrunctions:

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:       0000922c        andeq   r9, r0, ip, lsr #4
    891c:       e28fc600        add     ip, pc, #0      ; 0x0
    8920:       e28cca09        add     ip, ip, #36864  ; 0x9000
    8924:       e5bcf22c        ldr     pc, [ip, #556]!
    8928:       46c04778        undefined
    892c:       e28fc600        add     ip, pc, #0      ; 0x0
    8930:       e28cca09        add     ip, ip, #36864  ; 0x9000
    8934:       e5bcf220        ldr     pc, [ip, #544]!
    8938:       46c04778        undefined
    893c:       e28fc600        add     ip, pc, #0      ; 0x0
    8940:       e28cca09        add     ip, ip, #36864  ; 0x9000
    8944:       e5bcf214        ldr     pc, [ip, #532]!
    8948:       46c04778        undefined

I don't know what this .plt section is or which object files it's coming
from, but I suspect the dynamic linker ld.elf_so. Hopefully compiling it
in ARM mode would solve this. But at least a dynamic /bin/echo works in
thumb mode now :)


Home | Main Index | Thread Index | Old Index