From: Michael Snyder <msnyder@vmware.com>
To: Pierre Muller <pierre.muller@ics-cnrs.unistra.fr>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: [RFC] Improve stabs debugging for mingw64 executables loaded at high addresses
Date: Tue, 14 Sep 2010 18:15:00 -0000 [thread overview]
Message-ID: <4C8FADBC.70301@vmware.com> (raw)
In-Reply-To: <000701cb541e$1160cde0$342269a0$@muller@ics-cnrs.unistra.fr>
Pierre Muller wrote:
> 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...
>
> Comments welcome,
I don't see any intrinsic harm in it, since it will only affect stabs
binaries when BFD64 is defined.
This is just a comment, though, not an approval.
> 2010-09-14 Pierre Muller <muller@ics.u-strasbg.fr>
>
> * dbxread.c (read_dbx_symtab): Add high part of text_addr value
> to all section offsets.
>
> Index: src/gdb/dbxread.c
> ===================================================================
> 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 = DBX_TEXT_ADDR (objfile);
> text_size = DBX_TEXT_SIZE (objfile);
>
> +#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 = text_addr & ~((CORE_ADDR) 0xffffffff);
> + if (stabs_fixup)
> + {
> + objfile->section_offsets->offsets[SECT_OFF_TEXT (objfile)] += stabs_fixup;
> + objfile->section_offsets->offsets[SECT_OFF_DATA (objfile)] += stabs_fixup;
> + objfile->section_offsets->offsets[SECT_OFF_BSS (objfile)] += stabs_fixup;
> + }
> + }
> +#endif /* BFD64 */
> +
> /* FIXME. We probably want to change stringtab_global rather than add this
> while processing every symbol entry. FIXME. */
> file_string_table_offset = 0;
>
next prev parent reply other threads:[~2010-09-14 17:15 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-14 17:15 Pierre Muller
2010-09-14 17:32 ` Tristan Gingold
2010-09-14 17:50 ` Pierre Muller
2010-09-15 8:30 ` Tristan Gingold
2010-09-15 8:33 ` Pierre Muller
2010-09-15 12:42 ` Tristan Gingold
[not found] ` <47535.3697002449$1284477885@news.gmane.org>
2010-09-14 20:56 ` Tom Tromey
2010-09-15 11:54 ` Pierre Muller
2010-09-14 18:15 ` Michael Snyder [this message]
2010-09-14 19:07 ` Joel Brobecker
2010-09-15 9:57 ` Pierre Muller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4C8FADBC.70301@vmware.com \
--to=msnyder@vmware.com \
--cc=gdb-patches@sourceware.org \
--cc=pierre.muller@ics-cnrs.unistra.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox