From: Kevin Buettner <kevinb@redhat.com>
To: Paul Koning <pkoning@equallogic.com>, gdb@sources.redhat.com
Subject: Re: relocation of shared libs not based at 0
Date: Fri, 09 Jan 2004 22:48:00 -0000 [thread overview]
Message-ID: <1040109224820.ZM14159@localhost.localdomain> (raw)
In-Reply-To: Paul Koning <pkoning@equallogic.com> "RE: relocation of shared libs not based at 0" (Jan 5, 12:39pm)
On Jan 5, 12:39pm, Paul Koning wrote:
> So the real answer is simple: the LM_ADDR entries have to be adjusted
> by the as-linked start VMA of the library. The only problem I ran
> into is that I couldn't find a clean way to obtain that value in gdb.
> I did come up with something that worked; if there are better ways to
> do this I would be interested.
>
> My fix is in a modified 5.3, but the relevant source is unchanged from
> 5.3 to 6.0. So attached is a diff for 6.0 that shows the fix I
> described.
>
> paul
>
> --- gdb/solib-svr4.c.orig Fri Jun 13 17:56:27 2003
> +++ gdb/solib-svr4.c Mon Jan 5 12:29:49 2004
> @@ -1375,8 +1375,29 @@
> svr4_relocate_section_addresses (struct so_list *so,
> struct section_table *sec)
> {
> - sec->addr = svr4_truncate_ptr (sec->addr + LM_ADDR (so));
> - sec->endaddr = svr4_truncate_ptr (sec->endaddr + LM_ADDR (so));
> + CORE_ADDR reloc;
> +
> + /* On NetBSD/MIPS at least, the library is mapped in two pieces.
> + The section headers describe this: each shows the unrelocated
> + virtual address of the section. To figure out the relocated
> + address, we have to adjust these by the base VMA of the library.
> +
> + There isn't a really clean way to figure out the offset of each
> + section. "filepos" doesn't do it, because that is the
> + file-relative offset, not the VMA offset.
> +
> + So what we do is this:
> + Pick up the VMA (given by the header) of the first section,
> + and subtract from that its filepos. That's the unrelocated VMA
> + of the library. Subtract that from the unrelocated VMA
> + of each section to get its relocation bias; add that to the
> + library load address to get the relocated address.
> + */
> + reloc = so->sections->the_bfd_section->vma -
> + so->sections->the_bfd_section->filepos;
> +
> + sec->endaddr = svr4_truncate_ptr (sec->endaddr - reloc + LM_ADDR (so));
> + sec->addr = svr4_truncate_ptr (sec->addr - reloc + LM_ADDR (so));
> }
I think something along these lines will be okay. It may even be okay
as is. I need to study the relationship between "vma" and "filepos"
to convince myself that it's okay.
I'll be very busy with other matters for the next couple of weeks. Would
you mind pinging me in a few weeks?
In the interim, I'd like to find out what the QNX folks think of this
patch. As I recall, QNX behaved in a similar fashion to NetBSD and
I'm wondering if Paul's patch would address those problems as well.
Kevin
next prev parent reply other threads:[~2004-01-09 22:48 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-01-05 17:39 Paul Koning
2004-01-09 22:48 ` Kevin Buettner [this message]
-- strict thread matches above, loose matches on Subject: below --
2003-02-12 18:37 Peter van der Veen
2002-12-17 13:39 David Anderson
2002-12-17 12:23 Kris Warkentin
2002-12-17 12:31 ` Paul Koning
2002-12-17 13:36 ` Kris Warkentin
2002-12-17 16:28 ` Kevin Buettner
2002-12-17 16:47 ` Paul Koning
2003-01-08 21:52 ` Kris Warkentin
2003-01-08 22:24 ` Kevin Buettner
2003-01-09 14:35 ` Colin Burgess
2003-01-09 15:06 ` Kris Warkentin
2003-02-05 18:40 ` Paul Koning
2003-02-05 19:08 ` Kris Warkentin
2003-02-05 19:11 ` Kevin Buettner
2003-02-10 21:45 ` Paul Koning
2003-02-12 18:06 ` Kevin Buettner
2003-02-12 18:19 ` Kris Warkentin
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=1040109224820.ZM14159@localhost.localdomain \
--to=kevinb@redhat.com \
--cc=gdb@sources.redhat.com \
--cc=pkoning@equallogic.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