This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GDB: problem debugging 32 bit binary on 64 bit machine



A little convoluted, but here's the story:


On our 64 machine gdb fails to read share libraries when debugging 32 bit binaries (i.e., compiled with "-m32"). Debugging code built "-static" is OK. The error is "Cannot access memory at address 0x400000008" (address is above the 32 bit limit). This is caused by a call to extract_typed_address() from scan_dyntag() reading an 8 byte type when it should only be reading 4 bytes.

So, I tweaked extract_typed_address() to know it was dealing with 32 binaries. Now gdb starts happily and reads in the shared libraries but the program won't execute. It gets

warning: Can't read pathname for load map: Input/output error.
Cannot access memory at address 0x35dc3000

and the backtrace shows that it's in dl_main():
#0  *__GI__dl_debug_state () at dl-debug.c:77
#1  0x0000000077f93d00 in dl_main () at rtld.c:1651
#2  0x0000000077fb1698 in _dl_sysdep_start ()  at ../elf/dl-sysdep.c:244
#3  0x0000000077f90c70 in _dl_start_final () at rtld.c:334
#4  0x0000000077f96630 in _dl_start () at rtld.c:562
#5  0x0000000077fb2530 in _start () from .../lib32/ld.so.1

I have two questions:
1. is tweaking extract_typed_address() the right way to handle 32 bit addresses on a 64 bit machine? It seems weird but nothing else came to mind.
2. what's going wrong with dl_main()?
3. meta-question: is this a generic bug in gdb's handling of 32 bit binaries, or is there likely something I missed while porting?


Thanks.

--jeff


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]