2011-04-12 07:27:22     Ldd or readelf?

Document created by Aaronwu Employee on Aug 26, 2013
Version 1Show Document
  • View in full screen mode

2011-04-12 07:27:22     Ldd or readelf?

Gilles Ganault (FRANCE)

Message: 99785   

 

Hello

 

I need to build either ldd or readelf so I can run it on a Blackfin.

 

Although it is not part of even the latest stable Blackfin release (2010R1-RC5), it can be found in release 20101026 from www.uclinux.org.

 

So from 20101026/uClibc/utils/, I simply extracted ldd.c and bsignal.h into its own directory and used the following -I switch to include where I thought gcc would find the header files it needed:

 

================

 

BASE=/usr/src/uClinux-dist20101026

 

INCLUDES=-I$(BASE)/linux-2.6.x/include -I$(BASE)/uClibc/include -I$(BASE)/include -I$(BASE)/uClibc/ldso/include

CFLAGS=-O2 -Wall $(INCLUDES)

 

ldd:

        $(CC) $(CFLAGS) -o $@ *.c

================

 

But compiling is giving a lot of warnings/errors:

================

bfin-linux-uclibc-gcc -O2 -Wall -I/usr/src/uClinux-dist20101026/linux-2.6.x/include -I/usr/src/uClinux-dist20101026/uClibc/include -I/usr/src/uClinux-dist20101026/include -I/usr/src/uClinux-dist20101026/uClibc/ldso/include -o ldd *.c

ldd.c:120:23: error: asm/elf.h: No such file or directory

ldd.c:130:3: warning: #warning "You really should add a MATCH_MACHINE() macro for your architecture"

ldd.c: In function âelf_find_dynamicâ:

ldd.c:213: warning: cast to pointer from integer of different size

ldd.c: In function âcheck_elf_headerâ:

ldd.c:238: error: âELFCLASSMâ undeclared (first use in this function)

ldd.c:238: error: (Each undeclared identifier is reported only once

ldd.c:238: error: for each function it appears in.)

ldd.c: In function âfind_dependanciesâ:

ldd.c:705: error: âELFCLASSMâ undeclared (first use in this function)

ldd.c:708: warning: implicit declaration of function âMATCH_MACHINEâ

make: *** [ldd] Error 1

================

 

Does it mean that uClinux's version can not be compiled with the Blackfin toolchain? Is there a work-around?

 

Thank you.

QuoteReplyEditDelete

 

 

2011-04-12 12:45:38     Re: Ldd or readelf?

Mike Frysinger (UNITED STATES)

Message: 99793   

 

why exactly do you want to run these things on the board ?  do you just want to view the direct library dependencies ?

 

you could use `scanelf` from pax-utils.  that compiles cleanly for Blackfin targets.

 

as for the uclinux.org code, we dont support that.  uClibc is not part of the Blackfin dist (by design), but is included in the Blackfin toolchain.  `bfin-linux-uclibc-ldd`.

QuoteReplyEditDelete

 

 

2011-04-12 18:42:46     Re: Ldd or readelf?

Gilles Ganault (FRANCE)

Message: 99800   

 

> you could use `scanelf` from pax-utils.  that compiles cleanly for Blackfin targets.

 

Thanks for the tip. Indeed, to investigate, I need to check which libraries a binary needs when ran on a Blackfin board.

 

However, neither  "make menuconfig" nor  "find /usr/src/uClinux-dist-2010R1-RC5/ -name "scanelf"" returned any hit. Is "scanelf" part of uClinux-dist-2010R1-RC5, or should I download it from the Net and compile it manually using the latest Blackfin toolchain?

QuoteReplyEditDelete

 

 

2011-04-12 19:02:42     Re: Ldd or readelf?

Mike Frysinger (UNITED STATES)

Message: 99802   

 

wget   distfiles.gentoo.org/distfiles/pax-utils-0.2.3.tar.bz2

tar xf pax-utils-*.tar.bz2

cd pax-utils-*/

make CC=bfin-uclinux-gcc

./scanelf -qn <ELF>

QuoteReplyEditDelete

 

 

2011-04-12 20:17:24     Re: Ldd or readelf?

Gilles Ganault (FRANCE)

Message: 99805   

 

Thanks Mike. Turns out Gentoo used a new format starting with 0.2.3 (.xz instead of .bz2).

 

 

 

For the benefit of others looking for the same thing:

 

1. wget -c   distfiles.gentoo.org/distfiles/pax-utils-0.2.2.tar.bz2

 

2. tar xjvf pax-utils-0.2.2.tar.bz2

 

3. cd pax-utils-0.2.2

 

4. Export path to Blackfin GCC, and run "make CC=bfin-linux-uclibc-gcc"

 

5. Download scanelf on Blackfin appliance

 

6. > ./scanelf -qn ./myapp

Attachments

    Outcomes