ianlancetaylor / libbacktrace

A C library that may be linked into a C/C++ program to produce symbolic backtraces
Other
947 stars 220 forks source link

Libbacktrace doesn't work on Linux ARM-32 bits #114

Open clopez opened 11 months ago

clopez commented 11 months ago

When I try to use libbacktrace on Linux 32-bits I get an empty backtrace.

See the following example program: http://ix.io/4Jf4

Build it like:

curl http://ix.io/4Jf4 > testbt.c
gcc -c testbt.c -o testbt.o
gcc testbt.o /path/to/libbacktrace.a -o testbt

And then execute it.

On Debian/arm64 (64-bits) you get this:

$ ./testbt
At main() call into bt()
At bt() call backtrace_print
0xaaaac1df1333 ???
    ???:0
0xaaaac1df13b7 ???
    ???:0
0xffffb6d6be17 __libc_start_main
    ../csu/libc-start.c:308
0xaaaac1df1077 ???
    ???:0
At bt() call backtrace_simple
aaaac1df1363 bt ??:0
aaaac1df13b7 main ??:0
ffffb6d6be17 __libc_start_main ../csu/libc-start.c:308
aaaac1df1077 ?? ??:0
Program end

So far, so good

However, on Debian/armhf (ARM 32-bits) you get this:

$ ./testbt
At main() call into bt()
At bt() call backtrace_print
At bt() call backtrace_simple
Program end

So it prints nothing.

Some info about my test environment in case it is useful:

ianlancetaylor commented 11 months ago

Does it help if you run gcc -c -g testbt.c -o testbt.o? I added the -g option.

clopez commented 11 months ago

I just tested to add the -g option and unfortunately it doesn't help.

This is the info about the testbt binary that gets built, just in case is useful.

$ file testbt
testbt: ELF 32-bit LSB pie executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, BuildID[sha1]=ff2046b946518a75d05e88704a33c7429a1d991d, for GNU/Linux 3.2.0, with debug_info, not stripped

$ ldd testbt
    linux-vdso.so.1 (0xf7907000)
    libgcc_s.so.1 => /lib/arm-linux-gnueabihf/libgcc_s.so.1 (0xf7887000)
    libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0xf7788000)
    /lib/ld-linux-armhf.so.3 (0xf78df000)