* [rfa:ppc64] Get descriptor FN from the same object file as symbol ".FN"
@ 2003-11-14 0:25 Andrew Cagney
2003-11-14 1:15 ` Kevin Buettner
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Cagney @ 2003-11-14 0:25 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 488 bytes --]
Hello,
The attached tweaks the tail end of the ppc64_sysv_abi_push_dummy_call
code so that it restricts the search for the descriptor FN (that
corresponds to function ".FN") to the object file that contains ".FN".
Given shared libraries, several object files can contain the same symbol
so searching for an unqualified "FN" can end up finding the descriptor
in the wrong shared library :-(. This problem occures when trying to go
backwards from ".malloc" to "malloc".
ok?
Andrew
[-- Attachment #2: diffs --]
[-- Type: text/plain, Size: 3015 bytes --]
2003-11-13 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.
Index: ppc-sysv-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/ppc-sysv-tdep.c,v
retrieving revision 1.20
diff -u -r1.20 ppc-sysv-tdep.c
--- ppc-sysv-tdep.c 10 Nov 2003 22:47:28 -0000 1.20
+++ ppc-sysv-tdep.c 14 Nov 2003 00:11:37 -0000
@@ -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 @@
".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);
+ }
}
}
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [rfa:ppc64] Get descriptor FN from the same object file as symbol ".FN"
2003-11-14 0:25 [rfa:ppc64] Get descriptor FN from the same object file as symbol ".FN" Andrew Cagney
@ 2003-11-14 1:15 ` Kevin Buettner
2003-11-14 14:35 ` Andrew Cagney
0 siblings, 1 reply; 3+ messages in thread
From: Kevin Buettner @ 2003-11-14 1:15 UTC (permalink / raw)
To: Andrew Cagney, gdb-patches
On Nov 13, 7:24pm, Andrew Cagney wrote:
> The attached tweaks the tail end of the ppc64_sysv_abi_push_dummy_call
> code so that it restricts the search for the descriptor FN (that
> corresponds to function ".FN") to the object file that contains ".FN".
> Given shared libraries, several object files can contain the same symbol
> so searching for an unqualified "FN" can end up finding the descriptor
> in the wrong shared library :-(. This problem occures when trying to go
> backwards from ".malloc" to "malloc".
>
> 2003-11-13 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.
Okay.
Kevin
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [rfa:ppc64] Get descriptor FN from the same object file as symbol ".FN"
2003-11-14 1:15 ` Kevin Buettner
@ 2003-11-14 14:35 ` Andrew Cagney
0 siblings, 0 replies; 3+ messages in thread
From: Andrew Cagney @ 2003-11-14 14:35 UTC (permalink / raw)
To: Kevin Buettner; +Cc: Andrew Cagney, gdb-patches
>
> Okay.
>
Committed. On PPC64 GNU/Linux,
(gdb) print "string"
should now work.
Andrew
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-11-14 14:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-11-14 0:25 [rfa:ppc64] Get descriptor FN from the same object file as symbol ".FN" Andrew Cagney
2003-11-14 1:15 ` Kevin Buettner
2003-11-14 14:35 ` Andrew Cagney
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox