+2014-02-26 Tom Tromey <tromey@redhat.com>
+
+ * minsyms.c (msymbols_sort): Remove.
+ * minsyms.h (msymbols_sort): Remove.
+ * objfiles.c (objfile_relocate1): Don't relocate minsyms.
+ * symtab.h (MSYMBOL_VALUE_ADDRESS): Use objfile offsets.
+ * elfread.c (elf_symtab_read): Don't add section offsets.
+ * xcoffread.c (record_minimal_symbol): Don't add section offset
+ to minimal symbol address.
+ * somread.c (text_offset, data_offset): Remove.
+ (som_symtab_read): Don't add section offsets to minimal symbol
+ addresses.
+ * coff-pe-read.c (add_pe_forwarded_sym, read_pe_exported_syms):
+ Don't add section offsets to minimal symbols.
+ * coffread.c (coff_symtab_read): Don't add section offsets
+ to minimal symbol addresses.
+ * machoread.c (macho_symtab_add_minsym): Don't add section offset
+ to minimal symbol addresses.
+ * mipsread.c (read_alphacoff_dynamic_symtab): Don't add
+ section offset to minimal symbol addresses.
+ * mdebugread.c (parse_partial_symbols): Don't add section
+ offset to minimal symbol addresses.
+ * dbxread.c (read_dbx_dynamic_symtab): Don't add section
+ offset to minimal symbol addresses.
+
2014-02-26 Tom Tromey <tromey@redhat.com>
* ada-lang.c (ada_main_name): Update.
const char *forward_func_name, int ordinal,
const char *dll_name, struct objfile *objfile)
{
- CORE_ADDR vma;
+ CORE_ADDR vma, baseaddr;
struct bound_minimal_symbol msymbol;
enum minimal_symbol_type msymtype;
char *qualified_name, *bare_name;
qualified_name = xstrprintf ("%s!%s", dll_name, bare_name);
- prim_record_minimal_symbol_and_info (qualified_name, vma, msymtype,
- section, objfile);
+ /* Note that this code makes a minimal symbol whose value may point
+ outside of any section in this objfile. These symbols can't
+ really be relocated properly, but nevertheless we make a stab at
+ it, choosing an approach consistent with the history of this
+ code. */
+ baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
+
+ prim_record_minimal_symbol_and_info (qualified_name, vma - baseaddr,
+ msymtype, section, objfile);
/* Enter the plain name as well, which might not be unique. */
- prim_record_minimal_symbol_and_info (bare_name, vma, msymtype,
+ prim_record_minimal_symbol_and_info (bare_name, vma - baseaddr, msymtype,
section, objfile);
xfree (qualified_name);
xfree (bare_name);
bfd_map_over_sections (dll, get_section_vmas, &pe_sections_info);
- /* Adjust the vma_offsets in case this PE got relocated. This
- assumes that *all* sections share the same relocation offset
- as the text section. */
- for (i = 0; i < otherix; i++)
- {
- section_data[i].vma_offset
- += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
- }
-
/* Truncate name at first dot. Should maybe also convert to all
lower case for convenience on Windows. */
read_pe_truncate_name (dll_name);
minsyms. */
int section = cs_to_section (cs, objfile);
- tmpaddr = cs->c_value + ANOFFSET (objfile->section_offsets,
- SECT_OFF_TEXT (objfile));
+ tmpaddr = cs->c_value;
record_minimal_symbol (cs, tmpaddr, mst_text,
section, objfile);
enum minimal_symbol_type ms_type;
int sec;
+ CORE_ADDR offset = 0;
if (cs->c_secnum == N_UNDEF)
{
|| cs->c_sclass == C_THUMBEXTFUNC
|| cs->c_sclass == C_THUMBEXT
|| (pe_file && (cs->c_sclass == C_STAT)))
- tmpaddr += ANOFFSET (objfile->section_offsets, sec);
+ offset = ANOFFSET (objfile->section_offsets, sec);
if (bfd_section->flags & SEC_CODE)
{
sym = process_coff_symbol
(cs, &main_aux, objfile);
- SYMBOL_VALUE (sym) = tmpaddr;
+ SYMBOL_VALUE (sym) = tmpaddr + offset;
SYMBOL_SECTION (sym) = sec;
}
}
if (bfd_get_section_flags (abfd, sec) & SEC_CODE)
{
- 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 (objfile));
type = N_DATA;
}
else if (bfd_get_section_flags (abfd, sec) & SEC_ALLOC)
{
- sym_value += ANOFFSET (objfile->section_offsets,
- SECT_OFF_BSS (objfile));
type = N_BSS;
}
else
counter++, relptr++)
{
arelent *rel = *relptr;
- CORE_ADDR address =
- rel->address + ANOFFSET (objfile->section_offsets,
- SECT_OFF_DATA (objfile));
+ CORE_ADDR address = rel->address;
switch (bfd_get_arch (abfd))
{
case N_TEXT | N_EXT:
case N_NBTEXT | N_EXT:
- nlist.n_value += ANOFFSET (objfile->section_offsets,
- SECT_OFF_TEXT (objfile));
goto record_it;
case N_DATA | N_EXT:
case N_NBDATA | N_EXT:
- nlist.n_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? */
- nlist.n_value += ANOFFSET (objfile->section_offsets,
- SECT_OFF_BSS (objfile));
goto record_it;
case N_ABS | N_EXT:
case N_FN:
case N_FN_SEQ:
case N_TEXT:
- nlist.n_value += ANOFFSET (objfile->section_offsets,
- SECT_OFF_TEXT (objfile));
namestring = set_namestring (objfile, &nlist);
if ((namestring[0] == '-' && namestring[1] == 'l')
|| (namestring[(nsl = strlen (namestring)) - 1] == 'o'
&& namestring[nsl - 2] == '.'))
{
+ nlist.n_value += ANOFFSET (objfile->section_offsets,
+ SECT_OFF_TEXT (objfile));
+
if (past_first_source_file && pst
/* The gould NP1 uses low values for .o and -l symbols
which are not the address. */
continue;
case N_DATA:
- nlist.n_value += ANOFFSET (objfile->section_offsets,
- SECT_OFF_DATA (objfile));
goto record_it;
case N_UNDF | N_EXT:
&& bfd_get_section_by_name (abfd, ".plt") != NULL)
continue;
- symaddr += ANOFFSET (objfile->section_offsets,
- gdb_bfd_section_index (objfile->obfd, sect));
-
msym = record_minimal_symbol
(sym->name, strlen (sym->name), copy_names,
symaddr, mst_solib_trampoline, sect, objfile);
interested in will have a section. */
/* Bfd symbols are section relative. */
symaddr = sym->value + sym->section->vma;
- /* Relocate all non-absolute and non-TLS symbols by the
- section offset. */
- if (sym->section != bfd_abs_section_ptr
- && !(sym->section->flags & SEC_THREAD_LOCAL))
- {
- symaddr += offset;
- }
/* For non-absolute symbols, use the type of the section
they are relative to, to intuit text/data. Bfd provides
no way of figuring this out for absolute symbols. */
{
if (sym->name[0] == '.')
continue;
- symaddr += offset;
}
}
else if (sym->section->flags & SEC_CODE)
if (sym->flags & (BSF_GLOBAL | BSF_LOCAL | BSF_WEAK))
{
CORE_ADDR symaddr;
- CORE_ADDR offset;
enum minimal_symbol_type ms_type;
- offset = ANOFFSET (objfile->section_offsets,
- gdb_bfd_section_index (objfile->obfd, sym->section));
-
/* Bfd symbols are section relative. */
symaddr = sym->value + sym->section->vma;
- /* Select global/local/weak symbols. Note that bfd puts abs
- symbols in their own section, so all symbols we are
- interested in will have a section. */
- /* Relocate all non-absolute and non-TLS symbols by the
- section offset. */
- if (sym->section != bfd_abs_section_ptr
- && !(sym->section->flags & SEC_THREAD_LOCAL))
- symaddr += offset;
-
if (sym->section == bfd_abs_section_ptr)
ms_type = mst_abs;
else if (sym->section->flags & SEC_CODE)
{
case stProc:
/* Beginnning of Procedure */
- 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 (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 (objfile));
}
else if (SC_IS_BSS (ext_in->asym.sc))
{
ms_type = mst_bss;
- svalue += ANOFFSET (objfile->section_offsets,
- SECT_OFF_BSS (objfile));
}
else if (SC_IS_SBSS (ext_in->asym.sc))
{
ms_type = mst_bss;
- svalue += ANOFFSET (objfile->section_offsets,
- get_section_index (objfile, ".sbss"));
}
else
ms_type = mst_abs;
continue;
ms_type = mst_file_text;
- svalue += ANOFFSET (objfile->section_offsets,
- SECT_OFF_TEXT (objfile));
}
else if (SC_IS_DATA (ext_in->asym.sc))
{
continue;
ms_type = mst_file_data;
- svalue += ANOFFSET (objfile->section_offsets,
- SECT_OFF_DATA (objfile));
}
else if (SC_IS_BSS (ext_in->asym.sc))
{
continue;
ms_type = mst_file_bss;
- svalue += ANOFFSET (objfile->section_offsets,
- SECT_OFF_BSS (objfile));
}
else if (SC_IS_SBSS (ext_in->asym.sc))
{
continue;
ms_type = mst_file_bss;
- svalue += ANOFFSET (objfile->section_offsets, sbss_sect_index);
}
else
ms_type = mst_abs;
CORE_ADDR procaddr;
long isym;
- sh.value += ANOFFSET (objfile->section_offsets,
- SECT_OFF_TEXT (objfile));
if (sh.st == stStaticProc)
{
namestring = debug_info->ss + fh->issBase + sh.iss;
mst_file_text, sh.sc,
objfile);
}
+ sh.value += ANOFFSET (objfile->section_offsets,
+ SECT_OFF_TEXT (objfile));
procaddr = sh.value;
isym = AUX_GET_ISYM (fh->fBigendian,
case scPData:
case scXData:
namestring = debug_info->ss + fh->issBase + sh.iss;
- sh.value += ANOFFSET (objfile->section_offsets,
- SECT_OFF_DATA (objfile));
record_minimal_symbol (namestring, sh.value,
mst_file_data, sh.sc,
objfile);
+ sh.value += ANOFFSET (objfile->section_offsets,
+ SECT_OFF_DATA (objfile));
break;
default:
/* 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 (objfile));
record_minimal_symbol (namestring, sh.value,
mst_file_bss, sh.sc,
objfile);
+ sh.value += ANOFFSET (objfile->section_offsets,
+ SECT_OFF_BSS (objfile));
break;
}
}
{
char *name;
enum address_class class;
+ CORE_ADDR minsym_value;
(*swap_sym_in) (cur_bfd,
((char *) debug_info->external_sym
name = debug_info->ss + fh->issBase + sh.iss;
+ minsym_value = sh.value;
+
switch (sh.sc)
{
case scText:
int new_sdx;
case stStaticProc:
- prim_record_minimal_symbol_and_info (name, sh.value,
+ prim_record_minimal_symbol_and_info (name, minsym_value,
mst_file_text,
SECT_OFF_TEXT (objfile),
objfile);
case stStatic: /* Variable */
if (SC_IS_DATA (sh.sc))
- prim_record_minimal_symbol_and_info (name, sh.value,
+ prim_record_minimal_symbol_and_info (name, minsym_value,
mst_file_data,
SECT_OFF_DATA (objfile),
objfile);
else
- prim_record_minimal_symbol_and_info (name, sh.value,
+ prim_record_minimal_symbol_and_info (name, minsym_value,
mst_file_bss,
SECT_OFF_BSS (objfile),
objfile);
}
}
-/* Sort all the minimal symbols in OBJFILE. */
-
-void
-msymbols_sort (struct objfile *objfile)
-{
- qsort (objfile->msymbols, objfile->minimal_symbol_count,
- sizeof (struct minimal_symbol), compare_minimal_symbols);
- build_minimal_symbol_hash_tables (objfile);
-}
-
/* Check if PC is in a shared library trampoline code stub.
Return minimal symbol for the trampoline entry or NULL if PC is not
in a trampoline code stub. */
void terminate_minimal_symbol_table (struct objfile *objfile);
-/* Sort all the minimal symbols in OBJFILE. This should be only be
- called after relocating symbols; it ensures that the minimal
- symbols are properly sorted by address. */
-
-void msymbols_sort (struct objfile *objfile);
-
\f
/* Compute a hash code for the string argument. */
ms_type = mst_text;
else
ms_type = mst_file_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 (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 (objfile));
}
else if (sym_shndx == SHN_ABS)
{
if (objfile->sf)
objfile->sf->qf->relocate (objfile, new_offsets, delta);
- {
- struct minimal_symbol *msym;
-
- ALL_OBJFILE_MSYMBOLS (objfile, msym)
- if (MSYMBOL_SECTION (msym) >= 0)
- SET_MSYMBOL_VALUE_ADDRESS (msym, (MSYMBOL_VALUE_ADDRESS (objfile, msym)
- + ANOFFSET (delta,
- MSYMBOL_SECTION (msym))));
- }
- /* Relocating different sections by different amounts may cause the symbols
- to be out of order. */
- msymbols_sort (objfile);
-
{
int i;
const int symsize = sizeof (struct som_external_symbol_dictionary_record);
-#define text_offset ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile))
-#define data_offset ANOFFSET (section_offsets, SECT_OFF_DATA (objfile))
-
number_of_symbols = bfd_get_symcount (abfd);
/* Allocate a buffer to read in the debug info.
more accurate to check for a nonzero text offset, but they
have not provided any information about why that test is
more accurate. */
- dynamic = (text_offset != 0);
+ dynamic = (ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile)) != 0);
endbufp = buf + number_of_symbols;
for (bufp = buf; bufp < endbufp; ++bufp)
case ST_MILLICODE:
symname = bfd_getb32 (bufp->name) + stringtab;
ms_type = mst_text;
- symbol_value += text_offset;
symbol_value = gdbarch_addr_bits_remove (gdbarch, symbol_value);
break;
ms_type = mst_solib_trampoline;
else
ms_type = mst_text;
- symbol_value += text_offset;
symbol_value = gdbarch_addr_bits_remove (gdbarch, symbol_value);
break;
case ST_STUB:
symname = bfd_getb32 (bufp->name) + stringtab;
ms_type = mst_solib_trampoline;
- symbol_value += text_offset;
symbol_value = gdbarch_addr_bits_remove (gdbarch, symbol_value);
break;
case ST_DATA:
symname = bfd_getb32 (bufp->name) + stringtab;
- symbol_value += data_offset;
ms_type = mst_data;
break;
default:
case ST_CODE:
symname = bfd_getb32 (bufp->name) + stringtab;
ms_type = mst_file_text;
- symbol_value += text_offset;
symbol_value = gdbarch_addr_bits_remove (gdbarch, symbol_value);
check_strange_names:
case ST_MILLICODE:
symname = bfd_getb32 (bufp->name) + stringtab;
ms_type = mst_file_text;
- symbol_value += text_offset;
symbol_value = gdbarch_addr_bits_remove (gdbarch, symbol_value);
break;
using mst_file_text vs mst_solib_trampoline here like
we do for SS_UNIVERSAL and SS_EXTERNAL symbols above. */
ms_type = mst_file_text;
- symbol_value += text_offset;
symbol_value = gdbarch_addr_bits_remove (gdbarch, symbol_value);
break;
case ST_STUB:
symname = bfd_getb32 (bufp->name) + stringtab;
ms_type = mst_solib_trampoline;
- symbol_value += text_offset;
symbol_value = gdbarch_addr_bits_remove (gdbarch, symbol_value);
break;
case ST_DATA:
symname = bfd_getb32 (bufp->name) + stringtab;
- symbol_value += data_offset;
ms_type = mst_file_data;
goto check_strange_names;
case ST_STORAGE:
case ST_DATA:
symname = bfd_getb32 (bufp->name) + stringtab;
- symbol_value += data_offset;
ms_type = mst_data;
break;
ALL_OBJFILE_OSECTIONS (objfile, iter)
{
+ CORE_ADDR start;
+ CORE_ADDR len;
+
if (bfd_is_const_section (iter->the_bfd_section))
continue;
- if (obj_section_addr (iter) <= symbol_value
- && symbol_value < obj_section_endaddr (iter))
+ start = bfd_get_section_vma (iter->objfile->obfd,
+ iter->the_bfd_section);
+ len = bfd_get_section_size (iter->the_bfd_section);
+ if (start <= symbol_value && symbol_value < start + len)
{
section = iter->the_bfd_section;
break;
#define MSYMBOL_VALUE(symbol) (symbol)->mginfo.value.ivalue
/* The unrelocated address of the minimal symbol. */
#define MSYMBOL_VALUE_RAW_ADDRESS(symbol) ((symbol)->mginfo.value.address + 0)
-/* This weird definition lets us syntax-check without affecting the
- results. It is a temporary measure until a later patch. */
+/* The relocated address of the minimal symbol, using the section
+ offsets from OBJFILE. */
#define MSYMBOL_VALUE_ADDRESS(objfile, symbol) \
((symbol)->mginfo.value.address \
- + (0 \
- * ANOFFSET ((objfile)->section_offsets, ((symbol)->mginfo.section))))
+ + ANOFFSET ((objfile)->section_offsets, ((symbol)->mginfo.section)))
/* For a bound minsym, we can easily compute the address directly. */
#define BMSYMBOL_VALUE_ADDRESS(symbol) \
MSYMBOL_VALUE_ADDRESS ((symbol).objfile, (symbol).minsym)
if (name[0] == '.')
++name;
- address += ANOFFSET (objfile->section_offsets, section);
prim_record_minimal_symbol_and_info (name, address, ms_type,
secnum_to_section (n_scnum, objfile),
objfile);