aboutsummaryrefslogtreecommitdiff
path: root/gdb/rs6000-nat.c
diff options
context:
space:
mode:
authorPeter Schauer <Peter.Schauer@mytum.de>1997-08-15 21:10:32 +0000
committerPeter Schauer <Peter.Schauer@mytum.de>1997-08-15 21:10:32 +0000
commit05d52ace86cc898264acb8f23a97e22cb199ed36 (patch)
treee0051a3c2ad0d9ef0f486531f446b7b58a56774a /gdb/rs6000-nat.c
parentbe3d1b6f9e44f02435baac46febfe810a724b6d9 (diff)
downloadgdb-05d52ace86cc898264acb8f23a97e22cb199ed36.zip
gdb-05d52ace86cc898264acb8f23a97e22cb199ed36.tar.gz
gdb-05d52ace86cc898264acb8f23a97e22cb199ed36.tar.bz2
* infrun.c (wait_for_inferior): Add the symbols for any
newly loaded objects upon a TARGET_WAITKIND_LOADED event. Rewrite code which determines the TOC address for calling functions in the inferior under AIX. * rs6000-nat.c (find_toc_address): New function to determine the required TOC address from a function address. (_initialize_core_rs6000): Set up find_toc_address_hook to point to find_toc_address. (xcoff_relocate_symtab, xcoff_relocate_core): Remove add_text_to_loadinfo calls. (exec_one_dummy_insn): Change pid and status to int to get rid of compiler warnings. (xcoff_relocate_symtab): Cast ldi to `int *' when passing it to ptrace to get rid of compiler warnings. * rs6000-tdep.c: Add definition for find_toc_address_hook. (rs6000_fix_call_dummy): If find_toc_address_hook is non zero, patch TOC address load code in the call dummy with the value returned from find_toc_address_hook. (struct loadinfo, loadinfo, loadinfolen, loadinfotextindex, xcoff_init_loadinfo, free_loadinfo, xcoff_add_toc_to_loadinfo, add_text_to_loadinfo, find_toc_address): Remove. (_initialize_rs6000_tdep): Remove initialization of coff_add_toc_to_loadinfo_hook and xcoff_init_loadinfo_hook. * xcoffread.c (coff_add_toc_to_loadinfo_hook, xcoff_init_loadinfo_hook): Remove. (struct coff_symfile_info): Add toc_offset field. (scan_xcoff_symtab): Record toc_offset value in toc_offset field instead of calling xcoff_add_toc_to_loadinfo_hook. (get_toc_offset): New function to return the value of the toc_offset field for an object file. (xcoff_initial_scan): Remove call of xcoff_init_loadinfo_hook. * xcoffsolib.h (add_text_to_loadinfo): Remove declaration. * config/rs6000/tm-rs6000.h: Add declarations for find_toc_address_hook and get_toc_offset.
Diffstat (limited to 'gdb/rs6000-nat.c')
-rw-r--r--gdb/rs6000-nat.c50
1 files changed, 29 insertions, 21 deletions
diff --git a/gdb/rs6000-nat.c b/gdb/rs6000-nat.c
index 7311055..b57054f 100644
--- a/gdb/rs6000-nat.c
+++ b/gdb/rs6000-nat.c
@@ -73,9 +73,6 @@ static void
exec_one_dummy_insn PARAMS ((void));
extern void
-add_text_to_loadinfo PARAMS ((CORE_ADDR textaddr, CORE_ADDR dataaddr));
-
-extern void
fixup_breakpoints PARAMS ((CORE_ADDR low, CORE_ADDR high, CORE_ADDR delta));
/* Conversion from gdb-to-system special purpose register numbers.. */
@@ -248,7 +245,7 @@ exec_one_dummy_insn ()
#define DUMMY_INSN_ADDR (TEXT_SEGMENT_BASE)+0x200
char shadow_contents[BREAKPOINT_MAX]; /* Stash old bkpt addr contents */
- unsigned int status, pid;
+ int status, pid;
CORE_ADDR prev_pc;
/* We plant one dummy breakpoint into DUMMY_INSN_ADDR address. We assume that
@@ -623,25 +620,12 @@ xcoff_relocate_symtab (pid)
errno = 0;
ptrace (PT_LDINFO, pid, (PTRACE_ARG3_TYPE) ldi,
- MAX_LOAD_SEGS * sizeof(*ldi), ldi);
+ MAX_LOAD_SEGS * sizeof(*ldi), (int *) ldi);
if (errno)
perror_with_name ("ptrace ldinfo");
vmap_ldinfo (ldi);
- do {
- /* We are allowed to assume CORE_ADDR == pointer. This code is
- native only. */
- add_text_to_loadinfo ((CORE_ADDR) ldi->ldinfo_textorg,
- (CORE_ADDR) ldi->ldinfo_dataorg);
- } while (ldi->ldinfo_next
- && (ldi = (void *) (ldi->ldinfo_next + (char *) ldi)));
-
-#if 0
- /* Now that we've jumbled things around, re-sort them. */
- sort_minimal_symbols ();
-#endif
-
/* relocate the exec and core sections as well. */
vmap_exec ();
}
@@ -780,9 +764,6 @@ xcoff_relocate_core (target)
}
vmap_symtab (vp);
-
- add_text_to_loadinfo ((CORE_ADDR)ldip->ldinfo_textorg,
- (CORE_ADDR)ldip->ldinfo_dataorg);
} while (ldip->ldinfo_next != 0);
vmap_exec ();
breakpoint_re_set ();
@@ -794,7 +775,30 @@ kernel_u_size ()
{
return (sizeof (struct user));
}
+
+/* Under AIX, we have to pass the correct TOC pointer to a function
+ when calling functions in the inferior.
+ We try to find the relative toc offset of the objfile containing PC
+ and add the current load address of the data segment from the vmap. */
+
+static CORE_ADDR
+find_toc_address (pc)
+ CORE_ADDR pc;
+{
+ struct vmap *vp;
+ for (vp = vmap; vp; vp = vp->nxt)
+ {
+ if (pc >= vp->tstart && pc < vp->tend)
+ {
+ /* vp->objfile is only NULL for the exec file. */
+ return vp->dstart + get_toc_offset (vp->objfile == NULL
+ ? symfile_objfile
+ : vp->objfile);
+ }
+ }
+ error ("Unable to find TOC entry for pc 0x%x\n", pc);
+}
/* Register that we are able to handle rs6000 core file formats. */
@@ -808,6 +812,10 @@ static struct core_fns rs6000_core_fns =
void
_initialize_core_rs6000 ()
{
+ /* Initialize hook in rs6000-tdep.c for determining the TOC address when
+ calling functions in the inferior. */
+ find_toc_address_hook = &find_toc_address;
+
/* For native configurations, where this module is included, inform
the xcoffsolib module where it can find the function for symbol table
relocation at runtime. */