+Elena Zannoni <ezannoni@kwikemart.cygnus.com>
+
+ * objfiles.h (SECT_OFF_DATA, SECT_OFF_TEXT, SECT_OFF_BSS,
+ SECT_OFF_RODATA): Define as functions of OBJFILE. Add
+ sect_index_text, sect_index_data, sect_index_rodata,
+ sect_index_bss to objfile structure.
+ * gdb-stabs.h (SECT_OFF_DATA, SECT_OFF_TEXT, SECT_OFF_BSS,
+ SECT_OFF_RODATA): Remove.
+ * objfiles.c (allocate_objfile): Initialize
+ sect_index_{text,data,bss,rodata} to -1, for error detection.
+
+ * symfile.c (default_symfile_offsets): Initialize
+ sect_index_{text,data,bss,rodata} from bfd information.
+ * xcoffread.c (xcoff_symfile_offsets): Ditto.
+ * somread.c (som_symfile_offsets): Initialize
+ sect_index_{text,data,bss,rodata}.
+
+ * coffread.c, dbxread.c, elfread.c, hp-psymtab-read.c,
+ hp-symtab-read.c, hpread.c, mdebugread.c, minsyms.c,
+ mipsread.c, objfiles.c, os9kread.c, pa64solib.c, partial-stab.h,
+ remote-os9k.c, remote-vx.c, remote.c, rs6000-nat.c, somsolib.c,
+ stabsread.c, symfile.c, xcoffread.c:
+ Update use of SECT_OFF_{TEXT,DATA,BSS,RODATA} to depend on the
+ current objfile.
+
+ * xcoffread.c: Add new field objfile to find_targ_sec_arg.
+
Thu May 4 20:54:00 2000 Andrew Cagney <cagney@b1.cygnus.com>
* config/mips/tm-mipsv4.h (Dest_Reg), config/mips/tm-irix5.h
{
asection *sect = NULL;
struct find_targ_sec_arg args;
- int off = SECT_OFF_TEXT;
+ int off = SECT_OFF_TEXT (objfile);
args.targ_index = cs->c_secnum;
args.resultp = §
{
/* This is the section. Figure out what SECT_OFF_* code it is. */
if (bfd_get_section_flags (abfd, sect) & SEC_CODE)
- off = SECT_OFF_TEXT;
+ off = SECT_OFF_TEXT (objfile);
else if (bfd_get_section_flags (abfd, sect) & SEC_LOAD)
- off = SECT_OFF_DATA;
+ off = SECT_OFF_DATA (objfile);
else
- off = SECT_OFF_BSS;
+ off = SECT_OFF_BSS (objfile);
}
return off;
}
if (ISFCN (cs->c_type) && cs->c_sclass != C_TPDEF)
{
/* Record all functions -- external and static -- in minsyms. */
- tmpaddr = cs->c_value + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT);
+ tmpaddr = cs->c_value + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
record_minimal_symbol (cs->c_name, tmpaddr, mst_text, objfile);
fcn_line_ptr = main_aux.x_sym.x_fcnary.x_fcn.x_lnnoptr;
followed by a later file with no symbols. */
if (in_source_file)
complete_symtab (filestring,
- cs->c_value + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT),
+ cs->c_value + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)),
main_aux.x_scn.x_scnlen);
in_source_file = 0;
}
|| cs->c_sclass == C_THUMBEXT)
tmpaddr += ANOFFSET (objfile->section_offsets, sec);
- switch (sec)
+ if (sec == SECT_OFF_TEXT (objfile) || sec == SECT_OFF_RODATA (objfile))
{
- case SECT_OFF_TEXT:
- case SECT_OFF_RODATA:
ms_type =
cs->c_sclass == C_EXT || cs->c_sclass == C_THUMBEXTFUNC
|| cs->c_sclass == C_THUMBEXT ?
if (tmpaddr & 1) /* FIXME: delete this line */
SMASH_TEXT_ADDRESS (tmpaddr);
#endif
- break;
- case SECT_OFF_DATA:
+ }
+ else
+ if (sec == SECT_OFF_DATA (objfile))
+ {
ms_type =
cs->c_sclass == C_EXT || cs->c_sclass == C_THUMBEXT ?
mst_data : mst_file_data;
- break;
- case SECT_OFF_BSS:
+ }
+ else
+ if (sec == SECT_OFF_BSS (objfile))
+ {
ms_type =
cs->c_sclass == C_EXT || cs->c_sclass == C_THUMBEXT ?
mst_data : mst_file_data;
- break;
- default:
- ms_type = mst_unknown;
- break;
- }
+ }
+ else
+ ms_type = mst_unknown;
}
if (cs->c_name[0] != '@' /* Skip tdesc symbols */ )
of the epilogue. */
cs->c_value
+ FUNCTION_EPILOGUE_SIZE
- + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT),
+ + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)),
#else
fcn_cs_saved.c_value
+ fcn_aux_saved.x_sym.x_misc.x_fsize
- + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT),
+ + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)),
#endif
objfile
);
if (STREQ (cs->c_name, ".bb"))
{
tmpaddr = cs->c_value;
- tmpaddr += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT);
+ tmpaddr += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
push_context (++depth, tmpaddr);
}
else if (STREQ (cs->c_name, ".eb"))
if (local_symbols && context_stack_depth > 0)
{
tmpaddr =
- cs->c_value + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT);
+ cs->c_value + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
/* Make a block for the local symbols within. */
finish_block (0, &local_symbols, new->old_blocks,
new->start_addr, tmpaddr, objfile);
if (L_LNNO32 (&lptr) && L_LNNO32 (&lptr) <= last_line)
record_line (current_subfile, first_line + L_LNNO32 (&lptr),
lptr.l_addr.l_paddr
- + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT));
+ + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)));
else
break;
}
if (ISFCN (cs->c_type))
{
- SYMBOL_VALUE (sym) += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT);
+ SYMBOL_VALUE (sym) += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
SYMBOL_TYPE (sym) =
lookup_function_type (decode_function_type (cs, cs->c_type, aux));
case C_EXT:
SYMBOL_CLASS (sym) = LOC_STATIC;
SYMBOL_VALUE_ADDRESS (sym) = (CORE_ADDR) cs->c_value;
- SYMBOL_VALUE_ADDRESS (sym) += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT);
+ SYMBOL_VALUE_ADDRESS (sym) += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
add_symbol_to_list (sym, &global_symbols);
break;
case C_STAT:
SYMBOL_CLASS (sym) = LOC_STATIC;
SYMBOL_VALUE_ADDRESS (sym) = (CORE_ADDR) cs->c_value;
- SYMBOL_VALUE_ADDRESS (sym) += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT);
+ SYMBOL_VALUE_ADDRESS (sym) += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
if (within_function)
{
/* Static symbol of local scope */
{
case N_TEXT | N_EXT:
ms_type = mst_text;
- section = SECT_OFF_TEXT;
+ section = SECT_OFF_TEXT (objfile);
bfd_section = DBX_TEXT_SECTION (objfile);
break;
case N_DATA | N_EXT:
ms_type = mst_data;
- section = SECT_OFF_DATA;
+ section = SECT_OFF_DATA (objfile);
bfd_section = DBX_DATA_SECTION (objfile);
break;
case N_BSS | N_EXT:
ms_type = mst_bss;
- section = SECT_OFF_BSS;
+ section = SECT_OFF_BSS (objfile);
bfd_section = DBX_BSS_SECTION (objfile);
break;
case N_ABS | N_EXT:
#ifdef N_SETV
case N_SETV | N_EXT:
ms_type = mst_data;
- section = SECT_OFF_DATA;
+ section = SECT_OFF_DATA (objfile);
bfd_section = DBX_DATA_SECTION (objfile);
break;
case N_SETV:
of going over many .o files, it doesn't make sense to have one
file local. */
ms_type = mst_file_data;
- section = SECT_OFF_DATA;
+ section = SECT_OFF_DATA (objfile);
bfd_section = DBX_DATA_SECTION (objfile);
break;
#endif
case N_FN:
case N_FN_SEQ:
ms_type = mst_file_text;
- section = SECT_OFF_TEXT;
+ section = SECT_OFF_TEXT (objfile);
bfd_section = DBX_TEXT_SECTION (objfile);
break;
case N_DATA:
if (VTBL_PREFIX_P ((tempstring)))
ms_type = mst_data;
}
- section = SECT_OFF_DATA;
+ section = SECT_OFF_DATA (objfile);
bfd_section = DBX_DATA_SECTION (objfile);
break;
case N_BSS:
ms_type = mst_file_bss;
- section = SECT_OFF_BSS;
+ section = SECT_OFF_BSS (objfile);
bfd_section = DBX_BSS_SECTION (objfile);
break;
default:
if (bfd_get_section_flags (abfd, sec) & SEC_CODE)
{
- sym_value += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT);
+ sym_value += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
type = N_TEXT;
}
else if (bfd_get_section_flags (abfd, sec) & SEC_DATA)
{
- sym_value += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA);
+ sym_value += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile));
type = N_DATA;
}
else if (bfd_get_section_flags (abfd, sec) & SEC_ALLOC)
{
- sym_value += ANOFFSET (objfile->section_offsets, SECT_OFF_BSS);
+ sym_value += ANOFFSET (objfile->section_offsets, SECT_OFF_BSS (objfile));
type = N_BSS;
}
else
{
arelent *rel = *relptr;
CORE_ADDR address =
- rel->address + ANOFFSET (objfile->section_offsets, SECT_OFF_DATA);
+ rel->address + ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile));
switch (bfd_get_arch (abfd))
{
/* Don't set pst->texthigh lower than it already is. */
CORE_ADDR text_end =
(lowest_text_address == (CORE_ADDR) -1
- ? (text_addr + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT))
+ ? (text_addr + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)))
: lowest_text_address)
+ text_size;
struct partial_symtab *subpst =
allocate_psymtab (include_list[i], objfile);
+ /* Copy the sesction_offsets array from the main psymtab. */
subpst->section_offsets = pst->section_offsets;
subpst->read_symtab_private =
(char *) obstack_alloc (&objfile->psymbol_obstack,
sym_size = LDSYMLEN (pst);
text_offset = pst->textlow;
text_size = pst->texthigh - pst->textlow;
+ /* This cannot be simply objfile->section_offsets because of
+ elfstab_offset_sections() which initializes the psymtab section
+ offsets information in a special way, and that is different from
+ objfile->section_offsets. */
section_offsets = pst->section_offsets;
current_objfile = objfile;
if (last_source_start_addr > text_offset)
last_source_start_addr = text_offset;
- pst->symtab = end_symtab (text_offset + text_size, objfile, SECT_OFF_TEXT);
+ pst->symtab = end_symtab (text_offset + text_size, objfile, SECT_OFF_TEXT (objfile));
/* Process items which we had to "process_later" due to dependancies
on other stabs. */
NAME is the symbol name, in our address space.
SECTION_OFFSETS is a set of amounts by which the sections of this object
file were relocated when it was loaded into memory.
+ Note that these section_offsets are not the
+ objfile->section_offsets but the pst->section_offsets.
All symbols that refer
to memory locations need to be offset by these amounts.
OBJFILE is the object file from which we are reading symbols.
if (!block_address_function_relative)
/* N_LBRAC, N_RBRAC and N_SLINE entries are not relative to the
function start address, so just use the text offset. */
- function_start_offset = ANOFFSET (section_offsets, SECT_OFF_TEXT);
+ function_start_offset = ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
/* Something is wrong if we see real data before
seeing a source file name. */
}
/* Relocate for dynamic loading */
- valu += ANOFFSET (section_offsets, SECT_OFF_TEXT);
+ valu += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
#ifdef SMASH_TEXT_ADDRESS
SMASH_TEXT_ADDRESS (valu);
#endif
case N_FN_SEQ:
/* This kind of symbol indicates the start of an object file. */
/* Relocate for dynamic loading */
- valu += ANOFFSET (section_offsets, SECT_OFF_TEXT);
+ valu += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
break;
case N_SO:
Finish the symbol table of the previous source file
(if any) and start accumulating a new symbol table. */
/* Relocate for dynamic loading */
- valu += ANOFFSET (section_offsets, SECT_OFF_TEXT);
+ valu += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
n_opt_found = 0;
patch_subfile_names (current_subfile, name);
break; /* Ignore repeated SOs */
}
- end_symtab (valu, objfile, SECT_OFF_TEXT);
+ end_symtab (valu, objfile, SECT_OFF_TEXT (objfile));
end_stabs ();
}
included in the compilation of the main source file
(whose name was given in the N_SO symbol.) */
/* Relocate for dynamic loading */
- valu += ANOFFSET (section_offsets, SECT_OFF_TEXT);
+ valu += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
start_subfile (name, current_subfile->dirname);
break;
elfstab_offset_sections ever starts dealing with the
text offset, and we still need to do this, we need to
invent a SECT_OFF_ADDR_KLUDGE or something. */
- valu += ANOFFSET (section_offsets, SECT_OFF_TEXT);
+ valu += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
goto define_a_symbol;
}
}
case_N_STSYM: /* Static symbol in data seg */
case N_DSLINE: /* Source line number, data seg */
- valu += ANOFFSET (section_offsets, SECT_OFF_DATA);
+ valu += ANOFFSET (section_offsets, SECT_OFF_DATA (objfile));
goto define_a_symbol;
case_N_LCSYM: /* Static symbol in BSS seg */
case N_BSLINE: /* Source line number, bss seg */
/* N_BROWS: overlaps with N_BSLINE */
- valu += ANOFFSET (section_offsets, SECT_OFF_BSS);
+ valu += ANOFFSET (section_offsets, SECT_OFF_BSS (objfile));
goto define_a_symbol;
case_N_ROSYM: /* Static symbol in Read-only data seg */
- valu += ANOFFSET (section_offsets, SECT_OFF_RODATA);
+ valu += ANOFFSET (section_offsets, SECT_OFF_RODATA (objfile));
goto define_a_symbol;
case N_ENTRY: /* Alternate entry point */
/* Relocate for dynamic loading */
- valu += ANOFFSET (section_offsets, SECT_OFF_TEXT);
+ valu += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
goto define_a_symbol;
/* The following symbol types we don't know how to process. Handle
/* Deal with the SunPRO 3.0 compiler which omits the address
from N_FUN symbols. */
if (type == N_FUN
- && valu == ANOFFSET (section_offsets, SECT_OFF_TEXT))
+ && valu == ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile)))
valu =
find_stab_function_addr (name, last_source_file, objfile);
#endif
{
case mst_text:
case mst_file_text:
- section = SECT_OFF_TEXT;
+ section = SECT_OFF_TEXT (objfile);
#ifdef SMASH_TEXT_ADDRESS
SMASH_TEXT_ADDRESS (address);
#endif
break;
case mst_data:
case mst_file_data:
- section = SECT_OFF_DATA;
+ section = SECT_OFF_DATA (objfile);
break;
case mst_bss:
case mst_file_bss:
- section = SECT_OFF_BSS;
+ section = SECT_OFF_BSS (objfile);
break;
default:
section = -1;
error ("Can't read symbols from %s: %s", bfd_get_filename (objfile->obfd),
bfd_errmsg (bfd_get_error ()));
/* FIXME: Should use section specific offset, not SECT_OFF_TEXT. */
- offset = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT);
+ offset = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
for (i = 0; i < number_of_symbols; i++)
{
sym = symbol_table[i];
index = SECT_OFF_MAX;
if (STREQ ("Bbss.bss", sym->name))
{
- index = SECT_OFF_BSS;
+ index = SECT_OFF_BSS (objfile);
}
else if (STREQ ("Ddata.data", sym->name))
{
- index = SECT_OFF_DATA;
+ index = SECT_OFF_DATA (objfile);
}
else if (STREQ ("Drodata.rodata", sym->name))
{
- index = SECT_OFF_RODATA;
+ index = SECT_OFF_RODATA (objfile);
}
if (index != SECT_OFF_MAX)
{
#if !defined (GDBSTABS_H)
#define GDBSTABS_H
-/* Offsets in the psymtab's section_offsets array for various kinds of
- stabs symbols. Every psymtab built from stabs will have these offsets
- filled in by these guidelines, so that when actually reading symbols, the
- proper offset can simply be selected and added to the symbol value. */
-
-#define SECT_OFF_TEXT 0
-#define SECT_OFF_DATA 1
-#define SECT_OFF_BSS 2
-#define SECT_OFF_RODATA 3
#define SECT_OFF_MAX 40 /* Count of possible values */
/* The stab_section_info chain remembers info from the ELF symbol table,
LOC_BLOCK, /* "I am a routine" */
&objfile->global_psymbols,
(qPD[curr_pd].adrStart + /* Starting address of rtn */
- ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT)),
+ ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile))),
0, /* core addr?? */
trans_lang ((enum hp_language) qPD[curr_pd].language),
objfile);
LOC_BLOCK, /* "I am a routine" */
&objfile->static_psymbols,
(qPD[curr_pd].adrStart + /* Starting address of rtn */
- ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT)),
+ ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile))),
0, /* core addr?? */
trans_lang ((enum hp_language) qPD[curr_pd].language),
objfile);
past_first_source_file = 1;
valu = hpread_get_textlow (i, hp_symnum, objfile, symcount);
- valu += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT);
+ valu += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
pst = hpread_start_psymtab (objfile,
namestring, valu,
(hp_symnum
/* Now begin a new module and a new psymtab for it */
SET_NAMESTRING (dn_bufp, &namestring, objfile);
valu = hpread_get_textlow (i, hp_symnum, objfile, symcount);
- valu += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT);
+ valu += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
if (!pst)
{
pst = hpread_start_psymtab (objfile,
/* The beginning of a function. DNTT_TYPE_ENTRY may also denote
a secondary entry point. */
valu = dn_bufp->dfunc.hiaddr + ANOFFSET (objfile->section_offsets,
- SECT_OFF_TEXT);
+ SECT_OFF_TEXT (objfile));
if (valu > texthigh)
texthigh = valu;
valu = dn_bufp->dfunc.lowaddr +
- ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT);
+ ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
SET_NAMESTRING (dn_bufp, &namestring, objfile);
if (dn_bufp->dfunc.global)
add_psymbol_to_list (namestring, strlen (namestring),
case DNTT_TYPE_DOC_FUNCTION:
valu = dn_bufp->ddocfunc.hiaddr + ANOFFSET (objfile->section_offsets,
- SECT_OFF_TEXT);
+ SECT_OFF_TEXT (objfile));
if (valu > texthigh)
texthigh = valu;
valu = dn_bufp->ddocfunc.lowaddr +
- ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT);
+ ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
SET_NAMESTRING (dn_bufp, &namestring, objfile);
if (dn_bufp->ddocfunc.global)
add_psymbol_to_list (namestring, strlen (namestring),
valu = dn_bufp->dsvar.location;
/* Relocate in case it's in a shared library */
if (storage == LOC_STATIC)
- valu += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA);
+ valu += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile));
/* Luckily, dvar, svar, typedef, and tagdef all
have their "global" bit in the same place, so it works
struct partial_symbol **global_syms;
struct partial_symbol **static_syms;
{
- int offset = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT);
+ int offset = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
extern void hpread_psymtab_to_symtab ();
struct partial_symtab *result =
start_psymtab_common (objfile, objfile->section_offsets,
{
int i;
struct objfile *objfile = pst->objfile;
- int offset = ANOFFSET (pst->section_offsets, SECT_OFF_TEXT);
+ int offset = ANOFFSET (pst->section_offsets, SECT_OFF_TEXT (objfile));
#ifdef DUMPING
/* Turn on to see what kind of a psymtab we've built. */
unsigned long desc;
int type;
CORE_ADDR valu;
- int offset = ANOFFSET (section_offsets, SECT_OFF_TEXT);
- int data_offset = ANOFFSET (section_offsets, SECT_OFF_DATA);
+ int offset = ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
+ int data_offset = ANOFFSET (section_offsets, SECT_OFF_DATA (objfile));
union dnttentry *dn_temp;
dnttpointer hp_type;
struct symbol *sym;
past_first_source_file = 1;
valu = hpread_get_textlow (i, hp_symnum, objfile);
- valu += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT);
+ valu += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
pst = hpread_start_psymtab (objfile,
namestring, valu,
(hp_symnum
is supposed to be. */
SET_NAMESTRING (dn_bufp, &namestring, objfile);
valu = hpread_get_textlow (i, hp_symnum, objfile);
- valu += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT);
+ valu += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
if (!pst)
{
pst = hpread_start_psymtab (objfile,
/* The beginning of a function. DNTT_TYPE_ENTRY may also denote
a secondary entry point. */
valu = dn_bufp->dfunc.hiaddr + ANOFFSET (objfile->section_offsets,
- SECT_OFF_TEXT);
+ SECT_OFF_TEXT (objfile));
if (valu > texthigh)
texthigh = valu;
valu = dn_bufp->dfunc.lowaddr +
- ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT);
+ ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
SET_NAMESTRING (dn_bufp, &namestring, objfile);
add_psymbol_to_list (namestring, strlen (namestring),
VAR_NAMESPACE, LOC_BLOCK,
unsigned long desc;
int type;
CORE_ADDR valu;
- int offset = ANOFFSET (section_offsets, SECT_OFF_TEXT);
+ int offset = ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
union dnttentry *dn_temp;
dnttpointer hp_type;
struct symbol *sym;
new_bvect PARAMS ((int));
static int
-parse_symbol PARAMS ((SYMR *, union aux_ext *, char *, int, struct section_offsets *));
+parse_symbol PARAMS ((SYMR *, union aux_ext *, char *, int, struct section_offsets *, struct objfile *));
static struct type *
parse_type PARAMS ((int, union aux_ext *, unsigned int, int *, int, char *));
SYMR's handled (normally one). */
static int
-parse_symbol (sh, ax, ext_sh, bigend, section_offsets)
+parse_symbol (sh, ax, ext_sh, bigend, section_offsets, objfile)
SYMR *sh;
union aux_ext *ax;
char *ext_sh;
int bigend;
struct section_offsets *section_offsets;
+ struct objfile *objfile;
{
const bfd_size_type external_sym_size = debug_swap->external_sym_size;
void (*const swap_sym_in) PARAMS ((bfd *, PTR, SYMR *)) =
The value of a stBlock symbol is the displacement from the
procedure address. */
if (sh->st != stEnd && sh->st != stBlock)
- sh->value += ANOFFSET (section_offsets, SECT_OFF_TEXT);
+ sh->value += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
break;
case scData:
case scSData:
case scRData:
case scPData:
case scXData:
- sh->value += ANOFFSET (section_offsets, SECT_OFF_DATA);
+ sh->value += ANOFFSET (section_offsets, SECT_OFF_DATA (objfile));
break;
case scBss:
case scSBss:
- sh->value += ANOFFSET (section_offsets, SECT_OFF_BSS);
+ sh->value += ANOFFSET (section_offsets, SECT_OFF_BSS (objfile));
break;
}
procedure descriptor in e->pdr.adr.
As the address in the procedure descriptor is usually relative,
we would have to relocate e->pdr.adr with cur_fdr->adr and
- ANOFFSET (pst->section_offsets, SECT_OFF_TEXT).
+ ANOFFSET (pst->section_offsets, SECT_OFF_TEXT (pst->objfile)).
Unfortunately cur_fdr->adr and e->pdr.adr are both absolute
in shared libraries on some systems, and on other systems
e->pdr.adr is sometimes offset by a bogus value.
This routine clobbers top_stack->cur_block and ->cur_st. */
-static void parse_external PARAMS ((EXTR *, int, struct section_offsets *));
+static void parse_external PARAMS ((EXTR *, int, struct section_offsets *, struct objfile *));
static void
-parse_external (es, bigend, section_offsets)
+parse_external (es, bigend, section_offsets, objfile)
EXTR *es;
int bigend;
struct section_offsets *section_offsets;
+ struct objfile *objfile;
{
union aux_ext *ax;
/* Note that the case of a symbol with indexNil must be handled
anyways by parse_symbol(). */
- parse_symbol (&es->asym, ax, (char *) NULL, bigend, section_offsets);
+ parse_symbol (&es->asym, ax, (char *) NULL, bigend, section_offsets, objfile);
break;
default:
break;
{
case stProc:
/* Beginnning of Procedure */
- svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT);
+ svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
break;
case stStaticProc:
/* Load time only static procs */
ms_type = mst_file_text;
- svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT);
+ svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
break;
case stGlobal:
/* External symbol */
else if (SC_IS_DATA (ext_in->asym.sc))
{
ms_type = mst_data;
- svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA);
+ svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile));
}
else if (SC_IS_BSS (ext_in->asym.sc))
{
ms_type = mst_bss;
- svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_BSS);
+ svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_BSS (objfile));
}
else
ms_type = mst_abs;
if (SC_IS_TEXT (ext_in->asym.sc))
{
ms_type = mst_file_text;
- svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT);
+ svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
}
else if (SC_IS_DATA (ext_in->asym.sc))
{
ms_type = mst_file_data;
- svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA);
+ svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile));
}
else if (SC_IS_BSS (ext_in->asym.sc))
{
ms_type = mst_file_bss;
- svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_BSS);
+ svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_BSS (objfile));
}
else
ms_type = mst_abs;
{
textlow = fh->adr;
if (relocatable || textlow != 0)
- textlow += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT);
+ textlow += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
}
else
textlow = 0;
CORE_ADDR procaddr;
long isym;
- sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT);
+ sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
if (sh.st == stStaticProc)
{
namestring = debug_info->ss + fh->issBase + sh.iss;
sh.value,
mst_file_text,
NULL,
- SECT_OFF_TEXT,
+ SECT_OFF_TEXT (objfile),
NULL,
objfile);
}
case scPData:
case scXData:
namestring = debug_info->ss + fh->issBase + sh.iss;
- sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA);
+ sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile));
prim_record_minimal_symbol_and_info (namestring,
sh.value,
mst_file_data,
NULL,
- SECT_OFF_DATA,
+ SECT_OFF_DATA (objfile),
NULL,
objfile);
break;
/* FIXME! Shouldn't this use cases for bss,
then have the default be abs? */
namestring = debug_info->ss + fh->issBase + sh.iss;
- sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_BSS);
+ sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_BSS (objfile));
prim_record_minimal_symbol_and_info (namestring,
sh.value,
mst_file_bss,
NULL,
- SECT_OFF_BSS,
+ SECT_OFF_BSS (objfile),
NULL,
objfile);
break;
/* The value of a stEnd symbol is the displacement from the
corresponding start symbol value, do not relocate it. */
if (sh.st != stEnd)
- sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT);
+ sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
break;
case scData:
case scSData:
case scRData:
case scPData:
case scXData:
- sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA);
+ sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile));
break;
case scBss:
case scSBss:
- sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_BSS);
+ sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_BSS (objfile));
break;
}
case stStaticProc:
prim_record_minimal_symbol_and_info (name, sh.value,
mst_file_text, NULL,
- SECT_OFF_TEXT, NULL,
+ SECT_OFF_TEXT (objfile), NULL,
objfile);
/* FALLTHROUGH */
if (SC_IS_DATA (sh.sc))
prim_record_minimal_symbol_and_info (name, sh.value,
mst_file_data, NULL,
- SECT_OFF_DATA,
+ SECT_OFF_DATA (objfile),
NULL,
objfile);
else
prim_record_minimal_symbol_and_info (name, sh.value,
mst_file_bss, NULL,
- SECT_OFF_BSS,
+ SECT_OFF_BSS (objfile),
NULL,
objfile);
class = LOC_STATIC;
{
case scText:
case scRConst:
- svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT);
+ svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
break;
case scData:
case scSData:
case scRData:
case scPData:
case scXData:
- svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA);
+ svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile));
break;
case scBss:
case scSBss:
- svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_BSS);
+ svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_BSS (objfile));
break;
}
else
{
/* Handle encoded stab line number. */
- valu += ANOFFSET (pst->section_offsets, SECT_OFF_TEXT);
+ valu += ANOFFSET (pst->section_offsets, SECT_OFF_TEXT (pst->objfile));
record_line (current_subfile, sh.index, valu);
}
}
else
complain (&stab_unknown_complaint, name);
}
- st = end_symtab (pst->texthigh, pst->objfile, SECT_OFF_TEXT);
+ st = end_symtab (pst->texthigh, pst->objfile, SECT_OFF_TEXT (pst->objfile));
end_stabs ();
/* Sort the symbol table now, we are done adding symbols to it.
(*swap_sym_in) (cur_bfd, sym_ptr, &sh);
c = parse_symbol (&sh,
debug_info->external_aux + fh->iauxBase,
- sym_ptr, fh->fBigendian, pst->section_offsets);
+ sym_ptr, fh->fBigendian, pst->section_offsets, pst->objfile);
sym_ptr += c * external_sym_size;
}
ext_ptr = PST_PRIVATE (pst)->extern_tab;
for (i = PST_PRIVATE (pst)->extern_count; --i >= 0; ext_ptr++)
- parse_external (ext_ptr, fh->fBigendian, pst->section_offsets);
+ parse_external (ext_ptr, fh->fBigendian, pst->section_offsets, pst->objfile);
/* If there are undefined symbols, tell the user.
The alpha has an undefined symbol for every symbol that is
case mst_text:
case mst_file_text:
case mst_solib_trampoline:
- section = SECT_OFF_TEXT;
+ section = SECT_OFF_TEXT (objfile);
break;
case mst_data:
case mst_file_data:
- section = SECT_OFF_DATA;
+ section = SECT_OFF_DATA (objfile);
break;
case mst_bss:
case mst_file_bss:
- section = SECT_OFF_BSS;
+ section = SECT_OFF_BSS (objfile);
break;
default:
section = -1;
ms_type = mst_text;
else
ms_type = mst_file_text;
- sym_value += ANOFFSET (section_offsets, SECT_OFF_TEXT);
+ sym_value += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
}
else if (sym_shndx == SHN_MIPS_DATA)
{
ms_type = mst_data;
else
ms_type = mst_file_data;
- sym_value += ANOFFSET (section_offsets, SECT_OFF_DATA);
+ sym_value += ANOFFSET (section_offsets, SECT_OFF_DATA (objfile));
}
else if (sym_shndx == SHN_MIPS_ACOMMON)
{
ms_type = mst_bss;
else
ms_type = mst_file_bss;
- sym_value += ANOFFSET (section_offsets, SECT_OFF_BSS);
+ sym_value += ANOFFSET (section_offsets, SECT_OFF_BSS (objfile));
}
else if (sym_shndx == SHN_ABS)
{
}
}
+ /* Initialize the section indexes for this objfile, so that we can
+ later detect if they are used w/o being properly assigned to. */
+
+ objfile->sect_index_text = -1;
+ objfile->sect_index_data = -1;
+ objfile->sect_index_bss = -1;
+ objfile->sect_index_rodata = -1;
+
/* Add this file onto the tail of the linked list of other such files. */
objfile->next = NULL;
ALL_OBJFILE_PSYMTABS (objfile, p)
{
- p->textlow += ANOFFSET (delta, SECT_OFF_TEXT);
- p->texthigh += ANOFFSET (delta, SECT_OFF_TEXT);
+ p->textlow += ANOFFSET (delta, SECT_OFF_TEXT (objfile));
+ p->texthigh += ANOFFSET (delta, SECT_OFF_TEXT (objfile));
}
}
if (flags & SEC_CODE)
{
- s->addr += ANOFFSET (delta, SECT_OFF_TEXT);
- s->endaddr += ANOFFSET (delta, SECT_OFF_TEXT);
+ s->addr += ANOFFSET (delta, SECT_OFF_TEXT (objfile));
+ s->endaddr += ANOFFSET (delta, SECT_OFF_TEXT (objfile));
}
else if (flags & (SEC_DATA | SEC_LOAD))
{
- s->addr += ANOFFSET (delta, SECT_OFF_DATA);
- s->endaddr += ANOFFSET (delta, SECT_OFF_DATA);
+ s->addr += ANOFFSET (delta, SECT_OFF_DATA (objfile));
+ s->endaddr += ANOFFSET (delta, SECT_OFF_DATA (objfile));
}
else if (flags & SEC_ALLOC)
{
- s->addr += ANOFFSET (delta, SECT_OFF_BSS);
- s->endaddr += ANOFFSET (delta, SECT_OFF_BSS);
+ s->addr += ANOFFSET (delta, SECT_OFF_BSS (objfile));
+ s->endaddr += ANOFFSET (delta, SECT_OFF_BSS (objfile));
}
}
}
if (objfile->ei.entry_point != ~(CORE_ADDR) 0)
- objfile->ei.entry_point += ANOFFSET (delta, SECT_OFF_TEXT);
+ objfile->ei.entry_point += ANOFFSET (delta, SECT_OFF_TEXT (objfile));
if (objfile->ei.entry_func_lowpc != INVALID_ENTRY_LOWPC)
{
- objfile->ei.entry_func_lowpc += ANOFFSET (delta, SECT_OFF_TEXT);
- objfile->ei.entry_func_highpc += ANOFFSET (delta, SECT_OFF_TEXT);
+ objfile->ei.entry_func_lowpc += ANOFFSET (delta, SECT_OFF_TEXT (objfile));
+ objfile->ei.entry_func_highpc += ANOFFSET (delta, SECT_OFF_TEXT (objfile));
}
if (objfile->ei.entry_file_lowpc != INVALID_ENTRY_LOWPC)
{
- objfile->ei.entry_file_lowpc += ANOFFSET (delta, SECT_OFF_TEXT);
- objfile->ei.entry_file_highpc += ANOFFSET (delta, SECT_OFF_TEXT);
+ objfile->ei.entry_file_lowpc += ANOFFSET (delta, SECT_OFF_TEXT (objfile));
+ objfile->ei.entry_file_highpc += ANOFFSET (delta, SECT_OFF_TEXT (objfile));
}
if (objfile->ei.main_func_lowpc != INVALID_ENTRY_LOWPC)
{
- objfile->ei.main_func_lowpc += ANOFFSET (delta, SECT_OFF_TEXT);
- objfile->ei.main_func_highpc += ANOFFSET (delta, SECT_OFF_TEXT);
+ objfile->ei.main_func_lowpc += ANOFFSET (delta, SECT_OFF_TEXT (objfile));
+ objfile->ei.main_func_highpc += ANOFFSET (delta, SECT_OFF_TEXT (objfile));
}
/* Relocate breakpoints as necessary, after things are relocated. */
struct section_offsets *section_offsets;
int num_sections;
+ /* Indexes in the section_offsets array. These are initialized by the
+ *_symfile_offsets() family of functions (som_symfile_offsets,
+ xcoff_symfile_offsets, default_symfile_offsets). In theory they
+ should correspond to the section indexes used by bfd for the
+ current objfile. The exception to this for the time being is the
+ SOM version. */
+
+ int sect_index_text;
+ int sect_index_data;
+ int sect_index_bss;
+ int sect_index_rodata;
+
/* These pointers are used to locate the section table, which
among other things, is used to map pc addresses into sections.
SECTIONS points to the first entry in the table, and
ALL_OBJFILES (objfile) \
ALL_OBJFILE_OSECTIONS (objfile, osect)
+#define SECT_OFF_DATA(objfile) \
+ ((objfile->sect_index_data == -1) ? \
+ (internal_error ("sect_index_data not initialized"), -1) : objfile->sect_index_data)
+
+#define SECT_OFF_RODATA(objfile) \
+ ((objfile->sect_index_rodata == -1) ? \
+ (internal_error ("sect_index_rodata not initialized"), -1) : objfile->sect_index_rodata)
+
+#define SECT_OFF_TEXT(objfile) \
+ ((objfile->sect_index_text == -1) ? \
+ (internal_error ("sect_index_text not initialized"), -1) : objfile->sect_index_text)
+
+#define SECT_OFF_BSS(objfile) \
+ ((objfile->sect_index_bss == -1) ? \
+ (internal_error ("sect_index_bss not initialized"), -1) : objfile->sect_index_bss)
+
#endif /* !defined (OBJFILES_H) */
{
case N_TEXT:
ms_type = mst_text;
- address += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT);
+ address += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
break;
case N_DATA:
ms_type = mst_data;
#ifdef END_OF_TEXT_DEFAULT
end_of_text_addr = END_OF_TEXT_DEFAULT;
#else
- end_of_text_addr = text_addr + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT)
+ end_of_text_addr = text_addr + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile))
+ text_size; /* Relocate */
#endif
continue;
case N_SYM_SE:
- CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT);
+ CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
if (psymfile_depth == 1 && pst)
{
os9k_end_psymtab (pst, psymtab_include_list, includes_used,
valu = CUR_SYMBOL_VALUE;
if (valu)
- valu += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT);
+ valu += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
past_first_source_file = 1;
p = strchr (namestring, ':');
continue;
case 'f':
- CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT);
+ CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
if (pst && pst->textlow == 0)
pst->textlow = CUR_SYMBOL_VALUE;
continue;
case 'F':
- CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT);
+ CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
if (pst && pst->textlow == 0)
pst->textlow = CUR_SYMBOL_VALUE;
}
case N_SYM_RBRAC:
- CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT);
+ CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
#ifdef HANDLE_RBRAC
HANDLE_RBRAC (CUR_SYMBOL_VALUE);
continue;
which comes from pst->textlow is correct. */
if (last_source_start_addr == 0)
last_source_start_addr = text_offset;
- pst->symtab = end_symtab (text_offset + text_size, objfile, SECT_OFF_TEXT);
+ pst->symtab = end_symtab (text_offset + text_size, objfile, SECT_OFF_TEXT (objfile));
end_stabs ();
}
\f
case N_SYM_LBRAC:
/* On most machines, the block addresses are relative to the
N_SO, the linker did not relocate them (sigh). */
- valu += ANOFFSET (section_offsets, SECT_OFF_TEXT);
+ valu += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
new = push_context (desc, valu);
break;
case N_SYM_RBRAC:
- valu += ANOFFSET (section_offsets, SECT_OFF_TEXT);
+ valu += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
new = pop_context ();
#if !defined (OS9K_VARIABLES_INSIDE_BLOCK)
one line-number -- core-address correspondence.
Enter it in the line list for this symbol table. */
/* Relocate for dynamic loading and for ELF acc fn-relative syms. */
- valu += ANOFFSET (section_offsets, SECT_OFF_TEXT);
+ valu += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
/* FIXME: loses if sizeof (char *) > sizeof (int) */
record_line (current_subfile, (int) name, valu);
break;
switch (deftype)
{
case 'S':
- valu += ANOFFSET (section_offsets, SECT_OFF_TEXT);
+ valu += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
n = strrchr (name, '/');
if (n != NULL)
{
{
if (last_source_file)
{
- end_symtab (valu, objfile, SECT_OFF_TEXT);
+ end_symtab (valu, objfile, SECT_OFF_TEXT (objfile));
end_stabs ();
}
start_stabs ();
case 'f':
case 'F':
- valu += ANOFFSET (section_offsets, SECT_OFF_TEXT);
+ valu += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
function_stab_type = type;
within_function = 1;
case 'V':
case 'v':
- valu += ANOFFSET (section_offsets, SECT_OFF_DATA);
+ valu += ANOFFSET (section_offsets, SECT_OFF_DATA (objfile));
define_symbol (valu, name, desc, type, objfile);
break;
return;
}
- ANOFFSET (so->objfile->section_offsets, SECT_OFF_TEXT)
+ ANOFFSET (so->objfile->section_offsets, SECT_OFF_TEXT (so->objfile))
= so->pa64_solib_desc.text_base;
- ANOFFSET (so->objfile->section_offsets, SECT_OFF_DATA)
+ ANOFFSET (so->objfile->section_offsets, SECT_OFF_DATA (so->objfile))
= so->pa64_solib_desc.data_base;
/* Relocate all the sections based on where they got loaded. */
{
if (p->the_bfd_section->flags & SEC_CODE)
{
- p->addr += ANOFFSET (so->objfile->section_offsets, SECT_OFF_TEXT);
- p->endaddr += ANOFFSET (so->objfile->section_offsets, SECT_OFF_TEXT);
+ p->addr += ANOFFSET (so->objfile->section_offsets, SECT_OFF_TEXT (so->objfile));
+ p->endaddr += ANOFFSET (so->objfile->section_offsets, SECT_OFF_TEXT (so->objfile));
}
else if (p->the_bfd_section->flags & SEC_DATA)
{
- p->addr += ANOFFSET (so->objfile->section_offsets, SECT_OFF_DATA);
- p->endaddr += ANOFFSET (so->objfile->section_offsets, SECT_OFF_DATA);
+ p->addr += ANOFFSET (so->objfile->section_offsets, SECT_OFF_DATA (so->objfile));
+ p->endaddr += ANOFFSET (so->objfile->section_offsets, SECT_OFF_DATA (so->objfile));
}
}
case N_TEXT | N_EXT:
case N_NBTEXT | N_EXT:
- CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT);
+ CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
goto record_it;
case N_DATA | N_EXT:
case N_NBDATA | N_EXT:
- CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA);
+ CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile));
goto record_it;
case N_BSS:
case N_BSS | N_EXT:
case N_NBBSS | N_EXT:
case N_SETV | N_EXT: /* FIXME, is this in BSS? */
- CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_BSS);
+ CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_BSS (objfile));
goto record_it;
case N_ABS | N_EXT:
case N_FN_SEQ:
case N_TEXT:
#ifdef DBXREAD_ONLY
- CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT);
+ CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
SET_NAMESTRING ();
if ((namestring[0] == '-' && namestring[1] == 'l')
|| (namestring[(nsl = strlen (namestring)) - 1] == 'o'
continue;
case N_DATA:
- CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA);
+ CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile));
goto record_it;
case N_UNDF | N_EXT:
char *p;
int prev_textlow_not_set;
- valu = CUR_SYMBOL_VALUE + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT);
+ valu = CUR_SYMBOL_VALUE + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
prev_textlow_not_set = textlow_not_set;
switch (p[1])
{
case 'S':
- CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA);
+ CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile));
#ifdef STATIC_TRANSFORM_NAME
namestring = STATIC_TRANSFORM_NAME (namestring);
#endif
psymtab_language, objfile);
continue;
case 'G':
- CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA);
+ CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile));
/* The addresses in these entries are reported to be
wrong. See the code that reads 'G's for symtabs. */
add_psymbol_to_list (namestring, p - namestring,
continue;
case 'f':
- CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT);
+ CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
#ifdef DBXREAD_ONLY
/* Kludges for ELF/STABS with Sun ACC */
last_function_name = namestring;
if (textlow_not_set
|| (CUR_SYMBOL_VALUE < pst->textlow
&& CUR_SYMBOL_VALUE
- != ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT)))
+ != ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile))))
{
pst->textlow = CUR_SYMBOL_VALUE;
textlow_not_set = 0;
are put into the global psymtab like one would expect.
They're also in the minimal symbol table. */
case 'F':
- CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT);
+ CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
#ifdef DBXREAD_ONLY
/* Kludges for ELF/STABS with Sun ACC */
last_function_name = namestring;
/* Do not fix textlow==0 for .o or NLM files, as 0 is a legit
value for the bottom of the text seg in those cases. */
if (CUR_SYMBOL_VALUE == ANOFFSET (objfile->section_offsets,
- SECT_OFF_TEXT))
+ SECT_OFF_TEXT (objfile)))
CUR_SYMBOL_VALUE =
find_stab_function_addr (namestring, pst->filename, objfile);
if (pst && textlow_not_set)
if (textlow_not_set
|| (CUR_SYMBOL_VALUE < pst->textlow
&& CUR_SYMBOL_VALUE
- != ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT)))
+ != ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile))))
{
pst->textlow = CUR_SYMBOL_VALUE;
textlow_not_set = 0;
new_symfile_objfile (obj_sec->objfile, 1, 0);
offs = (struct section_offsets *) alloca (SIZEOF_SECTION_OFFSETS);
memcpy (offs, symfile_objfile->section_offsets, SIZEOF_SECTION_OFFSETS);
- ANOFFSET (offs, SECT_OFF_DATA) = addr;
- ANOFFSET (offs, SECT_OFF_BSS) = addr;
+ ANOFFSET (offs, SECT_OFF_DATA (symfile_objfile)) = addr;
+ ANOFFSET (offs, SECT_OFF_BSS (symfile_objfile)) = addr;
objfile_relocate (symfile_objfile, offs);
}
bfd_map_over_sections (objfile->obfd, find_sect, &ss);
/* Both COFF and b.out frontends use these SECT_OFF_* values. */
- ANOFFSET (offs, SECT_OFF_TEXT) = text_addr - ss.text_start;
- ANOFFSET (offs, SECT_OFF_DATA) = data_addr - ss.data_start;
- ANOFFSET (offs, SECT_OFF_BSS) = bss_addr - ss.bss_start;
+ ANOFFSET (offs, SECT_OFF_TEXT (so->objfile)) = text_addr - ss.text_start;
+ ANOFFSET (offs, SECT_OFF_DATA (so->objfile)) = data_addr - ss.data_start;
+ ANOFFSET (offs, SECT_OFF_BSS (so->objfile)) = bss_addr - ss.bss_start;
objfile_relocate (objfile, offs);
}
offs = (struct section_offsets *) alloca (SIZEOF_SECTION_OFFSETS);
memcpy (offs, symfile_objfile->section_offsets, SIZEOF_SECTION_OFFSETS);
- ANOFFSET (offs, SECT_OFF_TEXT) = text_addr;
+ ANOFFSET (offs, SECT_OFF_TEXT (symfile_objfile)) = text_addr;
/* This is a temporary kludge to force data and bss to use the same offsets
because that's what nlmconv does now. The real solution requires changes
to the stub and remote.c that I don't have time to do right now. */
- ANOFFSET (offs, SECT_OFF_DATA) = data_addr;
- ANOFFSET (offs, SECT_OFF_BSS) = data_addr;
+ ANOFFSET (offs, SECT_OFF_DATA (symfile_objfile)) = data_addr;
+ ANOFFSET (offs, SECT_OFF_BSS (symfile_objfile)) = data_addr;
objfile_relocate (symfile_objfile, offs);
}
offs = (struct section_offsets *) alloca (SIZEOF_SECTION_OFFSETS);
memcpy (offs, symfile_objfile->section_offsets, SIZEOF_SECTION_OFFSETS);
- ANOFFSET (offs, SECT_OFF_TEXT) = text_off;
- ANOFFSET (offs, SECT_OFF_DATA) = data_off;
- ANOFFSET (offs, SECT_OFF_BSS) = bss_off;
+ ANOFFSET (offs, SECT_OFF_TEXT (symfile_objfile)) = text_off;
+ ANOFFSET (offs, SECT_OFF_DATA (symfile_objfile)) = data_off;
+ ANOFFSET (offs, SECT_OFF_BSS (symfile_objfile)) = bss_off;
/* First call the standard objfile_relocate. */
objfile_relocate (symfile_objfile, offs);
/* 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);
}
objfile->section_offsets = (struct section_offsets *)
obstack_alloc (&objfile->psymbol_obstack, SIZEOF_SECTION_OFFSETS);
+ /* FIXME: ezannoni 2000-04-20 The section names in SOM are not
+ .text, .data, etc, but $TEXT$, $DATA$,... We should initialize
+ SET_OFF_* from bfd. (See default_symfile_offsets()). But I don't
+ know the correspondence between SOM sections and GDB's idea of
+ section names. So for now we default to what is was before these
+ changes.*/
+ objfile->sect_index_text = 0;
+ objfile->sect_index_data = 1;
+ objfile->sect_index_bss = 2;
+ objfile->sect_index_rodata = 3;
+
/* First see if we're a shared library. If so, get the section
offsets from the library, else get them from addrs. */
if (!som_solib_section_offsets (objfile, objfile->section_offsets))
{
+ /* Note: Here is OK to compare with ".text" because this is the
+ name that gdb itself gives to that section, not the SOM
+ name. */
for (i = 0; i < SECT_OFF_MAX && addrs->other[i].name; i++)
if (strcmp (addrs->other[i].name, ".text") == 0)
break;
{
if (p->the_bfd_section->flags & SEC_CODE)
{
- p->addr += ANOFFSET (so->objfile->section_offsets, SECT_OFF_TEXT);
- p->endaddr += ANOFFSET (so->objfile->section_offsets, SECT_OFF_TEXT);
+ p->addr += ANOFFSET (so->objfile->section_offsets, SECT_OFF_TEXT (so->objfile));
+ p->endaddr += ANOFFSET (so->objfile->section_offsets, SECT_OFF_TEXT (so->objfile));
}
else if (p->the_bfd_section->flags & SEC_DATA)
{
- p->addr += ANOFFSET (so->objfile->section_offsets, SECT_OFF_DATA);
- p->endaddr += ANOFFSET (so->objfile->section_offsets, SECT_OFF_DATA);
+ p->addr += ANOFFSET (so->objfile->section_offsets, SECT_OFF_DATA (so->objfile));
+ p->endaddr += ANOFFSET (so->objfile->section_offsets, SECT_OFF_DATA (so->objfile));
}
}
asection *private_section;
/* The text offset is easy. */
- ANOFFSET (offsets, SECT_OFF_TEXT)
+ ANOFFSET (offsets, SECT_OFF_TEXT (objfile))
= (so_list->som_solib.text_addr
- so_list->som_solib.text_link_addr);
- ANOFFSET (offsets, SECT_OFF_RODATA)
- = ANOFFSET (offsets, SECT_OFF_TEXT);
+ ANOFFSET (offsets, SECT_OFF_RODATA (objfile))
+ = ANOFFSET (offsets, SECT_OFF_TEXT (objfile));
/* We should look at presumed_dp in the SOM header, but
that's not easily available. This should be OK though. */
if (!private_section)
{
warning ("Unable to find $PRIVATE$ in shared library!");
- ANOFFSET (offsets, SECT_OFF_DATA) = 0;
- ANOFFSET (offsets, SECT_OFF_BSS) = 0;
+ ANOFFSET (offsets, SECT_OFF_DATA (objfile)) = 0;
+ ANOFFSET (offsets, SECT_OFF_BSS (objfile)) = 0;
return 1;
}
- ANOFFSET (offsets, SECT_OFF_DATA)
+ ANOFFSET (offsets, SECT_OFF_DATA (objfile))
= (so_list->som_solib.data_start - private_section->vma);
- ANOFFSET (offsets, SECT_OFF_BSS)
- = ANOFFSET (offsets, SECT_OFF_DATA);
+ ANOFFSET (offsets, SECT_OFF_BSS (objfile))
+ = ANOFFSET (offsets, SECT_OFF_DATA (objfile));
return 1;
}
so_list = so_list->next;
switch (type & N_TYPE)
{
case N_TEXT:
- SYMBOL_SECTION (sym) = SECT_OFF_TEXT;
+ SYMBOL_SECTION (sym) = SECT_OFF_TEXT (objfile);
break;
case N_DATA:
- SYMBOL_SECTION (sym) = SECT_OFF_DATA;
+ SYMBOL_SECTION (sym) = SECT_OFF_DATA (objfile);
break;
case N_BSS:
- SYMBOL_SECTION (sym) = SECT_OFF_BSS;
+ SYMBOL_SECTION (sym) = SECT_OFF_BSS (objfile);
break;
}
struct section_addr_info *addrs;
{
int i;
+ asection *sect = NULL;
objfile->num_sections = SECT_OFF_MAX;
objfile->section_offsets = (struct section_offsets *)
obstack_alloc (&objfile->psymbol_obstack, SIZEOF_SECTION_OFFSETS);
memset (objfile->section_offsets, 0, SIZEOF_SECTION_OFFSETS);
- /* Now calculate offsets for other sections. */
+ /* Now calculate offsets for section that were specified by the
+ caller. */
for (i = 0; i < MAX_SECTIONS && addrs->other[i].name; i++)
{
struct other_sections *osp ;
osp = &addrs->other[i] ;
- if (addrs->other[i].addr == 0)
+ if (osp->addr == 0)
continue;
-#if 0
- if (strcmp (".text", osp->name) == 0)
- SECT_OFF_TEXT = osp->sectindex ;
- else if (strcmp (".data", osp->name) == 0)
- SECT_OFF_DATA = osp->sectindex ;
- else if (strcmp (".bss", osp->name) == 0)
- SECT_OFF_BSS = osp->sectindex ;
-#endif
+
/* Record all sections in offsets */
+ /* The section_offsets in the objfile are here filled in using
+ the BFD index. */
ANOFFSET (objfile->section_offsets, osp->sectindex) = osp->addr;
}
-}
+ /* Remember the bfd indexes for the .text, .data, .bss and
+ .rodata sections. */
+
+ sect = bfd_get_section_by_name (objfile->obfd, ".text");
+ if (sect)
+ objfile->sect_index_text = sect->index;
+
+ sect = bfd_get_section_by_name (objfile->obfd, ".data");
+ if (sect)
+ objfile->sect_index_data = sect->index;
+
+ sect = bfd_get_section_by_name (objfile->obfd, ".bss");
+ if (sect)
+ objfile->sect_index_bss = sect->index;
+
+ sect = bfd_get_section_by_name (objfile->obfd, ".rodata");
+ if (sect)
+ objfile->sect_index_rodata = sect->index;
+
+}
/* Process a symbol file, as either the main file or as a dynamically
loaded file.
if (lower_sect == NULL)
warning ("no loadable sections found in added symbol-file %s",
objfile->name);
- else if ((bfd_get_section_flags (objfile->obfd, lower_sect) & SEC_CODE)
- == 0)
- warning ("Lowest section in %s is %s at %s",
- objfile->name,
- bfd_section_name (objfile->obfd, lower_sect),
- paddr (bfd_section_vma (objfile->obfd, lower_sect)));
+ else
+ if ((bfd_get_section_flags (objfile->obfd, lower_sect) & SEC_CODE) == 0)
+ warning ("Lowest section in %s is %s at %s",
+ objfile->name,
+ bfd_section_name (objfile->obfd, lower_sect),
+ paddr (bfd_section_vma (objfile->obfd, lower_sect)));
if (lower_sect != NULL)
lower_offset = bfd_section_vma (objfile->obfd, lower_sect);
else
int targ_index;
int *resultp;
asection **bfd_sect;
+ struct objfile *objfile;
};
static void find_targ_sec PARAMS ((bfd *, asection *, void *));
PTR obj;
{
struct find_targ_sec_arg *args = (struct find_targ_sec_arg *) obj;
+ struct objfile *objfile = args->objfile;
if (sect->target_index == args->targ_index)
{
/* This is the section. Figure out what SECT_OFF_* code it is. */
if (bfd_get_section_flags (abfd, sect) & SEC_CODE)
- *args->resultp = SECT_OFF_TEXT;
+ *args->resultp = SECT_OFF_TEXT (objfile);
else if (bfd_get_section_flags (abfd, sect) & SEC_LOAD)
- *args->resultp = SECT_OFF_DATA;
+ *args->resultp = SECT_OFF_DATA (objfile);
else
- *args->resultp = SECT_OFF_BSS;
+ *args->resultp = SECT_OFF_BSS (objfile);
*args->bfd_sect = sect;
}
}
int secnum;
struct objfile *objfile;
{
- int off = SECT_OFF_TEXT;
+ int off = SECT_OFF_TEXT (objfile);
asection *sect = NULL;
struct find_targ_sec_arg args;
args.targ_index = secnum;
args.resultp = &off;
args.bfd_sect = §
+ args.objfile = objfile;
bfd_map_over_sections (objfile->obfd, find_targ_sec, &args);
return off;
}
int secnum;
struct objfile *objfile;
{
- int off = SECT_OFF_TEXT;
+ int off = SECT_OFF_TEXT (objfile);
asection *sect = NULL;
struct find_targ_sec_arg args;
args.targ_index = secnum;
? int_lnno.l_addr.l_paddr
: read_symbol_nvalue (int_lnno.l_addr.l_symndx));
addr += ANOFFSET (this_symtab_psymtab->objfile->section_offsets,
- SECT_OFF_TEXT);
+ SECT_OFF_TEXT (this_symtab_psymtab->objfile));
if (addr < startaddr || (endaddr && addr >= endaddr))
return;
if (last_source_file)
{
pst->symtab =
- end_symtab (cur_src_end_addr, objfile, SECT_OFF_TEXT);
+ end_symtab (cur_src_end_addr, objfile, SECT_OFF_TEXT (objfile));
end_stabs ();
}
{
complete_symtab (filestring, file_start_addr);
cur_src_end_addr = file_end_addr;
- end_symtab (file_end_addr, objfile, SECT_OFF_TEXT);
+ end_symtab (file_end_addr, objfile, SECT_OFF_TEXT (objfile));
end_stabs ();
start_stabs ();
/* Give all csects for this source file the same
file_start_addr =
cs->c_value + ANOFFSET (objfile->section_offsets,
- SECT_OFF_TEXT);
+ SECT_OFF_TEXT (objfile));
file_end_addr = file_start_addr + CSECT_LEN (&main_aux);
if (cs->c_name && cs->c_name[0] == '.')
complete_symtab (filestring, file_start_addr);
cur_src_end_addr = file_end_addr;
- end_symtab (file_end_addr, objfile, SECT_OFF_TEXT);
+ end_symtab (file_end_addr, objfile, SECT_OFF_TEXT (objfile));
end_stabs ();
/* XCOFF, according to the AIX 3.2 documentation, puts the filename
if (STREQ (cs->c_name, ".bf"))
{
CORE_ADDR off = ANOFFSET (objfile->section_offsets,
- SECT_OFF_TEXT);
+ SECT_OFF_TEXT (objfile));
bfd_coff_swap_aux_in (abfd, raw_auxptr, cs->c_type, cs->c_sclass,
0, cs->c_naux, &main_aux);
(fcn_cs_saved.c_value + off,
fcn_stab_saved.c_name, 0, 0, objfile);
if (new->name != NULL)
- SYMBOL_SECTION (new->name) = SECT_OFF_TEXT;
+ SYMBOL_SECTION (new->name) = SECT_OFF_TEXT (objfile);
}
else if (STREQ (cs->c_name, ".ef"))
{
(fcn_cs_saved.c_value
+ fcn_aux_saved.x_sym.x_misc.x_fsize
+ ANOFFSET (objfile->section_offsets,
- SECT_OFF_TEXT)),
+ SECT_OFF_TEXT (objfile))),
objfile);
within_function = 0;
}
new = push_context (depth,
(cs->c_value
+ ANOFFSET (objfile->section_offsets,
- SECT_OFF_TEXT)));
+ SECT_OFF_TEXT (objfile))));
}
else if (STREQ (cs->c_name, ".eb"))
{
new->start_addr,
(cs->c_value
+ ANOFFSET (objfile->section_offsets,
- SECT_OFF_TEXT)),
+ SECT_OFF_TEXT (objfile))),
objfile);
}
local_symbols = new->locals;
complete_symtab (filestring, file_start_addr);
cur_src_end_addr = file_end_addr;
- s = end_symtab (file_end_addr, objfile, SECT_OFF_TEXT);
+ s = end_symtab (file_end_addr, objfile, SECT_OFF_TEXT (objfile));
/* When reading symbols for the last C_FILE of the objfile, try
to make sure that we set pst->symtab to the symtab for the
file, not to the _globals_ symtab. I'm not sure whether this
struct objfile *objfile;
struct section_addr_info *addrs;
{
+ asection *sect = NULL;
int i;
objfile->num_sections = SECT_OFF_MAX;
objfile->section_offsets = (struct section_offsets *)
obstack_alloc (&objfile->psymbol_obstack, SIZEOF_SECTION_OFFSETS);
- /* syms_from_objfile kindly subtracts from addr the bfd_section_vma
- of the .text section. This strikes me as wrong--whether the
- offset to be applied to symbol reading is relative to the start
- address of the section depends on the symbol format. In any
- event, this whole "addr" concept is pretty broken (it doesn't
- handle any section but .text sensibly), so just ignore the addr
- parameter and use 0. rs6000-nat.c will set the correct section
- offsets via objfile_relocate. */
+ /* Initialize the section indexes for future use. */
+ sect = bfd_get_section_by_name (objfile->obfd, ".text");
+ if (sect)
+ objfile->sect_index_text = sect->index;
+
+ sect = bfd_get_section_by_name (objfile->obfd, ".data");
+ if (sect)
+ objfile->sect_index_data = sect->index;
+
+ sect = bfd_get_section_by_name (objfile->obfd, ".bss");
+ if (sect)
+ objfile->sect_index_bss = sect->index;
+
+ sect = bfd_get_section_by_name (objfile->obfd, ".rodata");
+ if (sect)
+ objfile->sect_index_rodata = sect->index;
+
for (i = 0; i < objfile->num_sections; ++i)
- ANOFFSET (objfile->section_offsets, i) = 0;
+ {
+ /* syms_from_objfile kindly subtracts from addr the
+ bfd_section_vma of the .text section. This strikes me as
+ wrong--whether the offset to be applied to symbol reading is
+ relative to the start address of the section depends on the
+ symbol format. In any event, this whole "addr" concept is
+ pretty broken (it doesn't handle any section but .text
+ sensibly), so just ignore the addr parameter and use 0.
+ rs6000-nat.c will set the correct section offsets via
+ objfile_relocate. */
+ ANOFFSET (objfile->section_offsets, i) = 0;
+ }
}
/* Register our ability to parse symbols for xcoff BFD files. */