aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog9
-rw-r--r--gdb/objfiles.c5
-rw-r--r--gdb/objfiles.h35
-rw-r--r--gdb/printcmd.c30
-rw-r--r--gdb/sparc-tdep.c11
-rw-r--r--gdb/symfile.c6
-rw-r--r--gdb/xcoffexec.c39
7 files changed, 110 insertions, 25 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index b9caec4..6ed8958 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,14 @@
Thu Apr 22 09:07:24 1993 Jim Kingdon (kingdon@cygnus.com)
+ * objfiles.h (obj_section), objfiles.c (build_objfile_section_table):
+ Add objfile field.
+ * objfiles.c (find_pc_section): Return a struct obj_section *.
+ * sparc-tdep.c (in_solib_trampoline): Deal with find_pc_section return.
+ * symfile.c (syms_from_objfile) [IBM6000_TARGET]:
+ Don't use obj_section hack.
+ * xcoffexec (vmap_symtab): Relocate obj_sections.
+ * printcmd.c (containing_function_bounds): Use find_pc_section.
+
* symtab.h: Clean up SYMBOL_VALUE comments.
Wed Apr 21 14:29:57 1993 Jim Kingdon (kingdon@cygnus.com)
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index 94b5f57..ac238ab 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -81,6 +81,7 @@ add_to_objfile_sections (abfd, asect, objfile_p_char)
if (0 == bfd_section_size (abfd, asect))
return;
section.offset = 0;
+ section.objfile = objfile;
section.sec_ptr = asect;
section.addr = bfd_section_vma (abfd, asect);
section.endaddr = section.addr + bfd_section_size (abfd, asect);
@@ -715,7 +716,7 @@ map_to_address ()
/* Returns a section whose range includes PC or NULL if none found. */
-sec_ptr
+struct obj_section *
find_pc_section(pc)
CORE_ADDR pc;
{
@@ -726,7 +727,7 @@ find_pc_section(pc)
for (s = objfile->sections; s < objfile->sections_end; ++s)
if (s->addr <= pc
&& pc < s->endaddr)
- return(s->sec_ptr);
+ return(s);
return(NULL);
}
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index 3cc5de1..3912999 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -114,16 +114,39 @@ struct entry_info
};
-/* This structure is used to map pc values into sections. Note that
- offset is currently target independent and is redundant to the
- section_offsets field in the objfile struct. FIXME. */
+/* Sections in an objfile.
+
+ It is strange that we have both this notion of "sections"
+ and the one used by section_offsets. Section as used
+ here, (currently at least) means a BFD section, and the sections
+ are set up from the BFD sections in allocate_objfile.
+
+ The sections in section_offsets have their meaning determined by
+ the symbol format, and they are set up by the sym_offsets function
+ for that symbol file format.
+
+ I'm not sure this could or should be changed, however. */
struct obj_section {
CORE_ADDR addr; /* lowest address in section */
CORE_ADDR endaddr; /* 1+highest address in section */
- CORE_ADDR offset; /* offset between (end)addr and actual
- memory addresses. */
+
+ /* This field is being used for nefarious purposes by syms_from_objfile.
+ It is said to be redundant with section_offsets; it's not really being
+ used that way, however, it's some sort of hack I don't understand
+ and am not going to try to eliminate (yet, anyway). FIXME.
+
+ It was documented as "offset between (end)addr and actual memory
+ addresses", but that's not true; addr & endaddr are actual memory
+ addresses. */
+ CORE_ADDR offset;
+
sec_ptr sec_ptr; /* BFD section pointer */
+
+ /* Objfile this section is part of. Not currently used, but I'm sure
+ that someone will want the bfd that the sec_ptr goes with or something
+ like that before long. */
+ struct objfile *objfile;
};
/* Master structure for keeping track of each input file from which
@@ -353,7 +376,7 @@ have_full_symbols PARAMS ((void));
extern int
have_minimal_symbols PARAMS ((void));
-extern sec_ptr
+extern struct obj_section *
find_pc_section PARAMS((CORE_ADDR pc));
/* Traverse all object files. ALL_OBJFILES_SAFE works even if you delete
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index 1b855a4..298de93 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -31,6 +31,12 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "breakpoint.h"
#include "demangle.h"
+/* These are just for containing_function_bounds. It might be better
+ to move containing_function_bounds to blockframe.c or thereabouts. */
+#include "bfd.h"
+#include "symfile.h"
+#include "objfiles.h"
+
extern int asm_demangle; /* Whether to demangle syms in asm printouts */
extern int addressprint; /* Whether to print hex addresses in HLL " */
@@ -1846,18 +1852,28 @@ static int
containing_function_bounds (pc, low, high)
CORE_ADDR pc, *low, *high;
{
- int scan;
+ CORE_ADDR scan;
+ CORE_ADDR limit;
+ struct obj_section *sec;
if (!find_pc_partial_function (pc, 0, low))
return 0;
+ sec = find_pc_section (pc);
+ if (sec == NULL)
+ return 0;
+ limit = sec->endaddr;
+
scan = *low;
- do {
- scan++;
- if (!find_pc_partial_function (scan, 0, high))
- return 0;
- } while (*low == *high);
-
+ while (scan < limit)
+ {
+ ++scan;
+ if (!find_pc_partial_function (scan, 0, high))
+ return 0;
+ if (*low != *high)
+ return 1;
+ }
+ *high = limit;
return 1;
}
diff --git a/gdb/sparc-tdep.c b/gdb/sparc-tdep.c
index 61af732..5799c4e 100644
--- a/gdb/sparc-tdep.c
+++ b/gdb/sparc-tdep.c
@@ -23,7 +23,9 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "obstack.h"
#include "target.h"
#include "ieee-float.h"
-#include "symfile.h" /* for find_pc_section */
+
+#include "symfile.h" /* for objfiles.h */
+#include "objfiles.h" /* for find_pc_section */
#ifdef USE_PROC_FS
#include <sys/procfs.h>
@@ -840,22 +842,19 @@ get_longjmp_target(pc)
/* So far used only for sparc solaris. In sparc solaris, we recognize
a trampoline by it's section name. That is, if the pc is in a
- section named ".plt" then we are in a trampline.
-
- Section and offset tracking belongs in objfiles. FIXME. */
+ section named ".plt" then we are in a trampline. */
int
in_solib_trampoline(pc, name)
CORE_ADDR pc;
char *name;
{
- struct section_table *s;
+ sec_ptr s;
int retval = 0;
s = find_pc_section(pc);
retval = (s != NULL
- && s->sec_ptr != NULL
&& s->sec_ptr->name != NULL
&& STREQ (s->sec_ptr->name, ".plt"));
return(retval);
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 7a29fa6..ec582da 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -442,6 +442,11 @@ syms_from_objfile (objfile, addr, mainline, verbo)
section_offsets = (*objfile -> sf -> sym_offsets) (objfile, addr);
objfile->section_offsets = section_offsets;
+#ifndef IBM6000_TARGET
+ /* This is a SVR4/SunOS specific hack, I think. In any event, it
+ screws RS/6000. sym_offsets should be doing this sort of thing,
+ because it knows the mapping between bfd sections and
+ section_offsets. */
/* This is a hack. As far as I can tell, section offsets are not
target dependent. They are all set to addr with a couple of
exceptions. The exceptions are sysvr4 shared libraries, whose
@@ -469,6 +474,7 @@ syms_from_objfile (objfile, addr, mainline, verbo)
s->offset += addr;
}
}
+#endif /* not IBM6000_TARGET */
(*objfile -> sf -> sym_read) (objfile, section_offsets, mainline);
diff --git a/gdb/xcoffexec.c b/gdb/xcoffexec.c
index c965488..cfc6a78 100644
--- a/gdb/xcoffexec.c
+++ b/gdb/xcoffexec.c
@@ -312,7 +312,9 @@ vmap_symtab (vp)
asection *textsec;
asection *datasec;
asection *bsssec;
- CORE_ADDR old_text_offset;
+ CORE_ADDR text_delta;
+ CORE_ADDR data_delta;
+ CORE_ADDR bss_delta;
struct section_offsets *new_offsets;
int i;
@@ -335,18 +337,47 @@ vmap_symtab (vp)
ANOFFSET (new_offsets, i) = ANOFFSET (objfile->section_offsets, i);
textsec = bfd_get_section_by_name (vp->bfd, ".text");
- old_text_offset = ANOFFSET (objfile->section_offsets, textsec->target_index);
+ text_delta =
+ vp->tstart - ANOFFSET (objfile->section_offsets, textsec->target_index);
ANOFFSET (new_offsets, textsec->target_index) = vp->tstart;
+
datasec = bfd_get_section_by_name (vp->bfd, ".data");
+ data_delta =
+ vp->dstart - ANOFFSET (objfile->section_offsets, datasec->target_index);
ANOFFSET (new_offsets, datasec->target_index) = vp->dstart;
+
bsssec = bfd_get_section_by_name (vp->bfd, ".bss");
+ bss_delta =
+ vp->dstart - ANOFFSET (objfile->section_offsets, bsssec->target_index);
ANOFFSET (new_offsets, bsssec->target_index) = vp->dstart;
objfile_relocate (objfile, new_offsets);
+
+ {
+ struct obj_section *s;
+ for (s = objfile->sections; s < objfile->sections_end; ++s)
+ {
+ if (s->sec_ptr->target_index == textsec->target_index)
+ {
+ s->addr += text_delta;
+ s->endaddr += text_delta;
+ }
+ else if (s->sec_ptr->target_index == datasec->target_index)
+ {
+ s->addr += data_delta;
+ s->endaddr += data_delta;
+ }
+ else if (s->sec_ptr->target_index == bsssec->target_index)
+ {
+ s->addr += bss_delta;
+ s->endaddr += bss_delta;
+ }
+ }
+ }
- if (old_text_offset != ANOFFSET (new_offsets, textsec->target_index))
+ if (text_delta != 0)
/* breakpoints need to be relocated as well. */
- fixup_breakpoints (0, TEXT_SEGMENT_BASE, vp->tstart - old_text_offset);
+ fixup_breakpoints (0, TEXT_SEGMENT_BASE, text_delta);
}
/* Add symbols for an objfile. */