Make elf section symbols global for link-once sections.
authorAlan Modra <amodra@gmail.com>
Sat, 7 Oct 2000 12:52:15 +0000 (12:52 +0000)
committerAlan Modra <amodra@gmail.com>
Sat, 7 Oct 2000 12:52:15 +0000 (12:52 +0000)
bfd/ChangeLog
bfd/elf.c
gas/ChangeLog
gas/config/obj-elf.c
gas/write.c

index 7069fb8..3347191 100644 (file)
@@ -1,3 +1,7 @@
+2000-10-07  Alan Modra  <alan@linuxcare.com.au>
+
+       * elf.c (swap_out_syms): Handle global section symbols.
+
 2000-10-05  DJ Delorie  <dj@redhat.com>
 
        * peigen.c (_bfd_pei_swap_scnhdr_out): note extended relocs
index 3aede14..bc8dec7 100644 (file)
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -4352,8 +4352,9 @@ swap_out_syms (abfd, sttp, relocatable_p)
        flagword flags = syms[idx]->flags;
        int type;
 
-       if (flags & BSF_SECTION_SYM)
-         /* Section symbols have no names.  */
+       /* Section symbols usually have no name.  The exception is
+          link-once section symbols, which we make global.  */
+       if ((flags & (BSF_SECTION_SYM | BSF_GLOBAL)) == BSF_SECTION_SYM)
          sym.st_name = 0;
        else
          {
@@ -4461,7 +4462,8 @@ swap_out_syms (abfd, sttp, relocatable_p)
           type = (*bed->elf_backend_get_symbol_type) (&type_ptr->internal_elf_sym, type);
 
        if (flags & BSF_SECTION_SYM)
-         sym.st_info = ELF_ST_INFO (STB_LOCAL, STT_SECTION);
+         sym.st_info = ELF_ST_INFO ((flags & BSF_GLOBAL
+                                     ? STB_GLOBAL : STB_LOCAL), STT_SECTION);
        else if (bfd_is_com_section (syms[idx]->section))
          sym.st_info = ELF_ST_INFO (STB_GLOBAL, type);
        else if (bfd_is_und_section (syms[idx]->section))
index ff9c3b8..7533a9e 100644 (file)
@@ -1,3 +1,10 @@
+2000-10-07  Alan Modra  <alan@linuxcare.com.au>
+
+       * write.c (write_relocs): Fix a comment.
+
+       * config/obj-elf.c (elf_frob_symbol): Make section syms global on
+       link-once sections.
+
 2000-10-05  Jim Wilson  <wilson@cygnus.com>
 
        * config/tc-ia64.c (resources_match): Handle IA64_RS_PRr.
index 4e7f3a3..0f49ab6 100644 (file)
@@ -1742,6 +1742,21 @@ elf_frob_symbol (symp, puntp)
       && S_IS_DEFINED (symp))
     symbol_get_bfdsym (symp)->flags |= BSF_OBJECT;
 #endif
+
+  if (symbol_section_p (symp))
+    {
+      asection *symsec = S_GET_SEGMENT (symp);
+
+      if ((bfd_get_section_flags (stdoutput, symsec) & SEC_LINK_ONCE) != 0
+         || strncmp (segment_name (symsec), ".gnu.linkonce",
+                     sizeof ".gnu.linkonce" - 1) == 0)
+       {
+         /* Make section syms global on ELF linkonce sections.
+            This way, any reference to the section symbol will
+            resolve to the section that actually stays in.  */
+         S_SET_EXTERNAL (symp);
+       }
+    }
 }
 
 void
index 907ba2f..802d461 100644 (file)
@@ -1008,7 +1008,7 @@ write_relocs (abfd, sec, xxx)
        }
 
       /* If this is an undefined symbol which was equated to another
-         symbol, then use generate the reloc against the latter symbol
+         symbol, then generate the reloc against the latter symbol
          rather than the former.  */
       sym = fixp->fx_addsy;
       while (symbol_equated_p (sym)