From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16752 invoked by alias); 14 Sep 2010 15:04:22 -0000 Received: (qmail 16735 invoked by uid 22791); 14 Sep 2010 15:04:21 -0000 X-SWARE-Spam-Status: No, hits=-1.1 required=5.0 tests=AWL,BAYES_00,MSGID_MULTIPLE_AT,TW_BJ,TW_DB X-Spam-Check-By: sourceware.org Received: from mailhost.u-strasbg.fr (HELO mailhost.u-strasbg.fr) (130.79.200.151) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 14 Sep 2010 15:04:01 +0000 Received: from md1.u-strasbg.fr (md1.u-strasbg.fr [IPv6:2001:660:2402::186]) by mailhost.u-strasbg.fr (8.14.3/jtpda-5.5pre1) with ESMTP id o8EF3wZG094830 for ; Tue, 14 Sep 2010 17:03:58 +0200 (CEST) (envelope-from pierre.muller@ics-cnrs.unistra.fr) Received: from mailserver.u-strasbg.fr (ms5.u-strasbg.fr [IPv6:2001:660:2402:d::14]) by md1.u-strasbg.fr (8.14.4/jtpda-5.5pre1) with ESMTP id o8EF3woW022530 for ; Tue, 14 Sep 2010 17:03:58 +0200 (CEST) (envelope-from pierre.muller@ics-cnrs.unistra.fr) Received: from d620muller (gw-ics.u-strasbg.fr [130.79.210.225]) (user=mullerp mech=LOGIN) by mailserver.u-strasbg.fr (8.14.4/jtpda-5.5pre1) with ESMTP id o8EF3v7U006284 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO) for ; Tue, 14 Sep 2010 17:03:58 +0200 (CEST) (envelope-from pierre.muller@ics-cnrs.unistra.fr) From: "Pierre Muller" To: Subject: [RFC] Improve stabs debugging for mingw64 executables loaded at high addresses Date: Tue, 14 Sep 2010 17:15:00 -0000 Message-ID: <000701cb541e$1160cde0$342269a0$@muller@ics-cnrs.unistra.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-09/txt/msg00266.txt.bz2 On 64-bit targets, stabs suffers from the fact that addresses are only stored as 32-bit values. For mingw64, I was able to debug executables loaded at address 0x100000000 (the default location for executables compiled by Free Pascal Compiler) by using the simple patch below. The idea of the patch is quite basic: add the 32 high bits of text_addr as to the offsets of all sections in read_dbx_symtab. I don't know if this is mingw64 (possibly 64-bit PE) specific or not... All those offsets seemed to be at zero at the time I added the high 32-bit part of text_addr, but maybe other targets do something else... If this should not be applied for other 64-bit targets, we could of course modify the tests before changing the offsets, restricting it to targets for which it is relevant. I just tried to use gcc to compile an executable with -Wl,--image-base,0x300000000, to force high load address, but this lead to lots of messages: relocation truncated to fit R_X86_64_32 against .text Free Pascal compiler doesn't seem to generate any of those time of relocations...=20 Comments welcome, Pierre Muller Pascal language support maintainer for GDB =20=20 2010-09-14 Pierre Muller * dbxread.c (read_dbx_symtab): Add high part of text_addr value to all section offsets. Index: src/gdb/dbxread.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/dbxread.c,v retrieving revision 1.116 diff -u -p -r1.116 dbxread.c --- src/gdb/dbxread.c 14 May 2010 17:53:15 -0000 1.116 +++ src/gdb/dbxread.c 1 Sep 2010 08:01:01 -0000 @@ -1216,6 +1216,22 @@ read_dbx_symtab (struct objfile *objfile text_addr =3D DBX_TEXT_ADDR (objfile); text_size =3D DBX_TEXT_SIZE (objfile); =20 +#ifdef BFD64 + { + /* stabs internal format only has 4 bytes for address. + Use high dword of text address to fix global addresses. + FIXME: this only works if the whole executable has the same + high part address. */ + CORE_ADDR stabs_fixup =3D text_addr & ~((CORE_ADDR) 0xffffffff); + if (stabs_fixup) + { + objfile->section_offsets->offsets[SECT_OFF_TEXT (objfile)] +=3D st= abs_fixup; + objfile->section_offsets->offsets[SECT_OFF_DATA (objfile)] +=3D stabs_fix= up; + objfile->section_offsets->offsets[SECT_OFF_BSS (objfile)] +=3D stabs_fixu= p; + } + } +#endif /* BFD64 */ + /* FIXME. We probably want to change stringtab_global rather than add t= his while processing every symbol entry. FIXME. */ file_string_table_offset =3D 0;