PR symtab/8424:

* blockframe.c (find_pc_partial_function_gnu_ifunc): Check
	SYMBOL_SECTION, not SYMBOL_OBJ_SECTION.
	* breakpoint.c (resolve_sal_pc): Update.
	* elfread.c (elf_gnu_ifunc_record_cache): Update.
	* findvar.c (struct minsym_lookup_data) <objfile>: New field.
	(minsym_lookup_iterator_cb): Use it.
	(default_read_var_value): Update.
	* hppa-hpux-tdep.c (hppa64_hpux_in_solib_call_trampoline):
	Update.
	* infcmd.c (jump_command): Update.
	* linespec.c (minsym_found): Update.
	* maint.c (maintenance_translate_address): Update.
	* minsyms.c (lookup_minimal_symbol_by_pc_section_1): Update.
	(prim_record_minimal_symbol_full): Don't set SYMBOL_OBJ_SECTION.
	* parse.c (write_exp_msymbol): Update.
	* printcmd.c (address_info): Update.
	* psymtab.c (find_pc_sect_psymbol): Update.
	(fixup_psymbol_section): Check SYMBOL_SECTION, not
	SYMBOL_OBJ_SECTION.
	(add_psymbol_to_bcache): Correctly initialize SYMBOL_SECTION.
	Don't initialize SYMBOL_OBJ_SECTION.
	* spu-tdep.c (spu_catch_start): Update.
	* stabsread.c (define_symbol): Don't set SYMBOL_SECTION.
	* symmisc.c (dump_msymbols, print_symbol): Update.
	* symtab.c (fixup_section): Don't set 'obj_section'.  Change
	how fallback section is computed.
	(fixup_symbol_section): Update.
	(find_pc_sect_symtab, find_function_start_sal, skip_prologue_sal):
	Update.
	(allocate_symbol, initialize_symbol, allocate_template_symbol):
	Initialize SYMBOL_SECTION.
	* symtab.h (struct general_symbol_info) <section>: Update comment.
	<obj_section>: Remove.
	(SYMBOL_OBJ_SECTION): Add 'objfile' argument.  Rewrite.
	(SYMBOL_OBJFILE): New macro.
This commit is contained in:
Tom Tromey 2013-04-08 20:18:11 +00:00
parent e6dc44a8f5
commit e27d198cc4
18 changed files with 125 additions and 75 deletions

View File

@ -1,3 +1,42 @@
2013-04-08 Tom Tromey <tromey@redhat.com>
PR symtab/8424:
* blockframe.c (find_pc_partial_function_gnu_ifunc): Check
SYMBOL_SECTION, not SYMBOL_OBJ_SECTION.
* breakpoint.c (resolve_sal_pc): Update.
* elfread.c (elf_gnu_ifunc_record_cache): Update.
* findvar.c (struct minsym_lookup_data) <objfile>: New field.
(minsym_lookup_iterator_cb): Use it.
(default_read_var_value): Update.
* hppa-hpux-tdep.c (hppa64_hpux_in_solib_call_trampoline):
Update.
* infcmd.c (jump_command): Update.
* linespec.c (minsym_found): Update.
* maint.c (maintenance_translate_address): Update.
* minsyms.c (lookup_minimal_symbol_by_pc_section_1): Update.
(prim_record_minimal_symbol_full): Don't set SYMBOL_OBJ_SECTION.
* parse.c (write_exp_msymbol): Update.
* printcmd.c (address_info): Update.
* psymtab.c (find_pc_sect_psymbol): Update.
(fixup_psymbol_section): Check SYMBOL_SECTION, not
SYMBOL_OBJ_SECTION.
(add_psymbol_to_bcache): Correctly initialize SYMBOL_SECTION.
Don't initialize SYMBOL_OBJ_SECTION.
* spu-tdep.c (spu_catch_start): Update.
* stabsread.c (define_symbol): Don't set SYMBOL_SECTION.
* symmisc.c (dump_msymbols, print_symbol): Update.
* symtab.c (fixup_section): Don't set 'obj_section'. Change
how fallback section is computed.
(fixup_symbol_section): Update.
(find_pc_sect_symtab, find_function_start_sal, skip_prologue_sal):
Update.
(allocate_symbol, initialize_symbol, allocate_template_symbol):
Initialize SYMBOL_SECTION.
* symtab.h (struct general_symbol_info) <section>: Update comment.
<obj_section>: Remove.
(SYMBOL_OBJ_SECTION): Add 'objfile' argument. Rewrite.
(SYMBOL_OBJFILE): New macro.
2013-04-08 Tom Tromey <tromey@redhat.com> 2013-04-08 Tom Tromey <tromey@redhat.com>
* coffread.c (record_minimal_symbol): Update. * coffread.c (record_minimal_symbol): Update.

