This is the mail archive of the crossgcc@sourceware.cygnus.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more infromation.


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

Re: cross-compiling & debugging embedded-linux apps


Kai Ruottu wrote:

> > I NEED to be able to compile apps from the sources.  I have managed to
> > cross-compile ncurses and bash.  I can't get bash to run at all (even a
> > statically compiled version).  I get segmentaion faults.  I'm currently
> > using SASH which I have cross-compiled as a static binary.  I compiled a
> > test app (bjs1.c) which outputs a string every second.  It is compiled
> > as a static binary (bjs1-static) and a shared binary (bjs1-shared).  The
> > static binary works but the shared one does not.  I assume it is some
> > library problem but I can't figure out what.  The output of the sash
> > session is below.
> >
> > Stand-alone shell (version 1.0)
> > > ./bjs1-static
> > BJS1: Brendan was here
> > BJS1: Brendan was here
> > BJS1: Brendan was here
> > pid 7: killed (signal 2)
> > >
> > > ./bjs1-shared
> > pid 8: killed (signal 11)
>
>  Some simple sanity checks for shared executables, before downloading them
> into the target, follows...
>
> 1. Using 'strings' to see the 'hard-wired' name of the dynamic linker in
>    the executable:
>
>         E:\usr\local\samples>strings tst_ppc-linux.x | more
>         /lib/ld.so.1    <------- !!!
>         __gmon_start__
>         libc.so.6
>         strcpy
>         printf
>         stdout
>
> 2. Using 'objdump -p' to see the needed shared libs, version dependencies

I didn't know that existed.  My man and info pages do not describe the -p option,
though it is listed in the sytax/synopsis part.

The output of "powerpc-linux-strings bjs1-shared" looks OK to me.
$ powerpc-linux-strings bjs1-shared
_DYNAMIC
_GLOBAL_OFFSET_TABLE_
__gmon_start__
_init
_fini
_SDA_BASE_
_SDA2_BASE_
__deregister_frame_info
__register_frame_info
main
puts
sleep
libc.so.6
_etext
_edata
_end
GLIBC_2.0
BJS1: Brendan was here

I'm not sure how to interpret the output of "powerpc-linux-objdump -p bjs1-shared".
The output  is :
$ powerpc-linux-objdump -p bjs1-shared

bjs1-shared:     file format elf32-powerpc

Program Header:
    LOAD off    0x00000000 vaddr 0x00000000 paddr 0x00000000 align 2**16
         filesz 0x0000066c memsz 0x0000066c flags r-x
    LOAD off    0x00000670 vaddr 0x00040670 paddr 0x00040670 align 2**16
         filesz 0x000000d8 memsz 0x0000015c flags rwx
 DYNAMIC off    0x00000678 vaddr 0x00040678 paddr 0x00040678 align 2**2
         filesz 0x000000a0 memsz 0x000000a0 flags rw-

Dynamic Section:
  NEEDED      libc.so.6
  INIT        0x610
  FINI        0x634
  HASH        0x94
  STRTAB      0x310
  SYMTAB      0x150
  STRSZ       0xad
  SYMENT      0x10
  PLTGOT      0x40748
  PLTRELSZ    0x3c
  PLTREL      0x7
  JMPREL      0x48c
  RELA        0x420
  RELASZ      0xa8
  RELAENT     0xc
  TEXTREL     0x0
  VERNEED     0x400
  VERNEEDNUM  0x1
  VERSYM      0x3c8

Version References:
  required from libc.so.6:
    0x0d696910 0x00 02 GLIBC_2.0


I don't see anything strange here.   I did the same for libc.so.6
$ powerpc-linux-objdump -p lib/libc.so.6

lib/libc.so.6:     file format elf32-powerpc

Program Header:
    PHDR off    0x00000034 vaddr 0x00000034 paddr 0x00000034 align 2**2
         filesz 0x000000c0 memsz 0x000000c0 flags r-x
  INTERP off    0x000e8760 vaddr 0x00128760 paddr 0x00128760 align 2**2
         filesz 0x00000010 memsz 0x00000010 flags rw-
    LOAD off    0x00000000 vaddr 0x00000000 paddr 0x00000000 align 2**16
         filesz 0x000d9f1c memsz 0x000d9f1c flags r-x
    LOAD off    0x000d9f20 vaddr 0x00119f20 paddr 0x00119f20 align 2**16
         filesz 0x00012fa0 memsz 0x00016a48 flags rwx
 DYNAMIC off    0x000e8a30 vaddr 0x00128a30 paddr 0x00128a30 align 2**2
         filesz 0x000000b0 memsz 0x000000b0 flags rw-

Dynamic Section:
  NEEDED      ld.so.1
  SONAME      libc.so.6
  INIT        0x21738
  FINI        0xd9eb0
  HASH        0xf4
  STRTAB      0x9728
  SYMTAB      0x2be8
  STRSZ       0x79ba
  SYMENT      0x10
  PLTGOT      0x12cec0
  PLTRELSZ    0x14d0
  PLTREL      0x7
  JMPREL      0x1ff50
  RELA        0x11eec
  RELASZ      0xf714
  RELAENT     0xc
  VERDEF      0x11e60
  VERDEFNUM   0x3
  VERNEED     0x11ebc
  VERNEEDNUM  0x1
  VERSYM      0x110f6

Version definitions:
1 0x01 0x0865f4e6 libc.so.6
2 0x00 0x0d696910 GLIBC_2.0
3 0x00 0x0d696911 GLIBC_2.1
        GLIBC_2.0

Version References:
  required from ld.so.1:
    0x0d696911 0x00 05 GLIBC_2.1
    0x0d696910 0x00 04 GLIBC_2.0


And again for ld.so.1
$ powerpc-linux-objdump -p lib/ld.so.1

lib/ld.so.1:     file format elf32-powerpc

Program Header:
    LOAD off    0x00000000 vaddr 0x00000000 paddr 0x00000000 align 2**16
         filesz 0x00013fb8 memsz 0x00013fb8 flags r-x
    LOAD off    0x00013fc0 vaddr 0x00053fc0 paddr 0x00053fc0 align 2**16
         filesz 0x00002bc8 memsz 0x000032c0 flags rwx
 DYNAMIC off    0x00016378 vaddr 0x00056378 paddr 0x00056378 align 2**2
         filesz 0x00000088 memsz 0x00000088 flags rw-

Dynamic Section:
  SONAME      ld.so.1
  HASH        0x94
  STRTAB      0xf28
  SYMTAB      0x528
  STRSZ       0xcc4
  SYMENT      0x10
  PLTGOT      0x56c2c
  PLTRELSZ    0x330
  PLTREL      0x7
  JMPREL      0x3170
  RELA        0x1d9c
  RELASZ      0x1704
  RELAENT     0xc
  VERDEF      0x1d40
  VERDEFNUM   0x3
  VERSYM      0x1c00

Version definitions:
1 0x01 0x0275a261 ld.so.1
2 0x00 0x0d696910 GLIBC_2.0
3 0x00 0x0d696911 GLIBC_2.1
        GLIBC_2.0


I don't see anything glaringly wrong but I don't exactly know what I would be looking
for.  Can you see any problems ?



> > It can't be that hard to get a simple 10 line program to execute as a
> > shared binary.  It must be something really simple that I am missing.
>
>  Perhaps the new 'readelf' utility in binutils can be used for sanity checks
> of the same kind...

Never heard of it.  Is it part of binutils-2.9.1 or newer cvs and snapshots ?


Thanks,
Brendan Simon.



------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com


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