GDB remote debugging: affects execution on a remote target

Background

I'm working with an ARM device using a custom toolchain (based on Yocto with gcc 4.7 and gdb 7.5) and make it use gdb remote debugging with Eclipse CDT as the debugger interface. I recently had a problem that I was unable to debug a specific executable on a remote target due to this error (reported by gdbserver on the target page) which happened immediately after the gdb host connected to the target:

error while loading shared libraries: unexpected PLT reloc type 0xf0

      

I could finally track down the issue to not match the dynamic linker library binaries /lib/ld-2.16.so

in the target and on the host where, by calling set sysroot

in gdb, I used the locally stored root directory of the target, created along with the toolchain.

Keeping the local file in sync with the remote file works, but I can also just omit the installation sysroot

to debug at least the executable itself. This brings me to the next

Question

How does using the wrong binary ld.so

on the debug node affect the execution of the application in gdbserver on the target? I would prefer that I only get the wrong debug information on the host, since the executable runs without issue on the target (in gdbserver) if I don't have it ld.so

at all on the host. But as the behavior differs, there seems to be some feedback from the host to the target when the file is available.

+3


source to share


1 answer


How does using the wrong ld.so binary on the debug node affect the execution of the application in gdbserver on the target?

Good question.

One possible explanation: in order to properly track, for example, loaded shared libraries in the target, GDB sets a number of internal breakpoints (they are visible in the maintenance info breakpoints

output - they have a negative breakpoint number).



When you don't provide a local file at all, GDB has no idea where to set these breakpoints, and therefore not (you cannot, for example, debug library initializers without them).

When you supply the wrong local file, GDB sets a breakpoint ... in the wrong place (by overwriting what GDB thinks is an instruction, but is actually a PLT move). When the bootloader then encounters this overwritten move, it complains.

+1


source







All Articles