I'm trying to use gdb for debug an application in an arm64 device in a particular situation: -The device is an embedded linux arm64 running linux:
$ uname-a
Linux HMI-fa93 4.14.78-rt47 #1 SMP PREEMPT RT Fri Apr 29 08:40:42 UTC 2022 aarch64 GNU/Linux
I have no problem at all when trying to use gdb with an application that uses native 64 bit (using gdb-multiarch on host and gdbserver aarch64 on target).
In this device i have also an application running at 32 bit which is called using this command for execution:
/customfolder/lib32/ld-linux-armhf.so.3 --library-path /customfolder/lib32 ./TestGDB32
The application run whitout problems so far but the problem is when i want to debug it using gdb.
I've tested a lot of combinations but every time i'm not able to debug the application. I'm afraid that when launching the gdb he think that i'm trying to debug the ld-linux-armhf.so.3 and not my application. I launch the debug in this way:
/customfolder/lib32/ld-linux-armhf.so.3 --library-path /customfolder/lib32 /customfolder/bin/gdbserver --once host:10010 /customfolder/lib32/ld-linux-armhf.so.3 --library-path /customfolder/lib32 ./TestGDB32
Basically i'm trying to run gdb at 32 bit and launching the debug of the 32 bit application.
The output on the host is like that:
0xf7fbea80 in ?? ()
(gdb) list
No symbol table is loaded. Use the "file" command.
(gdb) bt
#0 0xf7fbea80 in ?? ()
#1 0x00000000 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
How can i debug an application at 32bit that runs with this dynamic loader using gdb?
CodePudding user response:
I launch the debug in this way
Yes, when you launch the app this way, GDB will think that you are running ld-linux-armhf.so.3
, and debugging will be very difficult.
It is possible to debug the app launched that way -- you would need to figure out where the main binary (assuming it's PIE) and all the shared libraries are loaded, and use add-symbol-file
for each one, but a much easier solution is to simply build the application so it references desired loader (-Wl,--dynamic-linker=/customfolder/lib32/ld-linux-armhf.so.3
) and has desired RPATH
(-rpath=/customfolder/lib32
), and launch it "normally" (./TestGDB32
).
If you do that, debugging should just work™.