From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28323 invoked by alias); 29 Nov 2011 20:58:30 -0000 Received: (qmail 28315 invoked by uid 22791); 29 Nov 2011 20:58:29 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from usmamail.tilera.com (HELO USMAMAIL.TILERA.COM) (206.83.70.75) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 29 Nov 2011 20:58:15 +0000 Received: from [10.7.0.51] (10.9.0.23) by USMAExch2.tad.internal.tilera.com (10.3.0.33) with Microsoft SMTP Server id 14.0.694.0; Tue, 29 Nov 2011 15:58:14 -0500 Message-ID: <4ED54766.2020601@tilera.com> Date: Tue, 29 Nov 2011 20:58:00 -0000 From: Jeff Kenton User-Agent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:6.0.2) Gecko/20110902 Thunderbird/6.0.2 MIME-Version: 1.0 To: Subject: GDB: problem debugging 32 bit binary on 64 bit machine Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes 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: 2011-11/txt/msg00131.txt.bz2 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