From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Andreas Schwab <schwab@redhat.com>
Cc: binutils@sourceware.org, gdb-patches@sourceware.org
Subject: Re: [patch] bfd/: bfd_elf_bfd_from_remote_memory 32bit &= 0xffffffff
Date: Thu, 11 Feb 2010 12:43:00 -0000 [thread overview]
Message-ID: <20100211124302.GA8435@host0.dyn.jankratochvil.net> (raw)
In-Reply-To: <m3tytoynpk.fsf@hase.home>
On Thu, 11 Feb 2010 13:13:43 +0100, Andreas Schwab wrote:
> Jan Kratochvil <jan.kratochvil@redhat.com> writes:
>
> > --- a/bfd/elfcode.h
> > +++ b/bfd/elfcode.h
> > @@ -1745,6 +1745,8 @@ NAME(_bfd_elf,bfd_from_remote_memory)
> > if (!loadbase_set && (i_phdrs[i].p_offset & -i_phdrs[i].p_align) == 0)
> > {
> > loadbase = ehdr_vma - (i_phdrs[i].p_vaddr & -i_phdrs[i].p_align);
> > + if (ELFCLASS == ELFCLASS32)
> > + loadbase &= 0xffffffff;
>
> Some targets use signed addresses.
http://sourceware.org/ml/gdb-patches/2006-09/msg00197.html
# One caveat:
# if addresses are supposed to be sign extended, we should not print out
# 64-bit addresses for a 32-bit target just because they're sign
# extended. This will show up on MIPS, which sign extends addresses.
Thanks for bringing up this larger issue.
As this representation is only internal to gdb (bfd) I chose rather to use
always the unsigned/zeroed format as it makes its internal handling in tools
IMO easier. It does not (or at least does not have to) affect any inferior-
or user- visible behavior. If someone casts CORE_ADDR -> LONGEST/ULONGEST
then CORE_ADDR should be extended the proper sign/unsigned way from its target
width (such as 32->64).
This patch is a prerequisite for PIE support on 64bit gdb -> 32bit inferior,
commented by Ulrich Weigand in:
http://sourceware.org/ml/gdb-patches/2010-01/msg00497.html
The full gdb patch (not yet posted) already does explicit handling of target
width on any CORE_ADDR in use as an address _displacement_ by ensuring
a compilation error otherwise:
+/* Wrap CORE_ADDR so that normal math operation are no longer valid on it. Use
+ the set of functions around addr_add_offset to access it. Direct access to
+ A is permitted for reading A and setting A to constant like zero or one. */
+typedef struct
+ {
+ CORE_ADDR a;
+ }
+addr_offset_t;
There should be similar part done for all the CORE_ADDR operations to properly
respect target address width. This is currently already broken anyway.
Therefore if we either always-zero-extend or target-wise-sign-extend CORE_ADDR
should not be a regression. I do not intend to post such full CORE_ADDR fixup
(outside of the biarch-PIE functionality) in a near future, though.
It may be simpler if CORE_ADDR would be a C++ class with overriden operators.
But moving GDB over to C++ has been currently turned down.
Thanks,
Jan
next prev parent reply other threads:[~2010-02-11 12:43 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-11 11:57 Jan Kratochvil
2010-02-11 12:13 ` Andreas Schwab
2010-02-11 12:43 ` Jan Kratochvil [this message]
[not found] ` <20100211124302.GA8435__38068.0548646071$1265892205$gmane$org@host0.dyn.jankratochvil.net>
2010-02-16 23:24 ` Tom Tromey
2010-02-17 11:34 ` Jan Kratochvil
2010-02-17 18:50 ` Tom Tromey
2010-02-20 0:43 ` Jan Kratochvil
2010-02-11 12:51 ` Mark Kettenis
2010-02-11 13:30 ` [cancelled] " Jan Kratochvil
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=20100211124302.GA8435@host0.dyn.jankratochvil.net \
--to=jan.kratochvil@redhat.com \
--cc=binutils@sourceware.org \
--cc=gdb-patches@sourceware.org \
--cc=schwab@redhat.com \
/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