From 2273f0ac95a79ce29ef42025c63f90e82cf907d7 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Tue, 15 Oct 2013 13:28:57 -0600 Subject: [PATCH] change minsyms not to be relocated at read-time This removes the runtime offsets from minsyms. Instead, these offsets will now be applied whenever the minsym's address is computed. This patch redefines MSYMBOL_VALUE_ADDRESS to actually use the offsets from the given objfile. Then, it updates all the symbol readers, changing them so that they do not add in the section offset when creating the symbol. This change also lets us remove relocation of minsyms from objfile_relocate1 and also msymbols_sort. 2014-02-26 Tom Tromey * 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. --- gdb/ChangeLog | 25 +++++++++++++++++++++++++ gdb/coff-pe-read.c | 24 +++++++++++------------- gdb/coffread.c | 8 ++++---- gdb/dbxread.c | 23 ++++------------------- gdb/elfread.c | 11 ----------- gdb/machoread.c | 13 ------------- gdb/mdebugread.c | 38 ++++++++++++-------------------------- gdb/minsyms.c | 10 ---------- gdb/minsyms.h | 6 ------ gdb/mipsread.c | 3 --- gdb/objfiles.c | 13 ------------- gdb/somread.c | 24 ++++++++---------------- gdb/symtab.h | 7 +++---- gdb/xcoffread.c | 1 - 14 files changed, 67 insertions(+), 139 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 0ce3186102f..76389ccf480 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,28 @@ +2014-02-26 Tom Tromey + + * 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 * ada-lang.c (ada_main_name): Update. diff --git a/gdb/coff-pe-read.c b/gdb/coff-pe-read.c index e1a61b7e65d..dbb57f86601 100644 --- a/gdb/coff-pe-read.c +++ b/gdb/coff-pe-read.c @@ -204,7 +204,7 @@ add_pe_forwarded_sym (const char *sym_name, const char *forward_dll_name, 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; @@ -259,11 +259,18 @@ add_pe_forwarded_sym (const char *sym_name, const char *forward_dll_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); @@ -528,15 +535,6 @@ read_pe_exported_syms (struct objfile *objfile) 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); diff --git a/gdb/coffread.c b/gdb/coffread.c index c5ad60c7b3a..44d77f09116 100644 --- a/gdb/coffread.c +++ b/gdb/coffread.c @@ -873,8 +873,7 @@ coff_symtab_read (long symtab_offset, unsigned int nsyms, 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); @@ -976,6 +975,7 @@ coff_symtab_read (long symtab_offset, unsigned int nsyms, enum minimal_symbol_type ms_type; int sec; + CORE_ADDR offset = 0; if (cs->c_secnum == N_UNDEF) { @@ -1007,7 +1007,7 @@ coff_symtab_read (long symtab_offset, unsigned int nsyms, || 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) { @@ -1046,7 +1046,7 @@ coff_symtab_read (long symtab_offset, unsigned int nsyms, sym = process_coff_symbol (cs, &main_aux, objfile); - SYMBOL_VALUE (sym) = tmpaddr; + SYMBOL_VALUE (sym) = tmpaddr + offset; SYMBOL_SECTION (sym) = sec; } } diff --git a/gdb/dbxread.c b/gdb/dbxread.c index e0e5c481f73..5171f50dd01 100644 --- a/gdb/dbxread.c +++ b/gdb/dbxread.c @@ -1045,20 +1045,14 @@ read_dbx_dynamic_symtab (struct objfile *objfile) 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 @@ -1098,9 +1092,7 @@ read_dbx_dynamic_symtab (struct objfile *objfile) 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)) { @@ -1326,22 +1318,16 @@ read_dbx_symtab (struct objfile *objfile) 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: @@ -1364,14 +1350,15 @@ read_dbx_symtab (struct objfile *objfile) 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. */ @@ -1396,8 +1383,6 @@ read_dbx_symtab (struct objfile *objfile) continue; case N_DATA: - nlist.n_value += ANOFFSET (objfile->section_offsets, - SECT_OFF_DATA (objfile)); goto record_it; case N_UNDF | N_EXT: diff --git a/gdb/elfread.c b/gdb/elfread.c index 7c4b17505ff..fd888133f2c 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -325,9 +325,6 @@ elf_symtab_read (struct objfile *objfile, int type, && 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); @@ -367,13 +364,6 @@ elf_symtab_read (struct objfile *objfile, int type, 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. */ @@ -409,7 +399,6 @@ elf_symtab_read (struct objfile *objfile, int type, { if (sym->name[0] == '.') continue; - symaddr += offset; } } else if (sym->section->flags & SEC_CODE) diff --git a/gdb/machoread.c b/gdb/machoread.c index f7194e250ae..f5e4a1e4e32 100644 --- a/gdb/machoread.c +++ b/gdb/machoread.c @@ -111,24 +111,11 @@ macho_symtab_add_minsym (struct objfile *objfile, const asymbol *sym) 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) diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index 5cb8d86f282..94af07b19cf 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -2519,14 +2519,10 @@ parse_partial_symbols (struct objfile *objfile) { 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 */ @@ -2539,20 +2535,14 @@ parse_partial_symbols (struct objfile *objfile) 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; @@ -2585,8 +2575,6 @@ parse_partial_symbols (struct objfile *objfile) continue; ms_type = mst_file_text; - svalue += ANOFFSET (objfile->section_offsets, - SECT_OFF_TEXT (objfile)); } else if (SC_IS_DATA (ext_in->asym.sc)) { @@ -2594,8 +2582,6 @@ parse_partial_symbols (struct objfile *objfile) continue; ms_type = mst_file_data; - svalue += ANOFFSET (objfile->section_offsets, - SECT_OFF_DATA (objfile)); } else if (SC_IS_BSS (ext_in->asym.sc)) { @@ -2603,8 +2589,6 @@ parse_partial_symbols (struct objfile *objfile) continue; ms_type = mst_file_bss; - svalue += ANOFFSET (objfile->section_offsets, - SECT_OFF_BSS (objfile)); } else if (SC_IS_SBSS (ext_in->asym.sc)) { @@ -2614,7 +2598,6 @@ parse_partial_symbols (struct objfile *objfile) continue; ms_type = mst_file_bss; - svalue += ANOFFSET (objfile->section_offsets, sbss_sect_index); } else ms_type = mst_abs; @@ -2748,8 +2731,6 @@ parse_partial_symbols (struct objfile *objfile) 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; @@ -2757,6 +2738,8 @@ parse_partial_symbols (struct objfile *objfile) 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, @@ -2796,22 +2779,22 @@ parse_partial_symbols (struct objfile *objfile) 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; } } @@ -3435,6 +3418,7 @@ parse_partial_symbols (struct objfile *objfile) { char *name; enum address_class class; + CORE_ADDR minsym_value; (*swap_sym_in) (cur_bfd, ((char *) debug_info->external_sym @@ -3460,6 +3444,8 @@ parse_partial_symbols (struct objfile *objfile) name = debug_info->ss + fh->issBase + sh.iss; + minsym_value = sh.value; + switch (sh.sc) { case scText: @@ -3492,7 +3478,7 @@ parse_partial_symbols (struct objfile *objfile) 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); @@ -3578,12 +3564,12 @@ parse_partial_symbols (struct 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); diff --git a/gdb/minsyms.c b/gdb/minsyms.c index aa6df11fc99..df499a4b4ad 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -1296,16 +1296,6 @@ terminate_minimal_symbol_table (struct 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. */ diff --git a/gdb/minsyms.h b/gdb/minsyms.h index a11b5e88aca..289dcae38c5 100644 --- a/gdb/minsyms.h +++ b/gdb/minsyms.h @@ -136,12 +136,6 @@ void install_minimal_symbols (struct objfile *); 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); - /* Compute a hash code for the string argument. */ diff --git a/gdb/mipsread.c b/gdb/mipsread.c index d199554f9f7..090a7e787d2 100644 --- a/gdb/mipsread.c +++ b/gdb/mipsread.c @@ -367,7 +367,6 @@ read_alphacoff_dynamic_symtab (struct section_offsets *section_offsets, 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) { @@ -375,7 +374,6 @@ read_alphacoff_dynamic_symtab (struct section_offsets *section_offsets, 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) { @@ -383,7 +381,6 @@ read_alphacoff_dynamic_symtab (struct section_offsets *section_offsets, 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) { diff --git a/gdb/objfiles.c b/gdb/objfiles.c index db0c7206b00..f45656987ff 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -800,19 +800,6 @@ objfile_relocate1 (struct objfile *objfile, 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; diff --git a/gdb/somread.c b/gdb/somread.c index 79068cd5e0b..4a7837e5923 100644 --- a/gdb/somread.c +++ b/gdb/somread.c @@ -57,9 +57,6 @@ som_symtab_read (bfd *abfd, struct objfile *objfile, 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. @@ -94,7 +91,7 @@ som_symtab_read (bfd *abfd, struct objfile *objfile, 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) @@ -152,7 +149,6 @@ som_symtab_read (bfd *abfd, struct objfile *objfile, 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; @@ -165,20 +161,17 @@ som_symtab_read (bfd *abfd, struct objfile *objfile, 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: @@ -200,7 +193,6 @@ som_symtab_read (bfd *abfd, struct objfile *objfile, 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: @@ -231,7 +223,6 @@ som_symtab_read (bfd *abfd, struct objfile *objfile, 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; @@ -242,21 +233,18 @@ som_symtab_read (bfd *abfd, struct objfile *objfile, 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; @@ -277,7 +265,6 @@ som_symtab_read (bfd *abfd, struct objfile *objfile, case ST_STORAGE: case ST_DATA: symname = bfd_getb32 (bufp->name) + stringtab; - symbol_value += data_offset; ms_type = mst_data; break; @@ -300,11 +287,16 @@ som_symtab_read (bfd *abfd, struct objfile *objfile, 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; diff --git a/gdb/symtab.h b/gdb/symtab.h index d80222b5d32..ef145d9f428 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -393,12 +393,11 @@ struct minimal_symbol #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) diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c index db1182001ed..b986dbd6255 100644 --- a/gdb/xcoffread.c +++ b/gdb/xcoffread.c @@ -948,7 +948,6 @@ record_minimal_symbol (const char *name, CORE_ADDR address, 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); -- 2.30.2