As reported on the bug trackers for some other linux distributions, certain kernels (after 2.6.18) will not work with GDB, giving the message "Failed to read valid object file image from memory" and providing very broken backtraces or not working at all. There is lots of detail on the suse bug at https://bugzilla.novell.com/show_bug.cgi?id=258433 I was having this issue with a fresh gentoo install on the 2.6.22-gentoo-r5 kernel, using both normally emerged GDB and a USE="vanilla" GDB. I applied a patch found in the bug I linked above (patch is at https://bugzilla.novell.com/attachment.cgi?id=159330) to the kernel, which seems to have worked (I no longer get the message, backtraces are fine, etc). Reproducible: Always Steps to Reproduce: 1. Run any program in GDB 2. The "failed to read valid object file image from memory" message is displayed 3. Halt the execution of the program, or crash it 4. Get a backtrace; the symbols will be extremely broken.
not a bug in the toolchain
Just to be sure, you're using COMPAT_VDSO=y, right? Can you test with the latest kernel prepatch, 2.6.23_rc4? That should fix it, since the required patch has been in since 2.6.23_rc1.
Yes, I have COMPAT_VDSO=y. The patch I linked works; if that's the one or similar to the one in 2.6.23, it should work fine. I'll test it anyway if you want, although i've got no idea how to get that kernel version; it doesn't seem to be in portage anywhere.
Yes, the patch you linked to is the same one that's in rc4 now. Please test it, you can get that kernel like this: # ACCEPT_KEYWORDS="~x86" emerge =sys-kernel/vanilla-sources-2.6.23_rc4
influence ~ # uname -a Linux influence 2.6.23-rc4 #1 Thu Aug 30 18:50:38 EDT 2007 i686 Intel(R) Pentium(R) 4 CPU 2.40GHz GenuineIntel GNU/Linux GDB starts without complaint, reads all of the symbols properly, and can read core dumps. Seems to fully work.
Please apply the attached patch to your gentoo-sources-2.6.22-r5, that should work as well. If it does, we'll incorporate it into the next version of gentoo-sources. Thank you for testing this.
Created attachment 129646 [details, diff] gdb_access_vsyscall_page_with_compat_vdso.patch
Yup; that fixes the issue on 2.6.22 as well. Glad to help ;)
Maarten, please include the full patch header when attaching and committing, even if you modified or remade it yourself (if you used quilt it would take care of this for you)
The patch has been included in gentoo-sources-2.6.22-r6.
*** Bug 191631 has been marked as a duplicate of this bug. ***