* xcoffread.c (xcoff_sym_fns): Revise comment about merging this

with coffread.c.

	* breakpoint.c (fixup_breakpoints): Removed.
	* rs6000-nat.c (vmap_symtab): Don't call fixup_breakpoints.
	(vmap_ldinfo, xcoff_relocate_core): Call breakpoint_re_set.

	* coffread.c (coff_symfile_offsets): Allocate SECT_OFF_MAX
	sections, not just SECT_OFF_MAX-1.

	* rs6000-nat.c (vmap_symtab), xcoffread.c: Re-do section offsets
	to be indexed by SECT_OFF_* instead of xcoff section numbers.
	* objfiles.c, remote.c: Remove comments regarding SECT_OFF_*.
	* symtab.h: Revise comment about block_line_section.
	* rs6000-nat.c (vmap_symtab): Don't relocate objfile->sections.
This commit is contained in:
Jim Kingdon 1995-04-16 00:53:31 +00:00
parent 9b86fdcaef
commit e2adc41a31
4 changed files with 62 additions and 90 deletions

View file

@ -1,3 +1,21 @@
Fri Apr 14 12:10:24 1995 Jim Kingdon <kingdon@deneb.cygnus.com>
* xcoffread.c (xcoff_sym_fns): Revise comment about merging this
with coffread.c.
* breakpoint.c (fixup_breakpoints): Removed.
* rs6000-nat.c (vmap_symtab): Don't call fixup_breakpoints.
(vmap_ldinfo, xcoff_relocate_core): Call breakpoint_re_set.
* coffread.c (coff_symfile_offsets): Allocate SECT_OFF_MAX
sections, not just SECT_OFF_MAX-1.
* rs6000-nat.c (vmap_symtab), xcoffread.c: Re-do section offsets
to be indexed by SECT_OFF_* instead of xcoff section numbers.
* objfiles.c, remote.c: Remove comments regarding SECT_OFF_*.
* symtab.h: Revise comment about block_line_section.
* rs6000-nat.c (vmap_symtab): Don't relocate objfile->sections.
Sat Apr 15 14:15:14 1995 Stan Shebs <shebs@andros.cygnus.com> Sat Apr 15 14:15:14 1995 Stan Shebs <shebs@andros.cygnus.com>
* mpw-make.in (init.c): Don't try to do symbolic {o} in sed * mpw-make.in (init.c): Don't try to do symbolic {o} in sed

View file

@ -545,10 +545,6 @@ objfile_relocate (objfile, new_offsets)
ALL_OBJFILE_PSYMTABS (objfile, p) ALL_OBJFILE_PSYMTABS (objfile, p)
{ {
/* FIXME: specific to symbol readers which use gdb-stabs.h.
We can only get away with it since objfile_relocate is only
used on XCOFF, which lacks psymtabs, and for gdb-stabs.h
targets. */
p->textlow += ANOFFSET (delta, SECT_OFF_TEXT); p->textlow += ANOFFSET (delta, SECT_OFF_TEXT);
p->texthigh += ANOFFSET (delta, SECT_OFF_TEXT); p->texthigh += ANOFFSET (delta, SECT_OFF_TEXT);
} }

View file