View File

@ -292,8 +292,8 @@ find_pc_partial_function_gnu_ifunc (CORE_ADDR pc, const char **name,
{ {
if (SYMBOL_VALUE_ADDRESS (msymbol + i) if (SYMBOL_VALUE_ADDRESS (msymbol + i)
!= SYMBOL_VALUE_ADDRESS (msymbol) != SYMBOL_VALUE_ADDRESS (msymbol)
&& SYMBOL_OBJ_SECTION (msymbol + i) && SYMBOL_SECTION (msymbol + i)
== SYMBOL_OBJ_SECTION (msymbol)) == SYMBOL_SECTION (msymbol))
break; break;
} }

View File

@ -9814,7 +9814,7 @@ resolve_sal_pc (struct symtab_and_line *sal)
if (sym != NULL) if (sym != NULL)
{ {
fixup_symbol_section (sym, sal->symtab->objfile); fixup_symbol_section (sym, sal->symtab->objfile);
sal->section = SYMBOL_OBJ_SECTION (sym); sal->section = SYMBOL_OBJ_SECTION (sal->symtab->objfile, sym);
} }
else else
{ {
@ -9830,7 +9830,7 @@ resolve_sal_pc (struct symtab_and_line *sal)
msym = lookup_minimal_symbol_by_pc (sal->pc); msym = lookup_minimal_symbol_by_pc (sal->pc);
if (msym.minsym) if (msym.minsym)
sal->section = SYMBOL_OBJ_SECTION (msym.minsym); sal->section = SYMBOL_OBJ_SECTION (msym.objfile, msym.minsym);
do_cleanups (old_chain); do_cleanups (old_chain);
} }

View File

@ -752,8 +752,8 @@ elf_gnu_ifunc_record_cache (const char *name, CORE_ADDR addr)
if (SYMBOL_VALUE_ADDRESS (msym.minsym) != addr) if (SYMBOL_VALUE_ADDRESS (msym.minsym) != addr)
return 0; return 0;
/* minimal symbols have always SYMBOL_OBJ_SECTION non-NULL. */ /* minimal symbols have always SYMBOL_OBJ_SECTION non-NULL. */
sect = SYMBOL_OBJ_SECTION (msym.minsym)->the_bfd_section; sect = SYMBOL_OBJ_SECTION (msym.objfile, msym.minsym)->the_bfd_section;
objfile = SYMBOL_OBJ_SECTION (msym.minsym)->objfile; objfile = msym.objfile;
/* If .plt jumps back to .plt the symbol is still deferred for later /* If .plt jumps back to .plt the symbol is still deferred for later
resolution and it has no use for GDB. Besides ".text" this symbol can resolution and it has no use for GDB. Besides ".text" this symbol can

View File

@ -414,6 +414,9 @@ struct minsym_lookup_data
if found. It should be initialized to NULL before the search if found. It should be initialized to NULL before the search
is started. */ is started. */
struct minimal_symbol *result; struct minimal_symbol *result;
/* The objfile in which the symbol was found. */
struct objfile *objfile;
}; };
/* A callback function for gdbarch_iterate_over_objfiles_in_search_order. /* A callback function for gdbarch_iterate_over_objfiles_in_search_order.
@ -429,6 +432,7 @@ minsym_lookup_iterator_cb (struct objfile *objfile, void *cb_data)
gdb_assert (data->result == NULL); gdb_assert (data->result == NULL);
data->result = lookup_minimal_symbol (data->name, NULL, objfile); data->result = lookup_minimal_symbol (data->name, NULL, objfile);
data->objfile = objfile;
/* The iterator should stop iff a match was found. */ /* The iterator should stop iff a match was found. */
return (data->result != NULL); return (data->result != NULL);
@ -475,7 +479,8 @@ default_read_var_value (struct symbol *var, struct frame_info *frame)
{ {
CORE_ADDR addr CORE_ADDR addr
= symbol_overlayed_address (SYMBOL_VALUE_ADDRESS (var), = symbol_overlayed_address (SYMBOL_VALUE_ADDRESS (var),
SYMBOL_OBJ_SECTION (var)); SYMBOL_OBJ_SECTION (SYMBOL_OBJFILE (var),
var));
store_typed_address (value_contents_raw (v), type, addr); store_typed_address (value_contents_raw (v), type, addr);
} }
@ -496,7 +501,8 @@ default_read_var_value (struct symbol *var, struct frame_info *frame)
v = allocate_value_lazy (type); v = allocate_value_lazy (type);
if (overlay_debugging) if (overlay_debugging)
addr = symbol_overlayed_address (SYMBOL_VALUE_ADDRESS (var), addr = symbol_overlayed_address (SYMBOL_VALUE_ADDRESS (var),
SYMBOL_OBJ_SECTION (var)); SYMBOL_OBJ_SECTION (SYMBOL_OBJFILE (var),
var));
else else
addr = SYMBOL_VALUE_ADDRESS (var); addr = SYMBOL_VALUE_ADDRESS (var);
break; break;
@ -541,7 +547,8 @@ default_read_var_value (struct symbol *var, struct frame_info *frame)
v = allocate_value_lazy (type); v = allocate_value_lazy (type);
if (overlay_debugging) if (overlay_debugging)
addr = symbol_overlayed_address addr = symbol_overlayed_address
(BLOCK_START (SYMBOL_BLOCK_VALUE (var)), SYMBOL_OBJ_SECTION (var)); (BLOCK_START (SYMBOL_BLOCK_VALUE (var)), SYMBOL_OBJ_SECTION (SYMBOL_OBJFILE (var),
var));
else else
addr = BLOCK_START (SYMBOL_BLOCK_VALUE (var)); addr = BLOCK_START (SYMBOL_BLOCK_VALUE (var));
break; break;
@ -600,11 +607,12 @@ default_read_var_value (struct symbol *var, struct frame_info *frame)
error (_("No global symbol \"%s\"."), SYMBOL_LINKAGE_NAME (var)); error (_("No global symbol \"%s\"."), SYMBOL_LINKAGE_NAME (var));
if (overlay_debugging) if (overlay_debugging)
addr = symbol_overlayed_address (SYMBOL_VALUE_ADDRESS (msym), addr = symbol_overlayed_address (SYMBOL_VALUE_ADDRESS (msym),
SYMBOL_OBJ_SECTION (msym)); SYMBOL_OBJ_SECTION (lookup_data.objfile,
msym));
else else
addr = SYMBOL_VALUE_ADDRESS (msym); addr = SYMBOL_VALUE_ADDRESS (msym);
obj_section = SYMBOL_OBJ_SECTION (msym); obj_section = SYMBOL_OBJ_SECTION (lookup_data.objfile, msym);
if (obj_section if (obj_section
&& (obj_section->the_bfd_section->flags & SEC_THREAD_LOCAL) != 0) && (obj_section->the_bfd_section->flags & SEC_THREAD_LOCAL) != 0)
addr = target_translate_tls_address (obj_section->objfile, addr); addr = target_translate_tls_address (obj_section->objfile, addr);

