summaryrefslogtreecommitdiff
path: root/gdb/rs6000-nat.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/rs6000-nat.c')
-rw-r--r--gdb/rs6000-nat.c54
1 files changed, 32 insertions, 22 deletions
diff --git a/gdb/rs6000-nat.c b/gdb/rs6000-nat.c
index 63fadcf9616..133269c826d 100644
--- a/gdb/rs6000-nat.c
+++ b/gdb/rs6000-nat.c
@@ -357,9 +357,9 @@ vmap_symtab (vp)
/* The symbols in the object file are linked to the VMA of the section,
relocate them VMA relative. */
- ANOFFSET (new_offsets, SECT_OFF_TEXT) = vp->tstart - vp->tvma;
- ANOFFSET (new_offsets, SECT_OFF_DATA) = vp->dstart - vp->dvma;
- ANOFFSET (new_offsets, SECT_OFF_BSS) = vp->dstart - vp->dvma;
+ ANOFFSET (new_offsets, SECT_OFF_TEXT (objfile)) = vp->tstart - vp->tvma;
+ ANOFFSET (new_offsets, SECT_OFF_DATA (objfile)) = vp->dstart - vp->dvma;
+ ANOFFSET (new_offsets, SECT_OFF_BSS (objfile)) = vp->dstart - vp->dvma;
objfile_relocate (objfile, new_offsets);
}
@@ -639,29 +639,39 @@ void
xcoff_relocate_symtab (pid)
unsigned int pid;
{
-#define MAX_LOAD_SEGS 64 /* maximum number of load segments */
+ int load_segs = 64; /* number of load segments */
+ int rc;
+ struct ld_info *ldi = NULL;
- struct ld_info *ldi;
-
- ldi = (void *) alloca (MAX_LOAD_SEGS * sizeof (*ldi));
-
- /* According to my humble theory, AIX has some timing problems and
- when the user stack grows, kernel doesn't update stack info in time
- and ptrace calls step on user stack. That is why we sleep here a little,
- and give kernel to update its internals. */
-
- usleep (36000);
+ do
+ {
+ ldi = (void *) xrealloc (ldi, load_segs * sizeof (*ldi));
- errno = 0;
- ptrace (PT_LDINFO, pid, (PTRACE_ARG3_TYPE) ldi,
- MAX_LOAD_SEGS * sizeof (*ldi), (int *) ldi);
- if (errno)
- perror_with_name ("ptrace ldinfo");
+ /* According to my humble theory, AIX has some timing problems and
+ when the user stack grows, kernel doesn't update stack info in time
+ and ptrace calls step on user stack. That is why we sleep here a
+ little, and give kernel to update its internals. */
- vmap_ldinfo (ldi);
+ usleep (36000);
- /* relocate the exec and core sections as well. */
- vmap_exec ();
+ errno = 0;
+ rc = ptrace (PT_LDINFO, pid, (PTRACE_ARG3_TYPE) ldi,
+ load_segs * sizeof (*ldi), (int *) ldi);
+ if (rc == -1)
+ {
+ if (errno == ENOMEM)
+ load_segs *= 2;
+ else
+ perror_with_name ("ptrace ldinfo");
+ }
+ else
+ {
+ vmap_ldinfo (ldi);
+ vmap_exec (); /* relocate the exec and core sections as well. */
+ }
+ } while (rc == -1);
+ if (ldi)
+ free (ldi);
}
/* Core file stuff. */