* elf32-sparc.c (elf32_sparc_size_dynamic_sections): Don't
authorIan Lance Taylor <ian@airs.com>
Mon, 24 Mar 1997 18:42:09 +0000 (18:42 +0000)
committerIan Lance Taylor <ian@airs.com>
Mon, 24 Mar 1997 18:42:09 +0000 (18:42 +0000)
count section symbols for sections that were created by the
linker, or are not allocatable or not loadable.
(elf32_sparc_finish_dynamic_sections): Output output section
symbols for section for which we made space for them.

bfd/ChangeLog
bfd/elf32-sparc.c

index b8a6a79..9038875 100644 (file)
@@ -1,3 +1,11 @@
+Mon Mar 24 13:41:00 1997  Ian Lance Taylor  <ian@cygnus.com>
+
+       * elf32-sparc.c (elf32_sparc_size_dynamic_sections): Don't
+       count section symbols for sections that were created by the
+       linker, or are not allocatable or not loadable.
+       (elf32_sparc_finish_dynamic_sections): Output output section
+       symbols for section for which we made space for them.
+
 Fri Mar 21 13:08:26 1997  Ian Lance Taylor  <ian@cygnus.com>
 
        * elf32-sparc.c (elf32_sparc_size_dynamic_sections): If there is
index 1db5f3a..905b567 100644 (file)
@@ -896,26 +896,34 @@ elf32_sparc_size_dynamic_sections (output_bfd, info)
     }
 
   /* If we are generating a shared library, we generate a section
-     symbol for each output section.  These are local symbols, which
-     means that they must come first in the dynamic symbol table.
-     That means we must increment the dynamic symbol index of every
-     other dynamic symbol.  */
+     symbol for each output section for which we might need to copy
+     relocs.  These are local symbols, which means that they must come
+     first in the dynamic symbol table.  That means we must increment
+     the dynamic symbol index of every other dynamic symbol.  */
   if (info->shared)
     {
-      int c, i;
+      int c;
 
-      c = bfd_count_sections (output_bfd);
-      elf_link_hash_traverse (elf_hash_table (info),
-                             elf32_sparc_adjust_dynindx,
-                             (PTR) &c);
-      elf_hash_table (info)->dynsymcount += c;
-
-      for (i = 1, s = output_bfd->sections; s != NULL; s = s->next, i++)
+      c = 0;
+      for (s = output_bfd->sections; s != NULL; s = s->next)
        {
-         elf_section_data (s)->dynindx = i;
+         if ((s->flags & SEC_LINKER_CREATED) != 0
+             || (s->flags & SEC_ALLOC) == 0
+             || (s->flags & SEC_LOAD) == 0)
+           continue;
+
+         elf_section_data (s)->dynindx = c + 1;
+
          /* These symbols will have no names, so we don't need to
              fiddle with dynstr_index.  */
+
+         ++c;
        }
+
+      elf_link_hash_traverse (elf_hash_table (info),
+                             elf32_sparc_adjust_dynindx,
+                             (PTR) &c);
+      elf_hash_table (info)->dynsymcount += c;
     }
 
   return true;
@@ -1630,6 +1638,7 @@ elf32_sparc_finish_dynamic_sections (output_bfd, info)
       asection *sdynsym;
       asection *s;
       Elf_Internal_Sym sym;
+      int c;
 
       /* Set up the section symbols for the output sections.  */
 
@@ -1641,10 +1650,14 @@ elf32_sparc_finish_dynamic_sections (output_bfd, info)
       sym.st_info = ELF_ST_INFO (STB_LOCAL, STT_SECTION);
       sym.st_other = 0;
 
+      c = 0;
       for (s = output_bfd->sections; s != NULL; s = s->next)
        {
          int indx;
 
+         if (elf_section_data (s)->dynindx == 0)
+           continue;
+
          sym.st_value = s->vma;
 
          indx = elf_section_data (s)->this_idx;
@@ -1655,12 +1668,13 @@ elf32_sparc_finish_dynamic_sections (output_bfd, info)
                                     (PTR) (((Elf32_External_Sym *)
                                             sdynsym->contents)
                                            + elf_section_data (s)->dynindx));
+
+         ++c;
        }
 
       /* Set the sh_info field of the output .dynsym section to the
          index of the first global symbol.  */
-      elf_section_data (sdynsym->output_section)->this_hdr.sh_info =
-       bfd_count_sections (output_bfd) + 1;
+      elf_section_data (sdynsym->output_section)->this_hdr.sh_info = c + 1;
     }
 
   return true;