change minsyms not to be relocated at read-time
authorTom Tromey <tromey@redhat.com>
Tue, 15 Oct 2013 19:28:57 +0000 (13:28 -0600)
committerTom Tromey <tromey@redhat.com>
Wed, 26 Feb 2014 19:11:17 +0000 (12:11 -0700)
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  <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.

14 files changed:
gdb/ChangeLog
gdb/coff-pe-read.c
gdb/coffread.c
gdb/dbxread.c
gdb/elfread.c
gdb/machoread.c
gdb/mdebugread.c
gdb/minsyms.c
gdb/minsyms.h
gdb/mipsread.c
gdb/objfiles.c
gdb/somread.c
gdb/symtab.h
gdb/xcoffread.c

index 0ce3186102fab2c7b1148ccba5c4561c4bd3c727..76389ccf48094e0d8c12b8ab2f6b4e24ee9dd7e6 100644 (file)
@@ -1,3 +1,28 @@
+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.
index e1a61b7e65d477cf1c27ddb1b24d4b32e7bec193..dbb57f86601358c3484d3a5d96e6ff4343bb296e 100644 (file)
@@ -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);
index c5ad60c7b3a4e20abb0ebea300c2f3e4cba160cc..44d77f09116d3dea976d3d84ee21e9f166bf5cd5 100644 (file)
@@ -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;
              }
          }
index e0e5c481f738bdd508306ae5d3ca52c9660490fa..5171f50dd018c5de6990309d04e63d8a59aed409 100644 (file)
@@ -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:
index 7c4b17505ffa55ea4173a269a90a65c909222beb..fd888133f2c2d9b7bac4e95ebf7be3117f6af733 100644 (file)
@@ -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)
index f7194e250ae814719f132ffc57dd97f14f8af91e..f5e4a1e4e32aa5dd4f78691ac97b5ec74945bcbc 100644 (file)
@@ -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)
index 5cb8d86f2825f0ff7c8e654c5a72b2e5809502f2..94af07b19cfc1f6f2eb83c32183a77ecd3d2f0c7 100644 (file)
@@ -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);
index aa6df11fc99a9893a60e226197d337076557932c..df499a4b4ad9131a7ebf372402a0694b5e74fef9 100644 (file)
@@ -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.  */
index a11b5e88acaf98619411a800dadd61d0ff7e6f28..289dcae38c54aaa34082466508aefe2c8a1b910f 100644 (file)
@@ -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);
-
 \f
 
 /* Compute a hash code for the string argument.  */
index d199554f9f74adb5d6b7d853b9e13f0174b26e77..090a7e787d2552b1fdf2ee28ee25dd7be0b35b14 100644 (file)
@@ -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)
            {
index db0c7206b002d20f7980649ec13e0ad74b47b18f..f45656987ff9fcdbf2a3d131ddc56a5d3548e76c 100644 (file)
@@ -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;
 
index 79068cd5e0b9f25c2ff3cd8bac1e881a340ce2ac..4a7837e5923ba24450ff44b9cea7747f4fece3ce 100644 (file)
@@ -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;
index d80222b5d32011891e8a62f7e8a3189b4d18530f..ef145d9f4289e769ed12c925e7de9ca73193a3aa 100644 (file)
@@ -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)
index db1182001edd1e56c1365540ba9e51511a907c12..b986dbd62550331b34374c629e2c15eadbb23e80 100644 (file)
@@ -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);