#include "gdb_assert.h"
#include "ppc-tdep.h"
#include "target.h"
+#include "objfiles.h"
+#include "infcall.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
starting from r4. */
CORE_ADDR
-ppc_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, CORE_ADDR func_addr,
+ppc_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
struct regcache *regcache, CORE_ADDR bp_addr,
int nargs, struct value **args, CORE_ADDR sp,
int struct_return, CORE_ADDR struct_addr)
the register's floating-point format. */
char regval[MAX_REGISTER_SIZE];
struct type *regtype
- = register_type (gdbarch, FP0_REGNUM + freg);
+ = register_type (gdbarch, tdep->ppc_fp0_regnum + freg);
convert_typed_floating (val, type, regval, regtype);
- regcache_cooked_write (regcache, FP0_REGNUM + freg,
+ regcache_cooked_write (regcache,
+ tdep->ppc_fp0_regnum + freg,
regval);
}
freg++;
/* Floats and doubles stored in "f1". Convert the value to
the required type. */
char regval[MAX_REGISTER_SIZE];
- struct type *regtype = register_type (gdbarch, FP0_REGNUM + 1);
- regcache_cooked_read (regcache, FP0_REGNUM + 1, regval);
+ struct type *regtype = register_type (gdbarch,
+ tdep->ppc_fp0_regnum + 1);
+ regcache_cooked_read (regcache, tdep->ppc_fp0_regnum + 1, regval);
convert_typed_floating (regval, regtype, readbuf, type);
}
if (writebuf)
/* Floats and doubles stored in "f1". Convert the value to
the register's "double" type. */
char regval[MAX_REGISTER_SIZE];
- struct type *regtype = register_type (gdbarch, FP0_REGNUM);
+ struct type *regtype = register_type (gdbarch, tdep->ppc_fp0_regnum);
convert_typed_floating (writebuf, type, regval, regtype);
- regcache_cooked_write (regcache, FP0_REGNUM + 1, regval);
+ regcache_cooked_write (regcache, tdep->ppc_fp0_regnum + 1, regval);
}
return RETURN_VALUE_REGISTER_CONVENTION;
}
greatly simplifies the logic. */
CORE_ADDR
-ppc64_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, CORE_ADDR func_addr,
+ppc64_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
struct regcache *regcache, CORE_ADDR bp_addr,
int nargs, struct value **args, CORE_ADDR sp,
int struct_return, CORE_ADDR struct_addr)
{
+ CORE_ADDR func_addr = find_function_addr (function, NULL);
struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
/* By this stage in the proceedings, SP has been decremented by "red
zone size" + "struct return size". Fetch the stack-pointer from
&& freg <= 13)
{
char regval[MAX_REGISTER_SIZE];
- struct type *regtype = register_type (gdbarch,
- FP0_REGNUM);
+ struct type *regtype
+ = register_type (gdbarch, tdep->ppc_fp0_regnum);
convert_typed_floating (val, type, regval, regtype);
- regcache_cooked_write (regcache, FP0_REGNUM + freg,
+ regcache_cooked_write (regcache,
+ tdep->ppc_fp0_regnum + freg,
regval);
}
if (greg <= 10)
".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);
+ }
}
}
}
const void *writebuf)
{
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+
+ /* This function exists to support a calling convention that
+ requires floating-point registers. It shouldn't be used on
+ processors that lack them. */
+ gdb_assert (ppc_floating_point_unit_p (gdbarch));
+
/* Floats and doubles in F1. */
if (TYPE_CODE (valtype) == TYPE_CODE_FLT && TYPE_LENGTH (valtype) <= 8)
{
char regval[MAX_REGISTER_SIZE];
- struct type *regtype = register_type (gdbarch, FP0_REGNUM);
+ struct type *regtype = register_type (gdbarch, tdep->ppc_fp0_regnum);
if (writebuf != NULL)
{
convert_typed_floating (writebuf, valtype, regval, regtype);
- regcache_cooked_write (regcache, FP0_REGNUM + 1, regval);
+ regcache_cooked_write (regcache, tdep->ppc_fp0_regnum + 1, regval);
}
if (readbuf != NULL)
{
- regcache_cooked_read (regcache, FP0_REGNUM + 1, regval);
+ regcache_cooked_read (regcache, tdep->ppc_fp0_regnum + 1, regval);
convert_typed_floating (regval, regtype, readbuf, valtype);
}
return RETURN_VALUE_REGISTER_CONVENTION;
for (i = 0; i < TYPE_LENGTH (valtype) / 8; i++)
{
if (writebuf != NULL)
- regcache_cooked_write (regcache, FP0_REGNUM + 1 + i,
+ regcache_cooked_write (regcache, tdep->ppc_fp0_regnum + 1 + i,
(const bfd_byte *) writebuf + i * 8);
if (readbuf != NULL)
- regcache_cooked_read (regcache, FP0_REGNUM + 1 + i,
+ regcache_cooked_read (regcache, tdep->ppc_fp0_regnum + 1 + i,
(bfd_byte *) readbuf + i * 8);
}
}
{
char regval[MAX_REGISTER_SIZE];
struct type *regtype =
- register_type (current_gdbarch, FP0_REGNUM);
+ register_type (current_gdbarch, tdep->ppc_fp0_regnum);
if (writebuf != NULL)
{
convert_typed_floating ((const bfd_byte *) writebuf +
i * (TYPE_LENGTH (valtype) / 2),
valtype, regval, regtype);
- regcache_cooked_write (regcache, FP0_REGNUM + 1 + i,
+ regcache_cooked_write (regcache,
+ tdep->ppc_fp0_regnum + 1 + i,
regval);
}
if (readbuf != NULL)
{
- regcache_cooked_read (regcache, FP0_REGNUM + 1 + i, regval);
+ regcache_cooked_read (regcache,
+ tdep->ppc_fp0_regnum + 1 + i,
+ regval);
convert_typed_floating (regval, regtype,
(bfd_byte *) readbuf +
i * (TYPE_LENGTH (valtype) / 2),
for (i = 0; i < 4; i++)
{
if (writebuf != NULL)
- regcache_cooked_write (regcache, FP0_REGNUM + 1 + i,
+ regcache_cooked_write (regcache, tdep->ppc_fp0_regnum + 1 + i,
(const bfd_byte *) writebuf + i * 8);
if (readbuf != NULL)
- regcache_cooked_read (regcache, FP0_REGNUM + 1 + i,
+ regcache_cooked_read (regcache, tdep->ppc_fp0_regnum + 1 + i,
(bfd_byte *) readbuf + i * 8);
}
}