View File

@ -184,7 +184,7 @@ hppa64_hpux_in_solib_call_trampoline (struct gdbarch *gdbarch,
if (! minsym.minsym) if (! minsym.minsym)
return 0; return 0;
sec = SYMBOL_OBJ_SECTION (minsym.minsym)->the_bfd_section; sec = SYMBOL_OBJ_SECTION (minsym.objfile, minsym.minsym)->the_bfd_section;
if (bfd_get_section_vma (sec->owner, sec) <= pc if (bfd_get_section_vma (sec->owner, sec) <= pc
&& pc < (bfd_get_section_vma (sec->owner, sec) && pc < (bfd_get_section_vma (sec->owner, sec)

View File

@ -1170,8 +1170,8 @@ jump_command (char *arg, int from_tty)
if (sfn != NULL) if (sfn != NULL)
{ {
fixup_symbol_section (sfn, 0); fixup_symbol_section (sfn, 0);
if (section_is_overlay (SYMBOL_OBJ_SECTION (sfn)) && if (section_is_overlay (SYMBOL_OBJ_SECTION (SYMBOL_OBJFILE (sfn), sfn)) &&
!section_is_mapped (SYMBOL_OBJ_SECTION (sfn))) !section_is_mapped (SYMBOL_OBJ_SECTION (SYMBOL_OBJFILE (sfn), sfn)))
{ {
if (!query (_("WARNING!!! Destination is in " if (!query (_("WARNING!!! Destination is in "
"unmapped overlay! Jump anyway? "))) "unmapped overlay! Jump anyway? ")))

View File

@ -3399,7 +3399,7 @@ minsym_found (struct linespec_state *self, struct objfile *objfile,
sal = find_pc_sect_line (SYMBOL_VALUE_ADDRESS (msymbol), sal = find_pc_sect_line (SYMBOL_VALUE_ADDRESS (msymbol),
(struct obj_section *) 0, 0); (struct obj_section *) 0, 0);
sal.section = SYMBOL_OBJ_SECTION (msymbol); sal.section = SYMBOL_OBJ_SECTION (objfile, msymbol);
/* The minimal symbol might point to a function descriptor; /* The minimal symbol might point to a function descriptor;
resolve it to the actual code address instead. */ resolve it to the actual code address instead. */

View File

@ -493,7 +493,7 @@ maintenance_translate_address (char *arg, int from_tty)
const char *symbol_offset const char *symbol_offset
= pulongest (address - SYMBOL_VALUE_ADDRESS (sym.minsym)); = pulongest (address - SYMBOL_VALUE_ADDRESS (sym.minsym));
sect = SYMBOL_OBJ_SECTION(sym.minsym); sect = SYMBOL_OBJ_SECTION(sym.objfile, sym.minsym);
if (sect != NULL) if (sect != NULL)
{ {
const char *section_name; const char *section_name;

View File

@ -593,9 +593,10 @@ lookup_minimal_symbol_by_pc_section_1 (CORE_ADDR pc,
/* Some types of debug info, such as COFF, /* Some types of debug info, such as COFF,
don't fill the bfd_section member, so don't don't fill the bfd_section member, so don't
throw away symbols on those platforms. */ throw away symbols on those platforms. */
&& SYMBOL_OBJ_SECTION (&msymbol[hi]) != NULL && SYMBOL_OBJ_SECTION (objfile, &msymbol[hi]) != NULL
&& (!matching_obj_sections && (!matching_obj_sections
(SYMBOL_OBJ_SECTION (&msymbol[hi]), section))) (SYMBOL_OBJ_SECTION (objfile, &msymbol[hi]),
section)))
{ {
hi--; hi--;
continue; continue;
@ -612,8 +613,8 @@ lookup_minimal_symbol_by_pc_section_1 (CORE_ADDR pc,
== MSYMBOL_SIZE (&msymbol[hi - 1])) == MSYMBOL_SIZE (&msymbol[hi - 1]))
&& (SYMBOL_VALUE_ADDRESS (&msymbol[hi]) && (SYMBOL_VALUE_ADDRESS (&msymbol[hi])
== SYMBOL_VALUE_ADDRESS (&msymbol[hi - 1])) == SYMBOL_VALUE_ADDRESS (&msymbol[hi - 1]))
&& (SYMBOL_OBJ_SECTION (&msymbol[hi]) && (SYMBOL_OBJ_SECTION (objfile, &msymbol[hi])
== SYMBOL_OBJ_SECTION (&msymbol[hi - 1]))) == SYMBOL_OBJ_SECTION (objfile, &msymbol[hi - 1])))
{ {
hi--; hi--;
continue; continue;
@ -942,7 +943,6 @@ prim_record_minimal_symbol_full (const char *name, int name_len, int copy_name,
SYMBOL_VALUE_ADDRESS (msymbol) = address; SYMBOL_VALUE_ADDRESS (msymbol) = address;
SYMBOL_SECTION (msymbol) = section; SYMBOL_SECTION (msymbol) = section;
SYMBOL_OBJ_SECTION (msymbol) = NULL;
MSYMBOL_TYPE (msymbol) = ms_type; MSYMBOL_TYPE (msymbol) = ms_type;
MSYMBOL_TARGET_FLAG_1 (msymbol) = 0; MSYMBOL_TARGET_FLAG_1 (msymbol) = 0;

View File

@ -502,7 +502,7 @@ write_exp_msymbol (struct minimal_symbol *msymbol)
struct gdbarch *gdbarch = get_objfile_arch (objfile); struct gdbarch *gdbarch = get_objfile_arch (objfile);
CORE_ADDR addr = SYMBOL_VALUE_ADDRESS (msymbol); CORE_ADDR addr = SYMBOL_VALUE_ADDRESS (msymbol);
struct obj_section *section = SYMBOL_OBJ_SECTION (msymbol); struct obj_section *section = SYMBOL_OBJ_SECTION (objfile, msymbol);
enum minimal_symbol_type type = MSYMBOL_TYPE (msymbol); enum minimal_symbol_type type = MSYMBOL_TYPE (msymbol);
CORE_ADDR pc; CORE_ADDR pc;

View File

@ -1219,7 +1219,9 @@ address_info (char *exp, int from_tty)
if (msymbol != NULL) if (msymbol != NULL)
{ {
gdbarch = get_objfile_arch (msymbol_objfile (msymbol)); struct objfile *objfile = msymbol_objfile (msymbol);
gdbarch = get_objfile_arch (objfile);
load_addr = SYMBOL_VALUE_ADDRESS (msymbol); load_addr = SYMBOL_VALUE_ADDRESS (msymbol);
printf_filtered ("Symbol \""); printf_filtered ("Symbol \"");
@ -1228,7 +1230,7 @@ address_info (char *exp, int from_tty)
printf_filtered ("\" is at "); printf_filtered ("\" is at ");
fputs_filtered (paddress (gdbarch, load_addr), gdb_stdout); fputs_filtered (paddress (gdbarch, load_addr), gdb_stdout);
printf_filtered (" in a file compiled without debugging"); printf_filtered (" in a file compiled without debugging");
section = SYMBOL_OBJ_SECTION (msymbol); section = SYMBOL_OBJ_SECTION (objfile, msymbol);
if (section_is_overlay (section)) if (section_is_overlay (section))
{ {
load_addr = overlay_unmapped_address (load_addr, section); load_addr = overlay_unmapped_address (load_addr, section);
@ -1249,7 +1251,7 @@ address_info (char *exp, int from_tty)
current_language->la_language, DMGL_ANSI); current_language->la_language, DMGL_ANSI);
printf_filtered ("\" is "); printf_filtered ("\" is ");
val = SYMBOL_VALUE (sym); val = SYMBOL_VALUE (sym);
section = SYMBOL_OBJ_SECTION (sym); section = SYMBOL_OBJ_SECTION (SYMBOL_OBJFILE (sym), sym);
gdbarch = get_objfile_arch (SYMBOL_SYMTAB (sym)->objfile); gdbarch = get_objfile_arch (SYMBOL_SYMTAB (sym)->objfile);
if (SYMBOL_COMPUTED_OPS (sym) != NULL) if (SYMBOL_COMPUTED_OPS (sym) != NULL)
@ -1354,15 +1356,15 @@ address_info (char *exp, int from_tty)
case LOC_UNRESOLVED: case LOC_UNRESOLVED:
{ {
struct minimal_symbol *msym; struct bound_minimal_symbol msym;
msym = lookup_minimal_symbol (SYMBOL_LINKAGE_NAME (sym), NULL, NULL); msym = lookup_minimal_symbol_and_objfile (SYMBOL_LINKAGE_NAME (sym));
if (msym == NULL) if (msym.minsym == NULL)
printf_filtered ("unresolved"); printf_filtered ("unresolved");
else else
{ {
section = SYMBOL_OBJ_SECTION (msym); section = SYMBOL_OBJ_SECTION (msym.objfile, msym.minsym);
load_addr = SYMBOL_VALUE_ADDRESS (msym); load_addr = SYMBOL_VALUE_ADDRESS (msym.minsym);
if (section if (section
&& (section->the_bfd_section->flags & SEC_THREAD_LOCAL) != 0) && (section->the_bfd_section->flags & SEC_THREAD_LOCAL) != 0)

View File

@ -429,7 +429,8 @@ find_pc_sect_psymbol (struct objfile *objfile,
if (section) /* Match on a specific section. */ if (section) /* Match on a specific section. */
{ {
fixup_psymbol_section (p, objfile); fixup_psymbol_section (p, objfile);
if (!matching_obj_sections (SYMBOL_OBJ_SECTION (p), section)) if (!matching_obj_sections (SYMBOL_OBJ_SECTION (objfile, p),
section))
continue; continue;
} }
best_pc = SYMBOL_VALUE_ADDRESS (p); best_pc = SYMBOL_VALUE_ADDRESS (p);
@ -453,7 +454,8 @@ find_pc_sect_psymbol (struct objfile *objfile,
if (section) /* Match on a specific section. */ if (section) /* Match on a specific section. */
{ {
fixup_psymbol_section (p, objfile); fixup_psymbol_section (p, objfile);
if (!matching_obj_sections (SYMBOL_OBJ_SECTION (p), section)) if (!matching_obj_sections (SYMBOL_OBJ_SECTION (objfile, p),
section))
continue; continue;
} }
best_pc = SYMBOL_VALUE_ADDRESS (p); best_pc = SYMBOL_VALUE_ADDRESS (p);
@ -469,7 +471,10 @@ fixup_psymbol_section (struct partial_symbol *psym, struct objfile *objfile)
{ {
CORE_ADDR addr; CORE_ADDR addr;
if (psym == NULL || SYMBOL_OBJ_SECTION (psym) != NULL) if (!psym)
return;
if (SYMBOL_SECTION (psym) >= 0)
return; return;
gdb_assert (objfile); gdb_assert (objfile);
@ -1603,8 +1608,7 @@ add_psymbol_to_bcache (const char *name, int namelength, int copy_name,
{ {
SYMBOL_VALUE_ADDRESS (&psymbol) = coreaddr; SYMBOL_VALUE_ADDRESS (&psymbol) = coreaddr;
} }
SYMBOL_SECTION (&psymbol) = 0; SYMBOL_SECTION (&psymbol) = -1;
SYMBOL_OBJ_SECTION (&psymbol) = NULL;
SYMBOL_SET_LANGUAGE (&psymbol, language, &objfile->objfile_obstack); SYMBOL_SET_LANGUAGE (&psymbol, language, &objfile->objfile_obstack);
PSYMBOL_DOMAIN (&psymbol) = domain; PSYMBOL_DOMAIN (&psymbol) = domain;
PSYMBOL_CLASS (&psymbol) = class; PSYMBOL_CLASS (&psymbol) = class;

View File

@ -1920,7 +1920,7 @@ spu_catch_start (struct objfile *objfile)
/* If we have debugging information, try to use it -- this /* If we have debugging information, try to use it -- this
will allow us to properly skip the prologue. */ will allow us to properly skip the prologue. */
pc = SYMBOL_VALUE_ADDRESS (minsym); pc = SYMBOL_VALUE_ADDRESS (minsym);
symtab = find_pc_sect_symtab (pc, SYMBOL_OBJ_SECTION (minsym)); symtab = find_pc_sect_symtab (pc, SYMBOL_OBJ_SECTION (objfile, minsym));
if (symtab != NULL) if (symtab != NULL)
{ {
struct blockvector *bv = BLOCKVECTOR (symtab); struct blockvector *bv = BLOCKVECTOR (symtab);

View File

@ -650,19 +650,6 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type,
current_symbol = sym = allocate_symbol (objfile); current_symbol = sym = allocate_symbol (objfile);
switch (type & N_TYPE)
{
case N_TEXT:
SYMBOL_SECTION (sym) = SECT_OFF_TEXT (objfile);
break;
case N_DATA:
SYMBOL_SECTION (sym) = SECT_OFF_DATA (objfile);
break;
case N_BSS:
SYMBOL_SECTION (sym) = SECT_OFF_BSS (objfile);
break;
}
if (processing_gcc_compilation) if (processing_gcc_compilation)
{ {
/* GCC 2.x puts the line number in desc. SunOS apparently puts in the /* GCC 2.x puts the line number in desc. SunOS apparently puts in the

View File

@ -218,7 +218,7 @@ dump_msymbols (struct objfile *objfile, struct ui_file *outfile)
index = 0; index = 0;
ALL_OBJFILE_MSYMBOLS (objfile, msymbol) ALL_OBJFILE_MSYMBOLS (objfile, msymbol)
{ {
struct obj_section *section = SYMBOL_OBJ_SECTION (msymbol); struct obj_section *section = SYMBOL_OBJ_SECTION (objfile, msymbol);
switch (MSYMBOL_TYPE (msymbol)) switch (MSYMBOL_TYPE (msymbol))
{ {
@ -464,7 +464,8 @@ print_symbol (void *args)
struct symbol *symbol = ((struct print_symbol_args *) args)->symbol; struct symbol *symbol = ((struct print_symbol_args *) args)->symbol;
int depth = ((struct print_symbol_args *) args)->depth; int depth = ((struct print_symbol_args *) args)->depth;
struct ui_file *outfile = ((struct print_symbol_args *) args)->outfile; struct ui_file *outfile = ((struct print_symbol_args *) args)->outfile;
struct obj_section *section = SYMBOL_OBJ_SECTION (symbol); struct obj_section *section = SYMBOL_OBJ_SECTION (SYMBOL_OBJFILE (symbol),
symbol);
print_spaces (depth, outfile); print_spaces (depth, outfile);
if (SYMBOL_DOMAIN (symbol) == LABEL_DOMAIN) if (SYMBOL_DOMAIN (symbol) == LABEL_DOMAIN)

View File

@ -1018,10 +1018,7 @@ fixup_section (struct general_symbol_info *ginfo,
point to the actual function code. */ point to the actual function code. */
msym = lookup_minimal_symbol_by_pc_name (addr, ginfo->name, objfile); msym = lookup_minimal_symbol_by_pc_name (addr, ginfo->name, objfile);
if (msym) if (msym)
{ ginfo->section = SYMBOL_SECTION (msym);
ginfo->obj_section = SYMBOL_OBJ_SECTION (msym);
ginfo->section = SYMBOL_SECTION (msym);
}
else else
{ {
/* Static, function-local variables do appear in the linker /* Static, function-local variables do appear in the linker
@ -1061,20 +1058,31 @@ fixup_section (struct general_symbol_info *ginfo,
a search of the section table. */ a search of the section table. */
struct obj_section *s; struct obj_section *s;
int fallback = -1;
ALL_OBJFILE_OSECTIONS (objfile, s) ALL_OBJFILE_OSECTIONS (objfile, s)
{ {
int idx = s - objfile->sections; int idx = s - objfile->sections;
CORE_ADDR offset = ANOFFSET (objfile->section_offsets, idx); CORE_ADDR offset = ANOFFSET (objfile->section_offsets, idx);
if (fallback == -1)
fallback = idx;
if (obj_section_addr (s) - offset <= addr if (obj_section_addr (s) - offset <= addr
&& addr < obj_section_endaddr (s) - offset) && addr < obj_section_endaddr (s) - offset)
{ {
ginfo->obj_section = s;
ginfo->section = idx; ginfo->section = idx;
return; return;
} }
} }
/* If we didn't find the section, assume it is in the first
section. If there is no allocated section, then it hardly
matters what we pick, so just pick zero. */
if (fallback == -1)
ginfo->section = 0;
else
ginfo->section = fallback;
} }
} }
@ -1086,9 +1094,6 @@ fixup_symbol_section (struct symbol *sym, struct objfile *objfile)
if (!sym) if (!sym)
return NULL; return NULL;
if (SYMBOL_OBJ_SECTION (sym))
return sym;
/* We either have an OBJFILE, or we can get at it from the sym's /* We either have an OBJFILE, or we can get at it from the sym's
symtab. Anything else is a bug. */ symtab. Anything else is a bug. */
gdb_assert (objfile || SYMBOL_SYMTAB (sym)); gdb_assert (objfile || SYMBOL_SYMTAB (sym));
@ -1096,6 +1101,9 @@ fixup_symbol_section (struct symbol *sym, struct objfile *objfile)
if (objfile == NULL) if (objfile == NULL)
objfile = SYMBOL_SYMTAB (sym)->objfile; objfile = SYMBOL_SYMTAB (sym)->objfile;
if (SYMBOL_OBJ_SECTION (objfile, sym))
return sym;
/* We should have an objfile by now. */ /* We should have an objfile by now. */
gdb_assert (objfile); gdb_assert (objfile);
@ -2131,7 +2139,8 @@ find_pc_sect_symtab (CORE_ADDR pc, struct obj_section *section)
ALL_BLOCK_SYMBOLS (b, iter, sym) ALL_BLOCK_SYMBOLS (b, iter, sym)
{ {
fixup_symbol_section (sym, objfile); fixup_symbol_section (sym, objfile);
if (matching_obj_sections (SYMBOL_OBJ_SECTION (sym), section)) if (matching_obj_sections (SYMBOL_OBJ_SECTION (objfile, sym),
section))
break; break;
} }
if (sym == NULL) if (sym == NULL)
@ -2763,7 +2772,7 @@ find_function_start_sal (struct symbol *sym, int funfirstline)
fixup_symbol_section (sym, NULL); fixup_symbol_section (sym, NULL);
sal = find_pc_sect_line (BLOCK_START (SYMBOL_BLOCK_VALUE (sym)), sal = find_pc_sect_line (BLOCK_START (SYMBOL_BLOCK_VALUE (sym)),
SYMBOL_OBJ_SECTION (sym), 0); SYMBOL_OBJ_SECTION (SYMBOL_OBJFILE (sym), sym), 0);
/* We always should have a line for the function start address. /* We always should have a line for the function start address.
If we don't, something is odd. Create a plain SAL refering If we don't, something is odd. Create a plain SAL refering
@ -2774,7 +2783,7 @@ find_function_start_sal (struct symbol *sym, int funfirstline)
init_sal (&sal); init_sal (&sal);
sal.pspace = current_program_space; sal.pspace = current_program_space;
sal.pc = BLOCK_START (SYMBOL_BLOCK_VALUE (sym)); sal.pc = BLOCK_START (SYMBOL_BLOCK_VALUE (sym));
sal.section = SYMBOL_OBJ_SECTION (sym); sal.section = SYMBOL_OBJ_SECTION (SYMBOL_OBJFILE (sym), sym);
} }
if (funfirstline) if (funfirstline)
@ -2815,7 +2824,7 @@ skip_prologue_sal (struct symtab_and_line *sal)
fixup_symbol_section (sym, NULL); fixup_symbol_section (sym, NULL);
pc = BLOCK_START (SYMBOL_BLOCK_VALUE (sym)); pc = BLOCK_START (SYMBOL_BLOCK_VALUE (sym));
section = SYMBOL_OBJ_SECTION (sym); section = SYMBOL_OBJ_SECTION (SYMBOL_OBJFILE (sym), sym);
name = SYMBOL_LINKAGE_NAME (sym); name = SYMBOL_LINKAGE_NAME (sym);
objfile = SYMBOL_SYMTAB (sym)->objfile; objfile = SYMBOL_SYMTAB (sym)->objfile;
} }
@ -2830,10 +2839,10 @@ skip_prologue_sal (struct symtab_and_line *sal)
return; return;
} }
pc = SYMBOL_VALUE_ADDRESS (msymbol);
section = SYMBOL_OBJ_SECTION (msymbol);
name = SYMBOL_LINKAGE_NAME (msymbol);
objfile = msymbol_objfile (msymbol); objfile = msymbol_objfile (msymbol);
pc = SYMBOL_VALUE_ADDRESS (msymbol);
section = SYMBOL_OBJ_SECTION (objfile, msymbol);
name = SYMBOL_LINKAGE_NAME (msymbol);
} }
gdbarch = get_objfile_arch (objfile); gdbarch = get_objfile_arch (objfile);
@ -5146,6 +5155,7 @@ void
initialize_symbol (struct symbol *sym) initialize_symbol (struct symbol *sym)
{ {
memset (sym, 0, sizeof (*sym)); memset (sym, 0, sizeof (*sym));
SYMBOL_SECTION (sym) = -1;
} }
/* Allocate and initialize a new 'struct symbol' on OBJFILE's /* Allocate and initialize a new 'struct symbol' on OBJFILE's
@ -5157,6 +5167,7 @@ allocate_symbol (struct objfile *objfile)
struct symbol *result; struct symbol *result;
result = OBSTACK_ZALLOC (&objfile->objfile_obstack, struct symbol); result = OBSTACK_ZALLOC (&objfile->objfile_obstack, struct symbol);
SYMBOL_SECTION (result) = -1;
return result; return result;
} }
@ -5170,6 +5181,7 @@ allocate_template_symbol (struct objfile *objfile)
struct template_symbol *result; struct template_symbol *result;
result = OBSTACK_ZALLOC (&objfile->objfile_obstack, struct template_symbol); result = OBSTACK_ZALLOC (&objfile->objfile_obstack, struct template_symbol);
SYMBOL_SECTION (&result->base) = -1;
return result; return result;
} }

View File

@ -165,16 +165,9 @@ struct general_symbol_info
/* Which section is this symbol in? This is an index into /* Which section is this symbol in? This is an index into
section_offsets for this objfile. Negative means that the symbol section_offsets for this objfile. Negative means that the symbol
does not get relocated relative to a section. does not get relocated relative to a section. */
Disclaimer: currently this is just used for xcoff, so don't
expect all symbol-reading code to set it correctly (the ELF code
also tries to set it correctly). */
short section; short section;
/* The section associated with this symbol. It can be NULL. */
struct obj_section *obj_section;
}; };
extern void symbol_set_demangled_name (struct general_symbol_info *, extern void symbol_set_demangled_name (struct general_symbol_info *,
@ -202,7 +195,10 @@ extern CORE_ADDR symbol_overlayed_address (CORE_ADDR, struct obj_section *);
#define SYMBOL_VALUE_CHAIN(symbol) (symbol)->ginfo.value.chain #define SYMBOL_VALUE_CHAIN(symbol) (symbol)->ginfo.value.chain
#define SYMBOL_LANGUAGE(symbol) (symbol)->ginfo.language #define SYMBOL_LANGUAGE(symbol) (symbol)->ginfo.language
#define SYMBOL_SECTION(symbol) (symbol)->ginfo.section #define SYMBOL_SECTION(symbol) (symbol)->ginfo.section
#define SYMBOL_OBJ_SECTION(symbol) (symbol)->ginfo.obj_section #define SYMBOL_OBJ_SECTION(objfile, symbol) \
(((symbol)->ginfo.section >= 0) \
? (&(((objfile)->sections)[(symbol)->ginfo.section])) \
: NULL)
/* Initializes the language dependent portion of a symbol /* Initializes the language dependent portion of a symbol
depending upon the language for the symbol. */ depending upon the language for the symbol. */
@ -731,6 +727,7 @@ extern const struct symbol_impl *symbol_impls;
#define SYMBOL_BLOCK_OPS(symbol) (SYMBOL_IMPL (symbol).ops_block) #define SYMBOL_BLOCK_OPS(symbol) (SYMBOL_IMPL (symbol).ops_block)
#define SYMBOL_REGISTER_OPS(symbol) (SYMBOL_IMPL (symbol).ops_register) #define SYMBOL_REGISTER_OPS(symbol) (SYMBOL_IMPL (symbol).ops_register)
#define SYMBOL_LOCATION_BATON(symbol) (symbol)->aux_value #define SYMBOL_LOCATION_BATON(symbol) (symbol)->aux_value
#define SYMBOL_OBJFILE(symbol) (SYMBOL_SYMTAB (symbol)->objfile)
extern int register_symbol_computed_impl (enum address_class, extern int register_symbol_computed_impl (enum address_class,
const struct symbol_computed_ops *); const struct symbol_computed_ops *);