@ -26,6 +26,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "objfiles.h" #include "objfiles.h"
#include "libbfd.h" /* For bfd_cache_lookup (FIXME) */ #include "libbfd.h" /* For bfd_cache_lookup (FIXME) */
#include "bfd.h" #include "bfd.h"
#include "gdb-stabs.h"
#include <sys/ptrace.h> #include <sys/ptrace.h>
#include <sys/reg.h> #include <sys/reg.h>
@ -285,9 +286,6 @@ vmap_symtab (vp)
register struct vmap *vp; register struct vmap *vp;
{ {
register struct objfile *objfile; register struct objfile *objfile;
asection *textsec;
asection *datasec;
asection *bsssec;
CORE_ADDR text_delta; CORE_ADDR text_delta;
CORE_ADDR data_delta; CORE_ADDR data_delta;
CORE_ADDR bss_delta; CORE_ADDR bss_delta;
@ -312,48 +310,19 @@ vmap_symtab (vp)
for (i = 0; i < objfile->num_sections; ++i) for (i = 0; i < objfile->num_sections; ++i)
ANOFFSET (new_offsets, i) = ANOFFSET (objfile->section_offsets, i); ANOFFSET (new_offsets, i) = ANOFFSET (objfile->section_offsets, i);
textsec = bfd_get_section_by_name (vp->bfd, ".text");
text_delta = text_delta =
vp->tstart - ANOFFSET (objfile->section_offsets, textsec->target_index); vp->tstart - ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT);
ANOFFSET (new_offsets, textsec->target_index) = vp->tstart; ANOFFSET (new_offsets, SECT_OFF_TEXT) = vp->tstart;
datasec = bfd_get_section_by_name (vp->bfd, ".data");
data_delta = data_delta =
vp->dstart - ANOFFSET (objfile->section_offsets, datasec->target_index); vp->dstart - ANOFFSET (objfile->section_offsets, SECT_OFF_DATA);
ANOFFSET (new_offsets, datasec->target_index) = vp->dstart; ANOFFSET (new_offsets, SECT_OFF_DATA) = vp->dstart;
bsssec = bfd_get_section_by_name (vp->bfd, ".bss");
bss_delta = bss_delta =
vp->dstart - ANOFFSET (objfile->section_offsets, bsssec->target_index); vp->dstart - ANOFFSET (objfile->section_offsets, SECT_OFF_BSS);
ANOFFSET (new_offsets, bsssec->target_index) = vp->dstart; ANOFFSET (new_offsets, SECT_OFF_BSS) = vp->dstart;
objfile_relocate (objfile, new_offsets); objfile_relocate (objfile, new_offsets);
{
struct obj_section *s;
for (s = objfile->sections; s < objfile->sections_end; ++s)
{
if (s->the_bfd_section->target_index == textsec->target_index)
{
s->addr += text_delta;
s->endaddr += text_delta;
}
else if (s->the_bfd_section->target_index == datasec->target_index)
{
s->addr += data_delta;
s->endaddr += data_delta;
}
else if (s->the_bfd_section->target_index == bsssec->target_index)
{
s->addr += bss_delta;
s->endaddr += bss_delta;
}
}
}
if (text_delta != 0)
/* breakpoints need to be relocated as well. */
fixup_breakpoints (0, TEXT_SEGMENT_BASE, text_delta);
} }
/* Add symbols for an objfile. */ /* Add symbols for an objfile. */
@ -568,6 +537,7 @@ symbols to the proper address).\n", gdb_stderr);
free_objfile (symfile_objfile); free_objfile (symfile_objfile);
symfile_objfile = NULL; symfile_objfile = NULL;
} }
breakpoint_re_set ();
} }
/* As well as symbol tables, exec_sections need relocation. After /* As well as symbol tables, exec_sections need relocation. After
@ -786,5 +756,6 @@ xcoff_relocate_core (target)
(CORE_ADDR)ldip->ldinfo_dataorg); (CORE_ADDR)ldip->ldinfo_dataorg);
} while (ldip->ldinfo_next != 0); } while (ldip->ldinfo_next != 0);
vmap_exec (); vmap_exec ();
breakpoint_re_set ();
do_cleanups (old); do_cleanups (old);
} }

View file

@ -214,7 +214,6 @@ static void
add_stab_to_list PARAMS ((char *, struct pending_stabs **)); add_stab_to_list PARAMS ((char *, struct pending_stabs **));
#ifdef STATIC_NODEBUG_VARS
/* Return the section_offsets* that CS points to. */ /* Return the section_offsets* that CS points to. */
static int cs_to_section PARAMS ((struct coff_symbol *, struct objfile *)); static int cs_to_section PARAMS ((struct coff_symbol *, struct objfile *));
@ -256,7 +255,6 @@ cs_to_section (cs, objfile)
bfd_map_over_sections (objfile->obfd, find_targ_sec, &args); bfd_map_over_sections (objfile->obfd, find_targ_sec, &args);
return off; return off;
} }
#endif /* STATIC_NODEBUG_VARS */
/* add a given stab string into given stab vector. */ /* add a given stab string into given stab vector. */
@ -1252,8 +1250,7 @@ read_xcoff_symtab (objfile, nsyms)
{ {
if (last_source_file) if (last_source_file)
{ {
end_symtab (cur_src_end_addr, 1, 0, objfile, end_symtab (cur_src_end_addr, 1, 0, objfile, SECT_OFF_TEXT);
textsec->target_index);
end_stabs (); end_stabs ();
} }
@ -1333,7 +1330,7 @@ read_xcoff_symtab (objfile, nsyms)
complete_symtab (filestring, file_start_addr); complete_symtab (filestring, file_start_addr);
cur_src_end_addr = file_end_addr; cur_src_end_addr = file_end_addr;
end_symtab (file_end_addr, 1, 0, objfile, end_symtab (file_end_addr, 1, 0, objfile,
textsec->target_index); SECT_OFF_TEXT);
end_stabs (); end_stabs ();
start_stabs (); start_stabs ();
/* Give all csects for this source file the same /* Give all csects for this source file the same
@ -1357,7 +1354,7 @@ read_xcoff_symtab (objfile, nsyms)
{ {
last_csect_name = cs->c_name; last_csect_name = cs->c_name;
last_csect_val = cs->c_value; last_csect_val = cs->c_value;
last_csect_sec = cs->c_secnum; last_csect_sec = cs_to_section (cs, objfile);
} }
} }
misc_func_recorded = 0; misc_func_recorded = 0;
@ -1400,9 +1397,10 @@ read_xcoff_symtab (objfile, nsyms)
case XMC_PR: case XMC_PR:
/* a function entry point. */ /* a function entry point. */
function_entry_point: function_entry_point:
RECORD_MINIMAL_SYMBOL (cs->c_name, cs->c_value, mst_text, RECORD_MINIMAL_SYMBOL
symname_alloced, cs->c_secnum, (cs->c_name, cs->c_value, mst_text,
objfile); symname_alloced, cs_to_section (cs, objfile),
objfile);
fcn_line_offset = main_aux.x_sym.x_fcnary.x_fcn.x_lnnoptr; fcn_line_offset = main_aux.x_sym.x_fcnary.x_fcn.x_lnnoptr;
fcn_start_addr = cs->c_value; fcn_start_addr = cs->c_value;
@ -1518,7 +1516,7 @@ read_xcoff_symtab (objfile, nsyms)
RECORD_MINIMAL_SYMBOL RECORD_MINIMAL_SYMBOL
(cs->c_name, cs->c_value, (cs->c_name, cs->c_value,
mst_solib_trampoline, mst_solib_trampoline,
symname_alloced, cs->c_secnum, objfile); symname_alloced, cs_to_section (cs, objfile), objfile);
continue; continue;
case XMC_DS: case XMC_DS:
@ -1575,7 +1573,7 @@ read_xcoff_symtab (objfile, nsyms)
complete_symtab (filestring, file_start_addr); complete_symtab (filestring, file_start_addr);
cur_src_end_addr = file_end_addr; cur_src_end_addr = file_end_addr;
end_symtab (file_end_addr, 1, 0, objfile, textsec->target_index); end_symtab (file_end_addr, 1, 0, objfile, SECT_OFF_TEXT);
end_stabs (); end_stabs ();
/* XCOFF, according to the AIX 3.2 documentation, puts the filename /* XCOFF, according to the AIX 3.2 documentation, puts the filename
@ -1621,7 +1619,7 @@ read_xcoff_symtab (objfile, nsyms)
new->name = define_symbol new->name = define_symbol
(fcn_cs_saved.c_value, fcn_stab_saved.c_name, 0, 0, objfile); (fcn_cs_saved.c_value, fcn_stab_saved.c_name, 0, 0, objfile);
if (new->name != NULL) if (new->name != NULL)
SYMBOL_SECTION (new->name) = cs->c_secnum; SYMBOL_SECTION (new->name) = cs_to_section (cs, objfile);
} }
else if (STREQ (cs->c_name, ".ef")) else if (STREQ (cs->c_name, ".ef"))
{ {
@ -1656,10 +1654,12 @@ read_xcoff_symtab (objfile, nsyms)
/* Begin static block. */ /* Begin static block. */
{ {
struct internal_syment symbol; struct internal_syment symbol;
struct coff_symbol csymbol;
read_symbol (&symbol, cs->c_value); read_symbol (&symbol, cs->c_value);
static_block_base = symbol.n_value; static_block_base = symbol.n_value;
static_block_section = symbol.n_scnum; csymbol.c_secnum = symbol.n_scnum;
static_block_section = cs_to_section (&csymbol, objfile);
} }
break; break;
@ -1721,7 +1721,7 @@ read_xcoff_symtab (objfile, nsyms)
break; break;
} }
RECORD_MINIMAL_SYMBOL (cs->c_name, cs->c_value, ms_type, RECORD_MINIMAL_SYMBOL (cs->c_name, cs->c_value, ms_type,
symname_alloced, cs->c_secnum, objfile); symname_alloced, sec, objfile);
} }
#endif /* STATIC_NODEBUG_VARS */ #endif /* STATIC_NODEBUG_VARS */
break; break;
@ -1774,7 +1774,7 @@ read_xcoff_symtab (objfile, nsyms)
if (last_source_file) if (last_source_file)
{ {
end_symtab (cur_src_end_addr, 1, 0, objfile, textsec->target_index); end_symtab (cur_src_end_addr, 1, 0, objfile, SECT_OFF_TEXT);
end_stabs (); end_stabs ();
} }
@ -1827,7 +1827,7 @@ process_xcoff_symbol (cs, objfile)
/* default assumptions */ /* default assumptions */
SYMBOL_VALUE (sym) = cs->c_value; SYMBOL_VALUE (sym) = cs->c_value;
SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
SYMBOL_SECTION (sym) = cs->c_secnum; SYMBOL_SECTION (sym) = cs_to_section (cs, objfile);
if (ISFCN (cs->c_type)) if (ISFCN (cs->c_type))
{ {
@ -1886,7 +1886,7 @@ process_xcoff_symbol (cs, objfile)
sym = define_symbol (cs->c_value, cs->c_name, 0, 0, objfile); sym = define_symbol (cs->c_value, cs->c_name, 0, 0, objfile);
if (sym != NULL) if (sym != NULL)
{ {
SYMBOL_SECTION (sym) = cs->c_secnum; SYMBOL_SECTION (sym) = cs_to_section (cs, objfile);
} }
return sym; return sym;
@ -1917,14 +1917,14 @@ process_xcoff_symbol (cs, objfile)
sym = define_symbol (cs->c_value, cs->c_name, 0, N_LSYM, objfile); sym = define_symbol (cs->c_value, cs->c_name, 0, N_LSYM, objfile);
if (sym != NULL) if (sym != NULL)
{ {
SYMBOL_SECTION (sym) = cs->c_secnum; SYMBOL_SECTION (sym) = cs_to_section (cs, objfile);
} }
return sym; return sym;
case C_AUTO: case C_AUTO:
SYMBOL_CLASS (sym) = LOC_LOCAL; SYMBOL_CLASS (sym) = LOC_LOCAL;
SYMBOL_NAME (sym) = SYMNAME_ALLOC (name, symname_alloced); SYMBOL_NAME (sym) = SYMNAME_ALLOC (name, symname_alloced);
SYMBOL_SECTION (sym) = cs->c_secnum; SYMBOL_SECTION (sym) = cs_to_section (cs, objfile);
SYMBOL_DUP (sym, sym2); SYMBOL_DUP (sym, sym2);
add_symbol_to_list (sym2, &local_symbols); add_symbol_to_list (sym2, &local_symbols);
break; break;
@ -1932,7 +1932,7 @@ process_xcoff_symbol (cs, objfile)
case C_EXT: case C_EXT:
SYMBOL_CLASS (sym) = LOC_STATIC; SYMBOL_CLASS (sym) = LOC_STATIC;
SYMBOL_NAME (sym) = SYMNAME_ALLOC (name, symname_alloced); SYMBOL_NAME (sym) = SYMNAME_ALLOC (name, symname_alloced);
SYMBOL_SECTION (sym) = cs->c_secnum; SYMBOL_SECTION (sym) = cs_to_section (cs, objfile);
SYMBOL_DUP (sym, sym2); SYMBOL_DUP (sym, sym2);
add_symbol_to_list (sym2, &global_symbols); add_symbol_to_list (sym2, &global_symbols);
break; break;
@ -1940,7 +1940,7 @@ process_xcoff_symbol (cs, objfile)
case C_STAT: case C_STAT:
SYMBOL_CLASS (sym) = LOC_STATIC; SYMBOL_CLASS (sym) = LOC_STATIC;
SYMBOL_NAME (sym) = SYMNAME_ALLOC (name, symname_alloced); SYMBOL_NAME (sym) = SYMNAME_ALLOC (name, symname_alloced);
SYMBOL_SECTION (sym) = cs->c_secnum; SYMBOL_SECTION (sym) = cs_to_section (cs, objfile);
SYMBOL_DUP (sym, sym2); SYMBOL_DUP (sym, sym2);
add_symbol_to_list add_symbol_to_list
(sym2, within_function ? &local_symbols : &file_symbols); (sym2, within_function ? &local_symbols : &file_symbols);
@ -1952,7 +1952,7 @@ process_xcoff_symbol (cs, objfile)
{ {
sym = define_symbol (cs->c_value, cs->c_name, 0, 0, objfile); sym = define_symbol (cs->c_value, cs->c_name, 0, 0, objfile);
if (sym != NULL) if (sym != NULL)
SYMBOL_SECTION (sym) = cs->c_secnum; SYMBOL_SECTION (sym) = cs_to_section (cs, objfile);
return sym; return sym;
} }
else else
@ -2372,22 +2372,7 @@ xcoff_symfile_read (objfile, section_offset, mainline)
do_cleanups (back_to); do_cleanups (back_to);
} }
/* XCOFF-specific parsing routine for section offsets. */ static struct section_offsets *
static int largest_section;
static void
note_one_section (abfd, asect, ptr)
bfd *abfd;
asection *asect;
PTR ptr;
{
if (asect->target_index > largest_section)
largest_section = asect->target_index;
}
static
struct section_offsets *
xcoff_symfile_offsets (objfile, addr) xcoff_symfile_offsets (objfile, addr)
struct objfile *objfile; struct objfile *objfile;
CORE_ADDR addr; CORE_ADDR addr;
@ -2395,14 +2380,12 @@ xcoff_symfile_offsets (objfile, addr)
struct section_offsets *section_offsets; struct section_offsets *section_offsets;
int i; int i;
largest_section = 0; objfile->num_sections = SECT_OFF_MAX;
bfd_map_over_sections (objfile->obfd, note_one_section, NULL);
objfile->num_sections = largest_section + 1;
section_offsets = (struct section_offsets *) section_offsets = (struct section_offsets *)
obstack_alloc obstack_alloc
(&objfile -> psymbol_obstack, (&objfile -> psymbol_obstack,
sizeof (struct section_offsets) sizeof (struct section_offsets)
+ sizeof (section_offsets->offsets) * (objfile->num_sections)); + sizeof (section_offsets->offsets) * objfile->num_sections);
/* syms_from_objfile kindly subtracts from addr the bfd_section_vma /* syms_from_objfile kindly subtracts from addr the bfd_section_vma
of the .text section. This strikes me as wrong--whether the of the .text section. This strikes me as wrong--whether the
@ -2412,9 +2395,9 @@ xcoff_symfile_offsets (objfile, addr)
handle any section but .text sensibly), so just ignore the addr handle any section but .text sensibly), so just ignore the addr
parameter and use 0. That matches the fact that xcoff_symfile_read parameter and use 0. That matches the fact that xcoff_symfile_read
ignores the section_offsets). */ ignores the section_offsets). */
for (i = 0; i < objfile->num_sections; i++) for (i = 0; i < objfile->num_sections; ++i)
ANOFFSET (section_offsets, i) = 0; ANOFFSET (section_offsets, i) = 0;
return section_offsets; return section_offsets;
} }
@ -2424,10 +2407,14 @@ static struct sym_fns xcoff_sym_fns =
{ {
/* Because the bfd uses coff_flavour, we need to specially kludge /* Because the bfd uses coff_flavour, we need to specially kludge
the flavour. FIXME: coff and xcoff and fundamentally similar the flavour. It is possible that coff and xcoff should be merged as
except for debug format, and we should see if we can merge this they do have fundamental similarities (for example, the extra storage
file with coffread.c. For example, the extra storage classes classes used for stabs could presumably be recognized in any COFF file).
used for stabs could presumably be recognized in any COFF file. */ However, in addition to obvious things like all the csect hair, there are
some subtler differences between xcoffread.c and coffread.c, notably
the fact that coffread.c has no need to read in all the symbols, but
xcoffread.c reads all the symbols and does in fact randomly access them
(in C_BSTAT and B_BINCL processing). */
(enum bfd_flavour)-1, (enum bfd_flavour)-1,