Discussion:
Cross-compiling GDB/GDBSERVER
Itzhak Ben-Akiva
2007-01-16 08:15:27 UTC
Permalink
Hi all,

I'm having some problems with a cross-compiled gdb/gdbserver. I have
searched the Net to find some help, but nothing that I have not
already tried. Include some mails exchange between Daniel Jacobowitz
and Dan Kegel.
The facts are as follows:

I built my toolchain for PowerPC 440EP with Kegel's crosstool. The
toolchain works properly. I'm using it for one year already.

Two days ago I compiled gdb/gdbserver in the following way:

cd gdb-6.6

./configure –target=powerpc-linux –enable-sim-powerpc \
–prefix=path/to/the/installation/of/toolchain

make
make install

Compilation went smoothly. Then, I compiled gdbserver:

cd ./gdb/gdbserver

./configure –host=powerpc-linux –prefix=path/to/the/installation/of/toolchain

make
make install

Compilation went smoothly without any warnings.

However, when I try to connect to the gdbserver, I get the message I
post below. gdb is trying to find the libraries in the wrong places
instead of the right one, i.e., the toolchain build directory. What am
I missing in the compilation? Should I set CFLAGS and LD_FLAGS to the
path of the toolchain build directory?

Many thanks in advance,
Itzhak

(gdb) target remote 172.20.2.156:9898
Remote debugging using 172.20.2.156:9898
warning: Remote failure reply: E01
0x30010308 in ?? ()
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
(gdb) b main
Breakpoint 1 at 0x1000378c
(gdb) c
Continuing.
warning: .dynamic section for "/lib/libpthread.so.0" is not at the
expected address
warning: .dynamic section for "/lib/libc.so.6" is not at the expected address
warning: .dynamic section for "/lib/libm.so.6" is not at the expected address
Error while mapping shared library sections:
/usr/lib/gcc/powerpc-unknown-linux-gnu/3.4.4/libstdc++.so.6: No such
file or directory.
Error while mapping shared library sections:
/usr/lib/gcc/powerpc-unknown-linux-gnu/3.4.4/libgcc_s.so.1: No such
file or directory.
Error while mapping shared library sections:
/lib/ld.so.1: No such file or directory.
Error while reading shared library symbols:
/usr/lib/gcc/powerpc-unknown-linux-gnu/3.4.4/libstdc++.so.6: No such
file or directory.
Error while reading shared library symbols:
/usr/lib/gcc/powerpc-unknown-linux-gnu/3.4.4/libgcc_s.so.1: No such
file or directory.
Error while reading shared library symbols:
/lib/ld.so.1: No such file or directory.

Program received signal SIGSEGV, Segmentation fault.
0x10001a70 in _start ()
Daniel Jacobowitz
2007-01-16 16:51:47 UTC
Permalink
Post by Itzhak Ben-Akiva
However, when I try to connect to the gdbserver, I get the message I
post below. gdb is trying to find the libraries in the wrong places
instead of the right one, i.e., the toolchain build directory. What am
I missing in the compilation? Should I set CFLAGS and LD_FLAGS to the
path of the toolchain build directory?
You need to either use --with-sysroot when building gdb, set
solib-absolute-prefix, or "set sysroot" if you're using GDB HEAD.
I added a section about this common pitfall to the manual a few weeks
ago.
--
Daniel Jacobowitz
CodeSourcery
Itzhak Ben-Akiva
2007-01-16 19:21:18 UTC
Permalink
Hi Daniel,

Thanks, I have already solved this problem.
Post by Daniel Jacobowitz
Post by Itzhak Ben-Akiva
However, when I try to connect to the gdbserver, I get the message I
post below. gdb is trying to find the libraries in the wrong places
instead of the right one, i.e., the toolchain build directory. What am
I missing in the compilation? Should I set CFLAGS and LD_FLAGS to the
path of the toolchain build directory?
You need to either use --with-sysroot when building gdb, set
solib-absolute-prefix, or "set sysroot" if you're using GDB HEAD.
That's exactly what I did. I found on the Net Dan Kegel's "how to"
http://www.kegel.com/linux/gdbserver.txt. It helped me a lot.

Thanks,
Itzhak

P.S.: I'm studying GDB Internals and the mails and patches regarding
to Reverse Debugging Project. I haven't forgot it.
Post by Daniel Jacobowitz
I added a section about this common pitfall to the manual a few weeks
ago.
--
Daniel Jacobowitz
CodeSourcery
Loading...