Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Kevin Buettner <kevinb@cygnus.com>
To: "Martin M. Hunt" <hunt@redhat.com>, <gdb-patches@sources.redhat.com>
Subject: Re: [RFA] shared library address patch
Date: Mon, 19 Feb 2001 18:29:00 -0000	[thread overview]
Message-ID: <1010220022927.ZM24388@ocotillo.lan> (raw)
In-Reply-To: <Pine.SUN.4.33.0102191527540.2670-100000@rtl.cygnus.com>

On Feb 19,  3:33pm, Martin M. Hunt wrote:

> The following patch keeps GDB from relocating shared libraries on
> mipsel-linux-gnu out of the 32-bit address space.  On researching this, I
> noticed Maciej W. Rozycki proposed a similar fix back in July
> (see http://sources.redhat.com/ml/gdb-patches/2000-07/msg00260.html )
> 
> 2001-02-19  Martin M. Hunt  <hunt@redhat.com>
> 
> 	* solib-svr4.c (LM_ADDR): LM_ADDR is a signed offset, so
> 	extract_signed_integer() should be called instead of
> 	extract_address().

This change is approved.

I stared at this one a while because it looked wrong to me.  So I'm
going to provide here the additional details which convinced me it was
right.

First, I can find no reference to the ``l_addr'' field, nor even to
struct link_map in any of my SysV ABI documents.  I searched abi386-4.pdf,
gabi40.pdf, gabi41.pdf, and mipsabi.pdf which may be found at

    http://www.sco.com/developer/devspecs/

I would very much like to know where struct link_map is documented.

When you can't find a document, you fall back to the code (though
sometimes it's the other way around ;-) . Anyway, I looked at link.h
on my Linux box and see the following declaration for the ``l_addr''
member:

    ElfW(Addr) l_addr;		/* Base address shared object is loaded at.  */

It turns out that this declaration of l_addr is unsigned.  This is one
of the reasons why Martin's/Maciej's change looked wrong to me.  OTOH,
if you read the comment, it clearly uses the words "base address".  Base
addresses *are* discussed in chapter 5 of the SysV ABI.  In gabi41, on
page 5-5 it says the following:

    ...  The difference between the virtual address of any segment in
    memory and the corresponding virtual address in the file is thus a
    single constant value for any one executable or shared object in a
    given process.  This difference is the base address.

As we all know, differences can sometimes be negative, so it doesn't
sense for the base address to be considered as an unsigned value.

Finally, I looked to see how glibc computed the l_addr value.  It is
indeed computed as the difference between where the segment gets
loaded and (presumably - I got a bit confused at this point) the file
address.

The one concern I have regarding this change is that (unfortunately)
SVR4 and SunOS support are still tangled together in solib-svr4.c.
Thus, my concern is that this change will break SunOS (and some *BSD)
shared library support.

Kevin


      parent reply	other threads:[~2001-02-19 18:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-02-19 15:33 Martin M. Hunt
2001-02-19 16:48 ` Andrew Cagney
2001-02-19 18:29 ` Kevin Buettner [this message]

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=1010220022927.ZM24388@ocotillo.lan \
    --to=kevinb@cygnus.com \
    --cc=gdb-patches@sources.redhat.com \
    --cc=hunt@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