From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24700 invoked by alias); 17 Dec 2004 06:52:52 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 24653 invoked from network); 17 Dec 2004 06:52:39 -0000 Received: from unknown (HELO smtp9.wanadoo.fr) (193.252.22.22) by sourceware.org with SMTP; 17 Dec 2004 06:52:39 -0000 Received: from me-wanadoo.net (localhost [127.0.0.1]) by mwinf0903.wanadoo.fr (SMTP Server) with SMTP id 0017A1C00182; Fri, 17 Dec 2004 07:52:38 +0100 (CET) Received: from takamaka.act-europe.fr (AStDenis-103-1-2-184.w81-249.abo.wanadoo.fr [81.249.112.184]) by mwinf0903.wanadoo.fr (SMTP Server) with ESMTP id 31AA41C0017C; Fri, 17 Dec 2004 07:52:38 +0100 (CET) Received: by takamaka.act-europe.fr (Postfix, from userid 507) id 649A947DAD; Fri, 17 Dec 2004 10:52:35 +0400 (RET) Date: Fri, 17 Dec 2004 07:15:00 -0000 From: Joel Brobecker To: Randolph Chung Cc: gdb-patches@sources.redhat.com Subject: Re: [RFA/hpux] SEGV when running program using dlopen Message-ID: <20041217065235.GE1146@adacore.com> References: <20041215073206.GM964@adacore.com> <20041215163628.GY29171@tausq.org> <20041215165738.GQ964@adacore.com> <20041215170602.GB29171@tausq.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="ew6BAiZeqk4r7MaW" Content-Disposition: inline In-Reply-To: <20041215170602.GB29171@tausq.org> User-Agent: Mutt/1.4i X-SW-Source: 2004-12/txt/msg00399.txt.bz2 --ew6BAiZeqk4r7MaW Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 659 > 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 * 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 --ew6BAiZeqk4r7MaW Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="solib.diff" Content-length: 3641 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); --ew6BAiZeqk4r7MaW--