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.
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)
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);
/* Returns a section whose range includes PC or NULL if none found. */
-sec_ptr
+struct obj_section *
find_pc_section(pc)
CORE_ADDR 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);
}
};
-/* 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
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
#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 " */
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;
}
#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>
/* 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);
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
s->offset += addr;
}
}
+#endif /* not IBM6000_TARGET */
(*objfile -> sf -> sym_read) (objfile, section_offsets, mainline);
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;
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. */