}
}
-/* Return the section number (SECT_OFF_*) that CS points to. */
-static int
-secnum_to_section (int secnum, struct objfile *objfile)
-{
- int off = SECT_OFF_TEXT (objfile);
+/* Search all BFD sections for the section whose target_index is
+ equal to N_SCNUM. Set *BFD_SECT to that section. The section's
+ associated index in the objfile's section_offset table is also
+ stored in *SECNUM.
- asection *sect = NULL;
+ If no match is found, *BFD_SECT is set to NULL, and *SECNUM
+ is set to the text section's number. */
+
+static void
+xcoff_secnum_to_sections (int n_scnum, struct objfile *objfile,
+ asection **bfd_sect, int *secnum)
+{
struct find_targ_sec_arg args;
- args.targ_index = secnum;
- args.resultp = &off;
- args.bfd_sect = §
+
+ args.targ_index = n_scnum;
+ args.resultp = secnum;
+ args.bfd_sect = bfd_sect;
args.objfile = objfile;
+
+ *bfd_sect = NULL;
+ *secnum = SECT_OFF_TEXT (objfile);
+
bfd_map_over_sections (objfile->obfd, find_targ_sec, &args);
- return off;
}
-/* Return the BFD section that CS points to. */
+/* Return the section number (SECT_OFF_*) that N_SCNUM points to. */
+
+static int
+secnum_to_section (int n_scnum, struct objfile *objfile)
+{
+ int secnum;
+ asection *ignored;
+
+ xcoff_secnum_to_sections (n_scnum, objfile, &ignored, &secnum);
+ return secnum;
+}
+
+/* Return the BFD section that N_SCNUM points to. */
+
static asection *
-secnum_to_bfd_section (int secnum, struct objfile *objfile)
+secnum_to_bfd_section (int n_scnum, struct objfile *objfile)
{
- int off = SECT_OFF_TEXT (objfile);
+ int ignored;
+ asection *bfd_sect;
- 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 sect;
+ xcoff_secnum_to_sections (n_scnum, objfile, &bfd_sect, &ignored);
+ return bfd_sect;
}
\f
/* add a given stab string into given stab vector. */
This function can read past the end of the symbol table
(into the string table) but this does no harm. */
-/* Reading symbol table has to be fast! Keep the followings as macros, rather
- than functions. */
-
-#define RECORD_MINIMAL_SYMBOL(NAME, ADDR, TYPE, SECTION, OBJFILE) \
-{ \
- const char *namestr; \
- \
- namestr = (NAME); \
- if (namestr[0] == '.') ++namestr; \
- prim_record_minimal_symbol_and_info (namestr, (ADDR), (TYPE), \
- (SECTION), (asection *)NULL, \
- (OBJFILE)); \
- misc_func_recorded = 1; \
-}
+/* Create a new minimal symbol (using prim_record_minimal_symbol_and_info).
+
+ Arguments are:
+
+ NAME - the symbol's name (but if NAME starts with a period, that
+ leading period is discarded).
+ ADDRESS - the symbol's address.
+ MS_TYPE - the symbol's type.
+ N_SCNUM - the symbol's XCOFF section number.
+ OBJFILE - the objfile associated with the minimal symbol. */
+
+static void
+record_minimal_symbol (const char *name, CORE_ADDR address,
+ enum minimal_symbol_type ms_type,
+ int n_scnum,
+ struct objfile *objfile)
+{
+ struct find_targ_sec_arg args;
+ int secnum;
+ asection *bfd_sect;
+ if (name[0] == '.')
+ ++name;
+
+ xcoff_secnum_to_sections (n_scnum, objfile, &bfd_sect, &secnum);
+ prim_record_minimal_symbol_and_info (name, address, ms_type,
+ secnum, bfd_sect, objfile);
+}
/* xcoff has static blocks marked in `.bs', `.es' pairs. They cannot be
nested. At any given time, a symbol can only be in one static block.
if (!misc_func_recorded)
{
- RECORD_MINIMAL_SYMBOL
+ record_minimal_symbol
(last_csect_name, last_csect_val,
- mst_text, last_csect_sec,
- objfile);
+ mst_text, last_csect_sec, objfile);
+ misc_func_recorded = 1;
}
if (pst != NULL)
{
last_csect_name = namestring;
last_csect_val = symbol.n_value;
- last_csect_sec =
- secnum_to_section (symbol.n_scnum, objfile);
+ last_csect_sec = symbol.n_scnum;
}
if (pst != NULL)
{
(namestring, symbol.n_value,
sclass == C_HIDEXT ? mst_file_data : mst_data,
secnum_to_section (symbol.n_scnum, objfile),
- NULL, objfile);
+ secnum_to_bfd_section (symbol.n_scnum, objfile),
+ objfile);
break;
case XMC_TC0:
if (first_fun_line_offset == 0 && symbol.n_numaux > 1)
first_fun_line_offset =
main_aux[0].x_sym.x_fcnary.x_fcn.x_lnnoptr;
- RECORD_MINIMAL_SYMBOL
- (namestring, symbol.n_value,
- sclass == C_HIDEXT ? mst_file_text : mst_text,
- secnum_to_section (symbol.n_scnum, objfile),
- objfile);
+ {
+ record_minimal_symbol
+ (namestring, symbol.n_value,
+ sclass == C_HIDEXT ? mst_file_text : mst_text,
+ symbol.n_scnum, objfile);
+ misc_func_recorded = 1;
+ }
break;
case XMC_GL:
mst_solib_trampoline symbol. When we lookup mst
symbols, we will choose mst_text over
mst_solib_trampoline. */
- RECORD_MINIMAL_SYMBOL
+ record_minimal_symbol
(namestring, symbol.n_value,
- mst_solib_trampoline,
- secnum_to_section (symbol.n_scnum, objfile),
- objfile);
+ mst_solib_trampoline, symbol.n_scnum, objfile);
+ misc_func_recorded = 1;
break;
case XMC_DS:
(namestring, symbol.n_value,
sclass == C_HIDEXT ? mst_file_data : mst_data,
secnum_to_section (symbol.n_scnum, objfile),
- NULL, objfile);
+ secnum_to_bfd_section (symbol.n_scnum, objfile),
+ objfile);
break;
}
break;
(namestring, symbol.n_value,
sclass == C_HIDEXT ? mst_file_bss : mst_bss,
secnum_to_section (symbol.n_scnum, objfile),
- NULL, objfile);
+ secnum_to_bfd_section (symbol.n_scnum, objfile),
+ objfile);
break;
}
break;
it as a function. This will take care of functions like
strcmp() compiled by xlc. */
- RECORD_MINIMAL_SYMBOL
- (last_csect_name, last_csect_val,
- mst_text, last_csect_sec, objfile);
+ record_minimal_symbol (last_csect_name, last_csect_val,
+ mst_text, last_csect_sec, objfile);
+ misc_func_recorded = 1;
}
if (pst)