2003-11-14 Andrew Cagney <cagney@redhat.com>
authorAndrew Cagney <cagney@redhat.com>
Fri, 14 Nov 2003 14:34:30 +0000 (14:34 +0000)
committerAndrew Cagney <cagney@redhat.com>
Fri, 14 Nov 2003 14:34:30 +0000 (14:34 +0000)
* Makefile.in (ppc-sysv-tdep.o): Update dependencies.
* ppc-sysv-tdep.c: Include "objfiles.h".
(ppc64_sysv_abi_push_dummy_call): Provide the
the FN's objfile when looking for the descriptor.

gdb/ChangeLog
gdb/ppc-sysv-tdep.c

index 2783ba6a70be768b7758867401cd8818e32fc0de..f640614c396dadeb4abd4659ce8eb34b611fbdf2 100644 (file)
@@ -1,4 +1,9 @@
-2003-11-13  Andrew Cagney  <cagney@redhat.com>
+2003-11-14  Andrew Cagney  <cagney@redhat.com>
+
+       * Makefile.in (ppc-sysv-tdep.o): Update dependencies.
+       * ppc-sysv-tdep.c: Include "objfiles.h".
+       (ppc64_sysv_abi_push_dummy_call): Provide the
+       the FN's objfile when looking for the descriptor.
 
        * ppc-linux-tdep.c (ppc_linux_init_abi): Set PPC64's
        "name_of_malloc" to ".malloc".
index 01438c159a288efdb2810f14eb3c7f81832abf42..60cf986bd72e660fdd143af663452c93cedd581c 100644 (file)
@@ -29,6 +29,7 @@
 #include "gdb_assert.h"
 #include "ppc-tdep.h"
 #include "target.h"
+#include "objfiles.h"
 
 /* Pass the arguments in either registers, or in the stack. Using the
    ppc sysv ABI, the first eight words of the argument list (that might
@@ -790,27 +791,38 @@ ppc64_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, CORE_ADDR func_addr,
      ".FN" and "FN" in the minimal symbol table.  "FN" points at the
      FN's descriptor, while ".FN" points at the entry point (which
      matches FUNC_ADDR).  Need to reverse from FUNC_ADDR back to the
-     FN's descriptor address.  */
+     FN's descriptor address (while at the same time being careful to
+     find "FN" in the same object file as ".FN").  */
   {
     /* Find the minimal symbol that corresponds to FUNC_ADDR (should
        have the name ".FN").  */
     struct minimal_symbol *dot_fn = lookup_minimal_symbol_by_pc (func_addr);
     if (dot_fn != NULL && SYMBOL_LINKAGE_NAME (dot_fn)[0] == '.')
       {
-       /* Now find the corresponding "FN" (dropping ".") minimal
-          symbol's address.  */
-       struct minimal_symbol *fn =
-         lookup_minimal_symbol (SYMBOL_LINKAGE_NAME (dot_fn) + 1, NULL,
-                                NULL);
-       if (fn != NULL)
+       /* Get the section that contains FUNC_ADR.  Need this for the
+           "objfile" that it contains.  */
+       struct obj_section *dot_fn_section = find_pc_section (func_addr);
+       if (dot_fn_section != NULL && dot_fn_section->objfile != NULL)
          {
-           /* Got the address of that descriptor.  The TOC is the
-              second double word.  */
-           CORE_ADDR toc =
-             read_memory_unsigned_integer (SYMBOL_VALUE_ADDRESS (fn) +
-                                           tdep->wordsize, tdep->wordsize);
-           regcache_cooked_write_unsigned (regcache,
-                                           tdep->ppc_gp0_regnum + 2, toc);
+           /* Now find the corresponding "FN" (dropping ".") minimal
+              symbol's address.  Only look for the minimal symbol in
+              ".FN"'s object file - avoids problems when two object
+              files (i.e., shared libraries) contain a minimal symbol
+              with the same name.  */
+           struct minimal_symbol *fn =
+             lookup_minimal_symbol (SYMBOL_LINKAGE_NAME (dot_fn) + 1, NULL,
+                                    dot_fn_section->objfile);
+           if (fn != NULL)
+             {
+               /* Got the address of that descriptor.  The TOC is the
+                  second double word.  */
+               CORE_ADDR toc =
+                 read_memory_unsigned_integer (SYMBOL_VALUE_ADDRESS (fn)
+                                               + tdep->wordsize,
+                                               tdep->wordsize);
+               regcache_cooked_write_unsigned (regcache,
+                                               tdep->ppc_gp0_regnum + 2, toc);
+             }
          }
       }
   }
This page took 0.032419 seconds and 4 git commands to generate.