* objfiles.h (struct obj_section): Remove addr and endaddr fields.

(obj_section_offset, obj_section_addr, obj_section_endaddr): New
	macros.
	* objfiles.c (add_to_objfile_sections): Don't set addr, endaddr
	and offset.  Use size_t instead of unsigned long.
	(build_objfile_section_table): Use size_t instead of unsigned
	long.
	(objfile_relocate): Don't relocate s->addr and s->endaddr, they're
	gone.
	(find_pc_sect_section): Use obj_section_addr and
	obj_section_endaddr.
	* symfile.c (symfile.c): Remove code that maps sections
	offsets in "addr" to the object's sections.
	* blockframe.c (find_pc_partial_function): Use obj_section_endaddr.
	* gcore.c (gcore_create_callback): Use obj_section_addr and
	obj_section_endaddr.
	* maint.c (print_objfile_section_info): Likewise.
	* printcmd.c (sym_info): Use obj_section_addr and
	obj_section_endaddr.
	* symtab.c (fixup_section): Likewise.
This commit is contained in:
Pedro Alves 2008-08-20 11:21:44 +00:00
parent b365f67721
commit f1f6aadf8c
9 changed files with 63 additions and 111 deletions

View file

@ -88,14 +88,12 @@ add_to_objfile_sections (struct bfd *abfd, struct bfd_section *asect,
if (0 == bfd_section_size (abfd, asect))
return;
section.offset = 0;
section.objfile = objfile;
section.the_bfd_section = asect;
section.ovly_mapped = 0;
section.addr = bfd_section_vma (abfd, asect);
section.endaddr = section.addr + bfd_section_size (abfd, asect);
obstack_grow (&objfile->objfile_obstack, (char *) &section, sizeof (section));
objfile->sections_end = (struct obj_section *) (((unsigned long) objfile->sections_end) + 1);
objfile->sections_end
= (struct obj_section *) (((size_t) objfile->sections_end) + 1);
}
/* Builds a section table for OBJFILE.
@ -124,10 +122,10 @@ build_objfile_section_table (struct objfile *objfile)
waste some memory. */
objfile->sections_end = 0;
bfd_map_over_sections (objfile->obfd, add_to_objfile_sections, (char *) objfile);
objfile->sections = (struct obj_section *)
obstack_finish (&objfile->objfile_obstack);
objfile->sections_end = objfile->sections + (unsigned long) objfile->sections_end;
bfd_map_over_sections (objfile->obfd,
add_to_objfile_sections, (void *) objfile);
objfile->sections = obstack_finish (&objfile->objfile_obstack);
objfile->sections_end = objfile->sections + (size_t) objfile->sections_end;
return (0);
}
@ -664,28 +662,13 @@ objfile_relocate (struct objfile *objfile, struct section_offsets *new_offsets)
objfile->ei.entry_point += ANOFFSET (delta, SECT_OFF_TEXT (objfile));
}
{
struct obj_section *s;
bfd *abfd;
abfd = objfile->obfd;
ALL_OBJFILE_OSECTIONS (objfile, s)
{
int idx = s->the_bfd_section->index;
s->addr += ANOFFSET (delta, idx);
s->endaddr += ANOFFSET (delta, idx);
}
}
/* Update the table in exec_ops, used to read memory. */
ALL_OBJFILE_OSECTIONS (objfile, s)
{
int idx = s->the_bfd_section->index;
exec_set_section_address (bfd_get_filename (objfile->obfd), idx,
s->addr);
obj_section_addr (s));
}
/* Relocate breakpoints as necessary, after things are relocated. */
@ -784,8 +767,8 @@ find_pc_sect_section (CORE_ADDR pc, struct bfd_section *section)
struct objfile *objfile;
ALL_OBJSECTIONS (objfile, s)
if ((section == 0 || section == s->the_bfd_section) &&
s->addr <= pc && pc < s->endaddr)
if ((section == 0 || section == s->the_bfd_section)
&& obj_section_addr (s) <= pc && pc < obj_section_endaddr (s))
return (s);
return (NULL);