From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10105 invoked by alias); 5 May 2010 12:48:40 -0000 Received: (qmail 9710 invoked by uid 22791); 5 May 2010 12:48:34 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 05 May 2010 12:48:24 +0000 Received: (qmail 25417 invoked from network); 5 May 2010 12:48:23 -0000 Received: from unknown (HELO ?192.168.0.104?) (ams@127.0.0.2) by mail.codesourcery.com with ESMTPA; 5 May 2010 12:48:23 -0000 Message-ID: <4BE16915.7080501@codesourcery.com> Date: Wed, 05 May 2010 12:48:00 -0000 From: Andrew Stubbs User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.9.1.9) Gecko/20100317 Thunderbird/3.0.4 MIME-Version: 1.0 To: gdb@sourceware.org Subject: debug problem with prelinked libraries Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2010-05/txt/msg00029.txt.bz2 Hi all, I'm trying to get to the bottom of a problem debugging prelinked libraries. I've fixed a few aspects of the problem, but the further I get into it the more I think I must be missing something. I mean, debugging prelinked libraries is supposed to Just Work, right? But I can't see how it could ever have worked. First, I should say that I'm trying to debug a core dump that includes prelinked libraries. Is that different somehow? The target is mips, if that makes any difference. Also, debugging works fine for the non-prelinked libraries and core file, so the problem's not there. I originally encountered the problem with (a somewhat patched) 6.6.50_20070925, but I'm seeing exactly the same trouble in the latest from CVS. The problem is that GDB does not find the symbols and debug info for the code in the prelinked libraries. Upon closer inspection, I find that the psymtab has the textlow and texthigh addresses as the original file-offsets, before relocation. This appears to be because it calculates the section offset as the difference between the actual address and the ELF VMA, but the file is prelinked, so the offset is zero, and the debug info and symbols are then not relocated. So, I inserted a little code to fixup the offset in the psymtab for the prelinked cases, but it now loads the symtab with exactly the same offset troubles. So, I try to fix those, and the problem just moves one step further on. Surely I can't need to implement prelink support from scratch, so I must be missing something? Is there one place that this should be fixed? I think I need to adjust the base address used by the debug info, but I don't know how to do it without also changing the base address used for relocating the binaries. Any other suggestions? Any help would be much appreciated. Andrew