From: "Kris Warkentin" <kewarken@qnx.com>
To: <gdb@sources.redhat.com>
Subject: relocation of shared libs not based at 0
Date: Tue, 17 Dec 2002 12:23:00 -0000 [thread overview]
Message-ID: <032c01c2a60a$2368a6e0$0202040a@catdog> (raw)
I recently came across a problem debugging a core file with some of our
older shared libs. Info shared showed the relocations of the shared libs to
be mangled (offset to 0x60... range rather than 0xb0... range). We had
recently changed our tools to always set the vaddr of shared libs to be zero
because of this but I was speaking to one of our architects and he says that
this shouldn't be.
One of the future optimizations we're looking at is pre-relocating shared
libs so that they can be executed in place (on flash for instance) and the
fact that the SysV stuff seems to assume that everything is based at zero is
not particularily compatable with that. I've attached an ugly patch that
shows a fix. This is for illustration only since solib.c is the wrong place
to put this but it makes it clear what the issue is.
Can anyone with more knowledge than I enlighten me as to a) whether it is
proper to allow shared objects to be non zero-based and b) a better way to
do this. I looked at putting it in solib-svr4.c but I don't have access to
the bfd in there, at least in svr4_relocate_section_addresses().
cheers,
Kris
Index: solib.c
===================================================================
RCS file: /product/tools/gdb/gdb/solib.c,v
retrieving revision 1.4
diff -c -r1.4 solib.c
*** solib.c 14 Nov 2002 20:57:23 -0000 1.4
--- solib.c 17 Dec 2002 20:10:14 -0000
***************
*** 26,31 ****
--- 26,34 ----
#include <fcntl.h>
#include "gdb_string.h"
#include "symtab.h"
+ #ifdef __QNXTARGET__
+ #include "elf-bfd.h"
+ #endif
#include "bfd.h"
#include "symfile.h"
#include "objfiles.h"
***************
*** 206,211 ****
--- 209,229 ----
expansion stuff?).
*/
+ #ifdef __QNXTARGET__
+ Elf_Internal_Phdr *find_load_phdr( bfd *abfd )
+ {
+ Elf32_Internal_Phdr *phdr;
+ unsigned int i;
+
+ phdr = elf_tdata (abfd)->phdr;
+ for (i = 0; i < elf_elfheader (abfd)->e_phnum; i++, phdr++) {
+ if (phdr->p_type == PT_LOAD && (phdr->p_flags & PF_X))
+ return phdr;
+ }
+ return NULL;
+ }
+ #endif
+
static int
solib_map_sections (PTR arg)
{
***************
*** 263,268 ****
--- 281,296 ----
object's file by the base address to which the object was
actually
mapped. */
TARGET_SO_RELOCATE_SECTION_ADDRESSES (so, p);
+ #ifdef __QNXTARGET__
+ /* hack for solibs not based at 0 */
+ {
+ Elf32_Internal_Phdr *phdr = find_load_phdr(abfd);
+ if(phdr){
+ p->addr -= phdr->p_vaddr;
+ p->endaddr -= phdr->p_vaddr;
+ }
+ }
+ #endif
if (STREQ (p->the_bfd_section->name, ".text"))
{
so->textsection = p;
next reply other threads:[~2002-12-17 20:23 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-12-17 12:23 Kris Warkentin [this message]
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
2002-12-17 13:39 David Anderson
2003-02-12 18:37 Peter van der Veen
2004-01-05 17:39 Paul Koning
2004-01-09 22:48 ` Kevin Buettner
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='032c01c2a60a$2368a6e0$0202040a@catdog' \
--to=kewarken@qnx.com \
--cc=gdb@sources.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