Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Joel Brobecker <brobecker@adacore.com>
To: Randolph Chung <tausq@debian.org>
Cc: gdb-patches@sources.redhat.com
Subject: Re: [RFA/hpux] SEGV when running program using dlopen
Date: Fri, 17 Dec 2004 07:15:00 -0000	[thread overview]
Message-ID: <20041217065235.GE1146@adacore.com> (raw)
In-Reply-To: <20041215170602.GB29171@tausq.org>

[-- Attachment #1: Type: text/plain, Size: 659 bytes --]

> ok, thanks. your patch looks good; i'm still wondering if we should have
> unified logic to search for (export|import) stubs... but that's for
> later.

How is the following?

2004-12-17  Joel Brobecker  <brobecker@gnat.com>

        * hppa-tdep.c (hppa_lookup_stub_minimal_symbol): New function.
        * hppa-tdep.h (hppa_lookup_stub_minimal_symbol): Add declaration.
        * solib-som.c (som_solib_create_inferior_hook): Replace stub
        msymbol search by call to hppa_lookup_stub_minimal_symbol. This
        extends the search to all objfiles, not just shared libraries.
        Remove unused variable.

Tested on HP/UX 11.00.

Thanks,
-- 
Joel

[-- Attachment #2: solib.diff --]
[-- Type: text/plain, Size: 3641 bytes --]

Index: hppa-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/hppa-tdep.c,v
retrieving revision 1.192
diff -u -p -r1.192 hppa-tdep.c
--- hppa-tdep.c	14 Dec 2004 16:35:37 -0000	1.192
+++ hppa-tdep.c	17 Dec 2004 06:49:05 -0000
@@ -2255,6 +2255,31 @@ hppa_unwind_pc (struct gdbarch *gdbarch,
   return pc & ~0x3;
 }
 
+/* Return the minimal symbol whose name is NAME and stub type is STUB_TYPE.
+   Return NULL if no such symbol was found.  */
+
+extern struct minimal_symbol *
+hppa_lookup_stub_minimal_symbol (const char *name,
+                                 enum unwind_stub_types stub_type)
+{
+  struct objfile *objfile;
+  struct minimal_symbol *msym;
+
+  ALL_MSYMBOLS (objfile, msym)
+    {
+      if (strcmp (SYMBOL_LINKAGE_NAME (msym), name) == 0)
+        {
+          struct unwind_table_entry *u;
+
+          u = find_unwind_entry (SYMBOL_VALUE (msym));
+          if (u != NULL && u->stub_unwind.stub_type == stub_type)
+            return msym;
+        }
+    }
+
+  return NULL;
+}
+
 /* Instead of this nasty cast, add a method pvoid() that prints out a
    host VOID data type (remember %p isn't portable).  */
 
Index: hppa-tdep.h
===================================================================
RCS file: /cvs/src/src/gdb/hppa-tdep.h,v
retrieving revision 1.17
diff -u -p -r1.17 hppa-tdep.h
--- hppa-tdep.h	13 Dec 2004 04:06:15 -0000	1.17
+++ hppa-tdep.h	17 Dec 2004 06:49:05 -0000
@@ -231,4 +231,8 @@ extern void hppa_write_pc (CORE_ADDR pc,
 extern CORE_ADDR hppa_unwind_pc (struct gdbarch *gdbarch,
 				 struct frame_info *next_frame);
 
+extern struct minimal_symbol *
+  hppa_lookup_stub_minimal_symbol (const char *name,
+                                   enum unwind_stub_types stub_type);
+
 #endif  /* HPPA_TDEP_H */
Index: solib-som.c
===================================================================
RCS file: /cvs/src/src/gdb/solib-som.c,v
retrieving revision 1.1
diff -u -p -r1.1 solib-som.c
--- solib-som.c	8 Dec 2004 01:36:42 -0000	1.1
+++ solib-som.c	17 Dec 2004 06:49:06 -0000
@@ -161,7 +161,6 @@ som_solib_create_inferior_hook (void)
   unsigned int dld_flags, status, have_endo;
   asection *shlib_info;
   char buf[4];
-  struct objfile *objfile;
   CORE_ADDR anaddr;
 
   /* First, remove all the solib event breakpoints.  Their addresses
@@ -226,33 +225,13 @@ som_solib_create_inferior_hook (void)
 
   /* Grrr, this might not be an export symbol!  We have to find the
      export stub.  */
-  ALL_OBJFILES (objfile)
-  {
-    struct unwind_table_entry *u;
-    struct minimal_symbol *msymbol2;
-
-    /* What a crock.  */
-    msymbol2 =
-      lookup_minimal_symbol_solib_trampoline (SYMBOL_LINKAGE_NAME (msymbol),
-					      objfile);
-    /* Found a symbol with the right name.  */
-    if (msymbol2)
-      {
-	struct unwind_table_entry *u;
-	/* It must be a shared library trampoline.  */
-	if (SYMBOL_TYPE (msymbol2) != mst_solib_trampoline)
-	  continue;
-
-	/* It must also be an export stub.  */
-	u = find_unwind_entry (SYMBOL_VALUE (msymbol2));
-	if (!u || u->stub_unwind.stub_type != EXPORT)
-	  continue;
-
-	/* OK.  Looks like the correct import stub.  */
-	anaddr = SYMBOL_VALUE (msymbol2);
-	dld_cache.hook_stub.address = anaddr;
-      }
-  }
+  msymbol = hppa_lookup_stub_minimal_symbol (SYMBOL_LINKAGE_NAME (msymbol),
+                                             EXPORT);
+  if (msymbol != NULL)
+    {
+      anaddr = SYMBOL_VALUE (msymbol);
+      dld_cache.hook_stub.address = anaddr;
+    }
   store_unsigned_integer (buf, 4, anaddr);
 
   msymbol = lookup_minimal_symbol ("__dld_hook", NULL, symfile_objfile);

  parent reply	other threads:[~2004-12-17  6:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-12-15  9:20 Joel Brobecker
2004-12-15 17:14 ` Randolph Chung
2004-12-15 17:23   ` Joel Brobecker
2004-12-15 17:27     ` Randolph Chung
2004-12-15 18:29       ` Joel Brobecker
2004-12-17  7:15       ` Joel Brobecker [this message]
2004-12-17  7:44         ` Randolph Chung
2004-12-17 19:22           ` Joel Brobecker

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=20041217065235.GE1146@adacore.com \
    --to=brobecker@adacore.com \
    --cc=gdb-patches@sources.redhat.com \
    --cc=tausq@debian.org \
    /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