bfd/
authorAlan Modra <amodra@gmail.com>
Thu, 4 Aug 2005 06:22:14 +0000 (06:22 +0000)
committerAlan Modra <amodra@gmail.com>
Thu, 4 Aug 2005 06:22:14 +0000 (06:22 +0000)
* elf32-ppc.c (struct elf_linker_section): Replace sym_val field
with sym.
(ppc_elf_relocate_section): Adjust for above.
(create_sdata_sym): New function.
(ppc_elf_create_linker_section): Call it.
(ppc_elf_check_relocs): Correct has_sda_refs and non_got_refs.
Create sdata syms for all SDA relocs.
(ppc_elf_adjust_dynamic_symbol): Don't special case _SDA_BASE_
and _SDA2_BASE_.
(ppc_elf_set_sdata_syms): Delete.
* elflink.c (bfd_elf_size_dynamic_sections): Don't create DT_INIT
and DT_FINI tags unless associated section has input.
(bfd_elf_set_symbol, _bfd_elf_provide_symbol): Delete.
(_bfd_elf_provide_section_bound_symbols): Delete.
* bfd-in.h (_bfd_elf_provide_symbol): Delete.
(_bfd_elf_provide_section_bound_symbols): Delete.
* bfd-in2.h: Regenerate.
ld/
* ldemul.c (ldemul_do_assignments, do_assignments_default): Delete.
* ldemul.h (ldemul_do_assignments, do_assignments_default): Delete.
(struct ld_emulation_xfer_struct): Remove do_assignments field.
* ldlang.c (lang_do_assignments): Don't call ldemul_do_assignments.
* emulparams/elf32ppc.sh (SDATA_START_SYMBOLS): New.
(SDATA2_START_SYMBOLS, SBSS_START_SYMBOLS, SBSS_END_SYMBOLS): New.
* emultempl/aix.em (ld_*_emulation): Delete do_assignments init.
* emultempl/armcoff.em: Likewise.
* emultempl/beos.em: Likewise.
* emultempl/generic.em: Likewise.
* emultempl/gld960.em: Likewise.
* emultempl/gld960c.em: Likewise.
* emultempl/linux.em: Likewise.
* emultempl/lnk960.em: Likewise.
* emultempl/m68kcoff.em: Likewise.
* emultempl/pe.em: Likewise.
* emultempl/sunos.em: Likewise.
* emultempl/ticoff.em: Likewise.
* emultempl/vanilla.em: Likewise.
* emultempl/elf32.em: Likewise.
(gld*_provide_bound_symbols): Delete.
(gld*_provide_init_fini_syms): Delete.
(gld*_before_allocation): Don't call ldemul_do_assignments.
* emultempl/ppc32elf.em (ppc_do_assignments): Delete.
(LDEMUL_DO_ASSIGNMENTS): Delete.
* scripttempl/elf.sc: Provide init/fini syms.  Add SBSS_START_SYMBOLS,
SBSS_END_SYMBOLS, SDATA2_START_SYMBOLS.

26 files changed:
bfd/ChangeLog
bfd/bfd-in.h
bfd/bfd-in2.h
bfd/elf32-ppc.c
bfd/elflink.c
ld/ChangeLog
ld/emulparams/elf32ppc.sh
ld/emultempl/aix.em
ld/emultempl/armcoff.em
ld/emultempl/beos.em
ld/emultempl/elf32.em
ld/emultempl/generic.em
ld/emultempl/gld960.em
ld/emultempl/gld960c.em
ld/emultempl/linux.em
ld/emultempl/lnk960.em
ld/emultempl/m68kcoff.em
ld/emultempl/pe.em
ld/emultempl/ppc32elf.em
ld/emultempl/sunos.em
ld/emultempl/ticoff.em
ld/emultempl/vanilla.em
ld/ldemul.c
ld/ldemul.h
ld/ldlang.c
ld/scripttempl/elf.sc

index 98fb93690e6d30fe6d2f6fe79eefb9fd901d54c9..3854c21fbff776ed6f2741f3584dd65f355a29d2 100644 (file)
@@ -1,3 +1,23 @@
+2005-08-04  Alan Modra  <amodra@bigpond.net.au>
+
+       * elf32-ppc.c (struct elf_linker_section): Replace sym_val field
+       with sym.
+       (ppc_elf_relocate_section): Adjust for above.
+       (create_sdata_sym): New function.
+       (ppc_elf_create_linker_section): Call it.
+       (ppc_elf_check_relocs): Correct has_sda_refs and non_got_refs.
+       Create sdata syms for all SDA relocs.
+       (ppc_elf_adjust_dynamic_symbol): Don't special case _SDA_BASE_
+       and _SDA2_BASE_.
+       (ppc_elf_set_sdata_syms): Delete.
+       * elflink.c (bfd_elf_size_dynamic_sections): Don't create DT_INIT
+       and DT_FINI tags unless associated section has input.
+       (bfd_elf_set_symbol, _bfd_elf_provide_symbol): Delete.
+       (_bfd_elf_provide_section_bound_symbols): Delete.
+       * bfd-in.h (_bfd_elf_provide_symbol): Delete.
+       (_bfd_elf_provide_section_bound_symbols): Delete.
+       * bfd-in2.h: Regenerate.
+
 2005-08-04  Alan Modra  <amodra@bigpond.net.au>
 
        * elflink.c (fix_syms, _bfd_elf_fix_excluded_sec_syms): Move to..
index 39a82cbffc5e8ec8dd18daa45d35ab0a77d3f6a6..cd3bc7678ef2eaad3d0a223e098783dec1a5923a 100644 (file)
@@ -702,12 +702,6 @@ extern int bfd_get_sign_extend_vma
 extern struct bfd_section *_bfd_elf_tls_setup
   (bfd *, struct bfd_link_info *);
 
-extern void _bfd_elf_provide_symbol
-  (struct bfd_link_info *, const char *, bfd_vma, struct bfd_section *);
-
-extern void _bfd_elf_provide_section_bound_symbols
-  (struct bfd_link_info *, struct bfd_section *, const char *, const char *);
-
 extern void _bfd_fix_excluded_sec_syms
   (bfd *, struct bfd_link_info *);
 
index 50ac26328620e9d9c65e0df0e2a552a9baa6732c..8ca1d6f8b16c1264d9e1f64056abc0e0cb592c05 100644 (file)
@@ -709,12 +709,6 @@ extern int bfd_get_sign_extend_vma
 extern struct bfd_section *_bfd_elf_tls_setup
   (bfd *, struct bfd_link_info *);
 
-extern void _bfd_elf_provide_symbol
-  (struct bfd_link_info *, const char *, bfd_vma, struct bfd_section *);
-
-extern void _bfd_elf_provide_section_bound_symbols
-  (struct bfd_link_info *, struct bfd_section *, const char *, const char *);
-
 extern void _bfd_fix_excluded_sec_syms
   (bfd *, struct bfd_link_info *);
 
index 5f51a3a7fbcfecb85e3cf0600e829d3dfce88192..168e58cdaf32888a57058e5e4de3dee00a285619 100644 (file)
@@ -1668,8 +1668,8 @@ typedef struct elf_linker_section
   const char *bss_name;
   /* Associated symbol name.  */
   const char *sym_name;
-  /* Value of symbol.  */
-  bfd_vma sym_val;
+  /* Associated symbol.  */
+  struct elf_link_hash_entry *sym;
 } elf_linker_section_t;
 
 /* Linked list of allocated pointer entries.  This hangs off of the
@@ -2734,6 +2734,20 @@ ppc_elf_add_symbol_hook (bfd *abfd,
   return TRUE;
 }
 \f
+static bfd_boolean
+create_sdata_sym (struct ppc_elf_link_hash_table *htab,
+                 elf_linker_section_t *lsect)
+{
+  lsect->sym = elf_link_hash_lookup (&htab->elf, lsect->sym_name,
+                                    TRUE, FALSE, TRUE);
+  if (lsect->sym == NULL)
+    return FALSE;
+  if (lsect->sym->root.type == bfd_link_hash_new)
+    lsect->sym->non_elf = 0;
+  lsect->sym->ref_regular = 1;
+  return TRUE;
+}
+
 /* Create a special linker section.  */
 
 static bfd_boolean
@@ -2760,7 +2774,7 @@ ppc_elf_create_linker_section (bfd *abfd,
     return FALSE;
   lsect->section = s;
 
-  return TRUE;
+  return create_sdata_sym (htab, lsect);
 }
 
 /* Find a linker generated pointer with a given addend and type.  */
@@ -3090,6 +3104,11 @@ ppc_elf_check_relocs (bfd *abfd,
          if (!elf_create_pointer_linker_section (abfd, &htab->sdata[0],
                                                  h, rel))
            return FALSE;
+         if (h != NULL)
+           {
+             ppc_elf_hash_entry (h)->has_sda_refs = TRUE;
+             h->non_got_ref = TRUE;
+           }
          break;
 
          /* Indirect .sdata2 relocation.  */
@@ -3106,12 +3125,65 @@ ppc_elf_check_relocs (bfd *abfd,
          if (!elf_create_pointer_linker_section (abfd, &htab->sdata[1],
                                                  h, rel))
            return FALSE;
+         if (h != NULL)
+           {
+             ppc_elf_hash_entry (h)->has_sda_refs = TRUE;
+             h->non_got_ref = TRUE;
+           }
          break;
 
        case R_PPC_SDAREL16:
+         if (info->shared)
+           {
+             bad_shared_reloc (abfd, r_type);
+             return FALSE;
+           }
+         if (htab->sdata[0].sym == NULL
+             && !create_sdata_sym (htab, &htab->sdata[0]))
+           return FALSE;
+         if (h != NULL)
+           {
+             ppc_elf_hash_entry (h)->has_sda_refs = TRUE;
+             h->non_got_ref = TRUE;
+           }
+         break;
+
        case R_PPC_EMB_SDA2REL:
+         if (info->shared)
+           {
+             bad_shared_reloc (abfd, r_type);
+             return FALSE;
+           }
+         if (htab->sdata[1].sym == NULL
+             && !create_sdata_sym (htab, &htab->sdata[1]))
+           return FALSE;
+         if (h != NULL)
+           {
+             ppc_elf_hash_entry (h)->has_sda_refs = TRUE;
+             h->non_got_ref = TRUE;
+           }
+         break;
+
        case R_PPC_EMB_SDA21:
        case R_PPC_EMB_RELSDA:
+         if (info->shared)
+           {
+             bad_shared_reloc (abfd, r_type);
+             return FALSE;
+           }
+         if (htab->sdata[0].sym == NULL
+             && !create_sdata_sym (htab, &htab->sdata[0]))
+           return FALSE;
+         if (htab->sdata[1].sym == NULL
+             && !create_sdata_sym (htab, &htab->sdata[1]))
+           return FALSE;
+         if (h != NULL)
+           {
+             ppc_elf_hash_entry (h)->has_sda_refs = TRUE;
+             h->non_got_ref = TRUE;
+           }
+         break;
+
        case R_PPC_EMB_NADDR32:
        case R_PPC_EMB_NADDR16:
        case R_PPC_EMB_NADDR16_LO:
@@ -3123,11 +3195,7 @@ ppc_elf_check_relocs (bfd *abfd,
              return FALSE;
            }
          if (h != NULL)
-           {
-             ppc_elf_hash_entry (h)->has_sda_refs = TRUE;
-             /* We may need a copy reloc.  */
-             h->non_got_ref = TRUE;
-           }
+           h->non_got_ref = TRUE;
          break;
 
        case R_PPC_PLT32:
@@ -4046,24 +4114,6 @@ ppc_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
   /* This is a reference to a symbol defined by a dynamic object which
      is not a function.  */
 
-  /* First, a fudge for old shared libs that export some symbols they
-     should not.  */
-  if (!h->def_regular
-      && (strcmp (h->root.root.string, "_SDA_BASE_") == 0
-         || strcmp (h->root.root.string, "_SDA2_BASE_") == 0))
-    {
-      /* These symbols will be defined later, as if they were defined in
-        a linker script.  We don't want to use a definition in a shared
-        object.  */
-      const struct elf_backend_data *bed;
-
-      bed = get_elf_backend_data (htab->elf.dynobj);
-      (*bed->elf_backend_hide_symbol) (info, h, TRUE);
-      h->root.type = bfd_link_hash_undefined;
-      h->root.u.undef.abfd = htab->elf.dynobj;
-      return TRUE;
-    }
-
   /* If we are creating a shared library, we must presume that the
      only references to the symbol are via the global offset table.
      For such cases we need not do anything here; the relocations will
@@ -5259,52 +5309,6 @@ ppc_elf_relax_section (bfd *abfd,
   return FALSE;
 }
 \f
-/* Set _SDA_BASE_, _SDA2_BASE, and sbss start and end syms.  They are
-   set here rather than via PROVIDE in the default linker script,
-   because using PROVIDE inside an output section statement results in
-   unnecessary output sections.  Using PROVIDE outside an output section
-   statement runs the risk of section alignment affecting where the
-   section starts.  */
-
-void
-ppc_elf_set_sdata_syms (bfd *obfd, struct bfd_link_info *info)
-{
-  struct ppc_elf_link_hash_table *htab;
-  unsigned i;
-  asection *s;
-  bfd_vma val;
-
-  htab = ppc_elf_hash_table (info);
-
-  for (i = 0; i < 2; i++)
-    {
-      elf_linker_section_t *lsect = &htab->sdata[i];
-
-      s = lsect->section;
-      if (s != NULL)
-       s = s->output_section;
-      if (s == NULL)
-       s = bfd_get_section_by_name (obfd, lsect->name);
-      if (s == NULL)
-       s = bfd_get_section_by_name (obfd, lsect->bss_name);
-
-      if (s)
-       {
-         /* VxWorks executables are relocatable, so the sdata base symbols
-            must be section-relative.  */
-         val = 32768;
-         lsect->sym_val = val + s->vma;
-       }
-      else
-       {
-         val = 0;
-         lsect->sym_val = 0;
-       }
-
-      _bfd_elf_provide_symbol (info, lsect->sym_name, val, s);
-    }
-}
-
 /* What to do when ld finds relocations against symbols defined in
    discarded sections.  */
 
@@ -6348,6 +6352,7 @@ ppc_elf_relocate_section (bfd *output_bfd,
        case R_PPC_SDAREL16:
          {
            const char *name;
+           struct elf_link_hash_entry *sh;
 
            BFD_ASSERT (sec != NULL);
            name = bfd_get_section_name (abfd, sec->output_section);
@@ -6364,7 +6369,10 @@ ppc_elf_relocate_section (bfd *output_bfd,
                   howto->name,
                   name);
              }
-           addend -= htab->sdata[0].sym_val;
+           sh = htab->sdata[0].sym;
+           addend -= (sh->root.u.def.value
+                      + sh->root.u.def.section->output_offset
+                      + sh->root.u.def.section->output_section->vma);
          }
          break;
 
@@ -6372,6 +6380,7 @@ ppc_elf_relocate_section (bfd *output_bfd,
        case R_PPC_EMB_SDA2REL:
          {
            const char *name;
+           struct elf_link_hash_entry *sh;
 
            BFD_ASSERT (sec != NULL);
            name = bfd_get_section_name (abfd, sec->output_section);
@@ -6390,7 +6399,10 @@ ppc_elf_relocate_section (bfd *output_bfd,
                ret = FALSE;
                continue;
              }
-           addend -= htab->sdata[1].sym_val;
+           sh = htab->sdata[1].sym;
+           addend -= (sh->root.u.def.value
+                      + sh->root.u.def.section->output_offset
+                      + sh->root.u.def.section->output_section->vma);
          }
          break;
 
@@ -6400,6 +6412,7 @@ ppc_elf_relocate_section (bfd *output_bfd,
          {
            const char *name;
            int reg;
+           struct elf_link_hash_entry *sh;
 
            BFD_ASSERT (sec != NULL);
            name = bfd_get_section_name (abfd, sec->output_section);
@@ -6409,14 +6422,20 @@ ppc_elf_relocate_section (bfd *output_bfd,
                     && (name[5] == 0 || name[5] == '.'))))
              {
                reg = 13;
-               addend -= htab->sdata[0].sym_val;
+               sh = htab->sdata[0].sym;
+               addend -= (sh->root.u.def.value
+                          + sh->root.u.def.section->output_offset
+                          + sh->root.u.def.section->output_section->vma);
              }
 
            else if (strncmp (name, ".sdata2", 7) == 0
                     || strncmp (name, ".sbss2", 6) == 0)
              {
                reg = 2;
-               addend -= htab->sdata[1].sym_val;
+               sh = htab->sdata[1].sym;
+               addend -= (sh->root.u.def.value
+                          + sh->root.u.def.section->output_offset
+                          + sh->root.u.def.section->output_section->vma);
              }
 
            else if (strcmp (name, ".PPC.EMB.sdata0") == 0
index 457ba8e6213209f8480ae8d628d6cd9484e406a8..7b7cdddf2f425e4e1e97332d0f507395c49d93cc 100644 (file)
@@ -5032,6 +5032,7 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd,
       asection *dynstr;
       struct bfd_elf_version_tree *t;
       struct bfd_elf_version_expr *d;
+      asection *s;
       bfd_boolean all_defined;
 
       *sinterpptr = bfd_get_section_by_name (dynobj, ".interp");
@@ -5235,7 +5236,8 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd,
            return FALSE;
        }
 
-      if (bfd_get_section_by_name (output_bfd, ".preinit_array") != NULL)
+      s = bfd_get_section_by_name (output_bfd, ".preinit_array");
+      if (s != NULL && s->linker_has_input)
        {
          /* DT_PREINIT_ARRAY is not allowed in shared library.  */
          if (! info->executable)
@@ -5263,13 +5265,15 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd,
              || !_bfd_elf_add_dynamic_entry (info, DT_PREINIT_ARRAYSZ, 0))
            return FALSE;
        }
-      if (bfd_get_section_by_name (output_bfd, ".init_array") != NULL)
+      s = bfd_get_section_by_name (output_bfd, ".init_array");
+      if (s != NULL && s->linker_has_input)
        {
          if (!_bfd_elf_add_dynamic_entry (info, DT_INIT_ARRAY, 0)
              || !_bfd_elf_add_dynamic_entry (info, DT_INIT_ARRAYSZ, 0))
            return FALSE;
        }
-      if (bfd_get_section_by_name (output_bfd, ".fini_array") != NULL)
+      s = bfd_get_section_by_name (output_bfd, ".fini_array");
+      if (s != NULL && s->linker_has_input)
        {
          if (!_bfd_elf_add_dynamic_entry (info, DT_FINI_ARRAY, 0)
              || !_bfd_elf_add_dynamic_entry (info, DT_FINI_ARRAYSZ, 0))
@@ -9841,55 +9845,6 @@ _bfd_elf_section_already_linked (bfd *abfd, struct bfd_section * sec)
   bfd_section_already_linked_table_insert (already_linked_list, sec);
 }
 
-static void
-bfd_elf_set_symbol (struct elf_link_hash_entry *h, bfd_vma val,
-                   struct bfd_section *s)
-{
-  h->root.type = bfd_link_hash_defined;
-  h->root.u.def.section = s ? s : bfd_abs_section_ptr;
-  h->root.u.def.value = val;
-  h->def_regular = 1;
-  h->type = STT_OBJECT;
-  h->other = STV_HIDDEN | (h->other & ~ ELF_ST_VISIBILITY (-1));
-  h->forced_local = 1;
-}
-
-/* Set NAME to VAL if the symbol exists and is not defined in a regular
-   object file.  If S is NULL it is an absolute symbol, otherwise it is
-   relative to that section.  */
-
-void
-_bfd_elf_provide_symbol (struct bfd_link_info *info, const char *name,
-                        bfd_vma val, struct bfd_section *s)
-{
-  struct elf_link_hash_entry *h;
-
-  bfd_elf_record_link_assignment (info, name, TRUE);
-
-  h = elf_link_hash_lookup (elf_hash_table (info), name, FALSE, FALSE, FALSE);
-  if (h != NULL
-      && !(h->root.type == bfd_link_hash_defined
-          && h->root.u.def.section != NULL
-          && h->root.u.def.section != h->root.u.def.section->output_section))
-    bfd_elf_set_symbol (h, val, s);
-}
-
-/* Set START and END to boundaries of SEC if they exist and are not
-   defined in regular object files.  */
-
-void
-_bfd_elf_provide_section_bound_symbols (struct bfd_link_info *info,
-                                       asection *sec,
-                                       const char *start,
-                                       const char *end)
-{
-  bfd_vma val = 0;
-  _bfd_elf_provide_symbol (info, start, val, sec);
-  if (sec != NULL)
-    val = sec->size;
-  _bfd_elf_provide_symbol (info, end, val, sec);
-}
-
 bfd_boolean
 _bfd_elf_common_definition (Elf_Internal_Sym *sym)
 {
index de94006933502df24c741ba4e16935a806b583e0..907208f20682c471d0d9e47a7575aea01b29fac0 100644 (file)
@@ -1,3 +1,33 @@
+2005-08-04  Alan Modra  <amodra@bigpond.net.au>
+
+       * ldemul.c (ldemul_do_assignments, do_assignments_default): Delete.
+       * ldemul.h (ldemul_do_assignments, do_assignments_default): Delete.
+       (struct ld_emulation_xfer_struct): Remove do_assignments field.
+       * ldlang.c (lang_do_assignments): Don't call ldemul_do_assignments.
+       * emulparams/elf32ppc.sh (SDATA_START_SYMBOLS): New.
+       (SDATA2_START_SYMBOLS, SBSS_START_SYMBOLS, SBSS_END_SYMBOLS): New.
+       * emultempl/aix.em (ld_*_emulation): Delete do_assignments init.
+       * emultempl/armcoff.em: Likewise.
+       * emultempl/beos.em: Likewise.
+       * emultempl/generic.em: Likewise.
+       * emultempl/gld960.em: Likewise.
+       * emultempl/gld960c.em: Likewise.
+       * emultempl/linux.em: Likewise.
+       * emultempl/lnk960.em: Likewise.
+       * emultempl/m68kcoff.em: Likewise.
+       * emultempl/pe.em: Likewise.
+       * emultempl/sunos.em: Likewise.
+       * emultempl/ticoff.em: Likewise.
+       * emultempl/vanilla.em: Likewise.
+       * emultempl/elf32.em: Likewise.
+       (gld*_provide_bound_symbols): Delete.
+       (gld*_provide_init_fini_syms): Delete.
+       (gld*_before_allocation): Don't call ldemul_do_assignments.
+       * emultempl/ppc32elf.em (ppc_do_assignments): Delete.
+       (LDEMUL_DO_ASSIGNMENTS): Delete.
+       * scripttempl/elf.sc: Provide init/fini syms.  Add SBSS_START_SYMBOLS,
+       SBSS_END_SYMBOLS, SDATA2_START_SYMBOLS.
+
 2005-08-04  Alan Modra  <amodra@bigpond.net.au>
 
        * Makefile.am (eelf32m32c.c): Fix dependencies.
index e5b22524b555411797ae8d6d0184f23ea03850f8..ad6876dd4fb1fa70e928bdcf16feec4d35f1f4a1 100644 (file)
@@ -23,6 +23,17 @@ PLT=".plt          ${RELOCATING-0} : SPECIAL { *(.plt) }"
 GOTPLT="${PLT}"
 OTHER_TEXT_SECTIONS="*(.glink)"
 EXECUTABLE_SYMBOLS='PROVIDE (__stack = 0); PROVIDE (___stack = 0);'
+if test -z "${CREATE_SHLIB}"; then
+  SDATA_START_SYMBOLS="PROVIDE (_SDA_BASE_ = 32768);"
+  SDATA2_START_SYMBOLS="PROVIDE (_SDA2_BASE_ = 32768);"
+  SBSS_START_SYMBOLS="PROVIDE (__sbss_start = .); PROVIDE (___sbss_start = .);"
+  SBSS_END_SYMBOLS="PROVIDE (__sbss_end = .); PROVIDE (___sbss_end = .);"
+else
+  unset SDATA_START_SYMBOLS
+  unset SDATA2_START_SYMBOLS
+  unset SBSS_START_SYMBOLS
+  unset SBSS_END_SYMBOLS
+fi
 OTHER_END_SYMBOLS="__end = .;"
 OTHER_RELRO_SECTIONS="
   .fixup        ${RELOCATING-0} : { *(.fixup) }
index 8763155b7e2533fa7f9bb9e1c61bf5a3e17a29b1..d525edd890455ab06798430e0366b13c66c5b79a 100644 (file)
@@ -1339,7 +1339,6 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = {
   gld${EMULATION_NAME}_set_output_arch,
   gld${EMULATION_NAME}_choose_target,
   gld${EMULATION_NAME}_before_allocation,
-  do_assignments_default,
   gld${EMULATION_NAME}_get_script,
   "${EMULATION_NAME}",
   "${OUTPUT_FORMAT}",
index acf117cb414adeaa720af83d977b70560e66f3ba..d5fd67d8ce2e850ee73bf37e187c3c9ead08718a 100644 (file)
@@ -261,7 +261,6 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
   set_output_arch_default,
   ldemul_default_target,
   gld${EMULATION_NAME}_before_allocation,
-  do_assignments_default,
   gld${EMULATION_NAME}_get_script,
   "${EMULATION_NAME}",
   "${OUTPUT_FORMAT}",
index e07677b314240c672d5852d948a2c4e0abea87c3..0b06bc742087d2e361edf96be87860863f1b270b 100644 (file)
@@ -766,7 +766,6 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
   set_output_arch_default,
   ldemul_default_target,
   gld_${EMULATION_NAME}_before_allocation,
-  do_assignments_default,
   gld_${EMULATION_NAME}_get_script,
   "${EMULATION_NAME}",
   "${OUTPUT_FORMAT}",
index e43c8c5a8305bda13b3958c486ece65e1a46204c..2764a59d9685820cfe89668d33fd5ae9d3fc0725 100644 (file)
@@ -57,7 +57,6 @@ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
 /* Declare functions used by various EXTRA_EM_FILEs.  */
 static void gld${EMULATION_NAME}_before_parse (void);
 static void gld${EMULATION_NAME}_after_open (void);
-static void gld${EMULATION_NAME}_provide_init_fini_syms (void);
 static void gld${EMULATION_NAME}_before_allocation (void);
 static bfd_boolean gld${EMULATION_NAME}_place_orphan
   (lang_input_statement_type *file, asection *s);
@@ -1040,47 +1039,6 @@ if test x"$LDEMUL_BEFORE_ALLOCATION" != xgld"$EMULATION_NAME"_before_allocation;
   fi
 cat >>e${EMULATION_NAME}.c <<EOF
 
-static void
-gld${EMULATION_NAME}_provide_bound_symbols (const char *sec,
-                                           const char *start,
-                                           const char *end)
-{
-  asection *s = bfd_get_section_by_name (output_bfd, sec);
-  _bfd_elf_provide_section_bound_symbols (&link_info, s, start, end);
-}
-
-/* If not building a shared library, provide
-
-   __preinit_array_start
-   __preinit_array_end
-   __init_array_start
-   __init_array_end
-   __fini_array_start
-   __fini_array_end
-
-   They are set here rather than via PROVIDE in the linker
-   script, because using PROVIDE inside an output section
-   statement results in unnecessary output sections.  Using
-   PROVIDE outside an output section statement runs the risk of
-   section alignment affecting where the section starts.  */
-
-static void
-gld${EMULATION_NAME}_provide_init_fini_syms (void)
-{
-  if (!link_info.relocatable && link_info.executable)
-    {
-      gld${EMULATION_NAME}_provide_bound_symbols (".preinit_array",
-                                                 "__preinit_array_start",
-                                                 "__preinit_array_end");
-      gld${EMULATION_NAME}_provide_bound_symbols (".init_array",
-                                                 "__init_array_start",
-                                                 "__init_array_end");
-      gld${EMULATION_NAME}_provide_bound_symbols (".fini_array",
-                                                 "__fini_array_start",
-                                                 "__fini_array_end");
-    }
-}
-
 /* This is called after the sections have been attached to output
    sections, but before any sizes or addresses have been set.  */
 
@@ -1098,8 +1056,6 @@ gld${EMULATION_NAME}_before_allocation (void)
      referred to by dynamic objects.  */
   lang_for_each_statement (gld${EMULATION_NAME}_find_statement_assignment);
 
-  ldemul_do_assignments ();
-
   /* Let the ELF backend work out the sizes of any sections required
      by dynamic linking.  */
   rpath = command_line.rpath;
@@ -1881,7 +1837,6 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
   ${LDEMUL_SET_OUTPUT_ARCH-set_output_arch_default},
   ${LDEMUL_CHOOSE_TARGET-ldemul_default_target},
   ${LDEMUL_BEFORE_ALLOCATION-gld${EMULATION_NAME}_before_allocation},
-  ${LDEMUL_DO_ASSIGNMENTS-gld${EMULATION_NAME}_provide_init_fini_syms},
   ${LDEMUL_GET_SCRIPT-gld${EMULATION_NAME}_get_script},
   "${EMULATION_NAME}",
   "${OUTPUT_FORMAT}",
index f7153b682e9994b6b2cc76f2a6ae714798d2ac53..985cdf8e24f4ac19903c17fad77ee2d1f16d9d91 100644 (file)
@@ -128,7 +128,6 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
   ${LDEMUL_SET_OUTPUT_ARCH-set_output_arch_default},
   ${LDEMUL_CHOOSE_TARGET-ldemul_default_target},
   ${LDEMUL_BEFORE_ALLOCATION-before_allocation_default},
-  ${LDEMUL_DO_ASSIGNMENTS-do_assignments_default},
   ${LDEMUL_GET_SCRIPT-gld${EMULATION_NAME}_get_script},
   "${EMULATION_NAME}",
   "${OUTPUT_FORMAT}",
index f4076223aed202e6f17b32b9b4a7c55b5afbc958..63b5bb341a3f8870166e69d147cf3583843f9108 100644 (file)
@@ -134,7 +134,6 @@ struct ld_emulation_xfer_struct ld_gld960_emulation =
   gld960_set_output_arch,
   gld960_choose_target,
   before_allocation_default,
-  do_assignments_default,
   gld960_get_script,
   "960",
   "",
index 5de01e64311e3ceb9c906547fbb107a78b1bae41..6973a06d40359e1d0c8d91b4653b6f7cf97d8041 100644 (file)
@@ -149,7 +149,6 @@ struct ld_emulation_xfer_struct ld_gld960coff_emulation =
   gld960_set_output_arch,
   gld960_choose_target,
   before_allocation_default,
-  do_assignments_default,
   gld960_get_script,
   "960coff",
   "",
index 071af80cec292c58b824678480c016437813e9b5..996a7ea1100499346415d5ac03ef75bf103e857f 100644 (file)
@@ -189,7 +189,6 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
   set_output_arch_default,
   ldemul_default_target,
   gld${EMULATION_NAME}_before_allocation,
-  do_assignments_default,
   gld${EMULATION_NAME}_get_script,
   "${EMULATION_NAME}",
   "${OUTPUT_FORMAT}",
index 14839835d4999d9b47abf259a7f3835a4b82a3f4..95384d42d5a2efac626c5cf11e9ea6d4e490e150 100644 (file)
@@ -269,7 +269,6 @@ struct ld_emulation_xfer_struct ld_lnk960_emulation =
   lnk960_set_output_arch,
   lnk960_choose_target,
   before_allocation_default,
-  do_assignments_default,
   lnk960_get_script,
   "lnk960",
   "",
index 31f98a04652736f903f1f583f8d8e5b60db6dcc5..4bf3994b67b305026f2902e1ad08ac274c6ff0c1 100644 (file)
@@ -222,7 +222,6 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
   set_output_arch_default,
   ldemul_default_target,
   before_allocation_default,
-  do_assignments_default,
   gld${EMULATION_NAME}_get_script,
   "${EMULATION_NAME}",
   "${OUTPUT_FORMAT}",
index 6e143304942a573cfe55bde7e8088c5eadde27d4..df7692d680c169052d99cc8a1306482dc00d2882 100644 (file)
@@ -1823,7 +1823,6 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
   set_output_arch_default,
   ldemul_default_target,
   gld_${EMULATION_NAME}_before_allocation,
-  do_assignments_default,
   gld_${EMULATION_NAME}_get_script,
   "${EMULATION_NAME}",
   "${OUTPUT_FORMAT}",
index ba59b80a9785fd77b7adaeaf45cee68a652f8864..e4d56de418df1cb69b56f479fbab9a3f8dfb868a 100644 (file)
@@ -117,23 +117,6 @@ ppc_before_allocation (void)
   gld${EMULATION_NAME}_before_allocation ();
 }
 
-static void
-ppc_do_assignments (void)
-{
-  asection *s;
-
-  if (is_ppc_elf32_vec (link_info.hash->creator))
-    ppc_elf_set_sdata_syms (output_bfd, &link_info);
-
-  s = bfd_get_section_by_name (output_bfd, ".sbss");
-  _bfd_elf_provide_section_bound_symbols (&link_info, s,
-                                         "__sbss_start", "__sbss_end");
-  _bfd_elf_provide_section_bound_symbols (&link_info, s,
-                                         "___sbss_start", "___sbss_end");
-
-  gld${EMULATION_NAME}_provide_init_fini_syms ();
-}
-
 EOF
 
 # Define some shell vars to insert bits of code into the standard elf
@@ -177,4 +160,3 @@ PARSE_AND_LIST_ARGS_CASES='
 #
 LDEMUL_AFTER_OPEN=ppc_after_open
 LDEMUL_BEFORE_ALLOCATION=ppc_before_allocation
-LDEMUL_DO_ASSIGNMENTS=ppc_do_assignments
index 19f18931c8849390c5d28c972c435196f559df92..a480558c90691679c4d5692d3c0f224b7131355d 100644 (file)
@@ -1013,7 +1013,6 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
   set_output_arch_default,
   ldemul_default_target,
   gld${EMULATION_NAME}_before_allocation,
-  do_assignments_default,
   gld${EMULATION_NAME}_get_script,
   "${EMULATION_NAME}",
   "${OUTPUT_FORMAT}",
index 5938ba421e07755bb582f1c98a831a5658df07ba..0382bbdd8658e497effbe4a92115f8a61354abc9 100644 (file)
@@ -162,7 +162,6 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
   set_output_arch_default,
   ldemul_default_target,
   before_allocation_default,
-  do_assignments_default,
   gld_${EMULATION_NAME}_get_script,
   "${EMULATION_NAME}",
   "${OUTPUT_FORMAT}",
index ad11f41ddbbe487a155993232f854306845a7764..21248526873405ee20cf74a5d023c65e9f2e6c81 100644 (file)
@@ -65,7 +65,6 @@ struct ld_emulation_xfer_struct ld_vanilla_emulation =
   vanilla_set_output_arch,
   ldemul_default_target,
   before_allocation_default,
-  do_assignments_default,
   vanilla_get_script,
   "vanilla",
   "a.out-sunos-big",
index 5b4796a2d97254e564dd89871be40a6e24b82940..0ff11cebe0896972d3c8dc76112549e18c84ae47 100644 (file)
@@ -79,12 +79,6 @@ ldemul_before_allocation (void)
   ld_emulation->before_allocation ();
 }
 
-void
-ldemul_do_assignments (void)
-{
-  ld_emulation->do_assignments ();
-}
-
 void
 ldemul_set_output_arch (void)
 {
@@ -221,11 +215,6 @@ before_allocation_default (void)
     strip_excluded_output_sections ();
 }
 
-void
-do_assignments_default (void)
-{
-}
-
 void
 finish_default (void)
 {
index c3ba033ecb241afc6114bdf5eab34bf86fd56acd..44538d15a63fc19d862eaa8595ffe8890065c79d 100644 (file)
@@ -35,8 +35,6 @@ extern void ldemul_after_allocation
   (void);
 extern void ldemul_before_allocation
   (void);
-extern void ldemul_do_assignments
-  (void);
 extern void ldemul_set_output_arch
   (void);
 extern char *ldemul_choose_target
@@ -79,7 +77,7 @@ extern void after_allocation_default
   (void);
 extern void before_allocation_default
   (void);
-extern void do_assignments_default
+extern void finish_default
   (void);
 extern void finish_default
   (void);
@@ -123,9 +121,6 @@ typedef struct ld_emulation_xfer_struct {
   /* Run before allocating output sections.  */
   void   (*before_allocation) (void);
 
-  /* Run to set special symbols at the same time as link script syms.  */
-  void   (*do_assignments) (void);
-
   /* Return the appropriate linker script.  */
   char * (*get_script) (int *isfile);
 
index 038af17b3b492a727e4cb4bb43d57a4df8cbf35e..fb5454c75a81acab8973fff800a9b556f84403b3 100644 (file)
@@ -3056,9 +3056,7 @@ strip_excluded_output_sections (void)
 {
   lang_output_section_statement_type *os;
 
-  /* Run lang_size_sections (if not already done) to ensure that all
-     symbols defined in the linker script are put in the bfd hash
-     table.  */
+  /* Run lang_size_sections (if not already done).  */
   if (expld.phase != lang_mark_phase_enum)
     {
       expld.phase = lang_mark_phase_enum;
@@ -4591,7 +4589,6 @@ lang_do_assignments (void)
 {
   lang_statement_iteration++;
   lang_do_assignments_1 (statement_list.head, abs_output_section, NULL, 0);
-  ldemul_do_assignments ();
 }
 
 /* Fix any .startof. or .sizeof. symbols.  When the assemblers see the
index 741d5294af9c0c3144faa32cd66cfc2d2cd04589..3ee8b43693b6bc59d4af240c0d0b5ee3a99fa09b 100644 (file)
@@ -123,10 +123,12 @@ STACKNOTE="/DISCARD/ : { *(.note.GNU-stack) }"
 if test -z "${NO_SMALL_DATA}"; then
   SBSS=".sbss         ${RELOCATING-0} :
   {
+    ${RELOCATING+${SBSS_START_SYMBOLS}}
     ${CREATE_SHLIB+*(.sbss2 .sbss2.* .gnu.linkonce.sb2.*)}
     *(.dynsbss)
     *(.sbss${RELOCATING+ .sbss.* .gnu.linkonce.sb.*})
     *(.scommon)
+    ${RELOCATING+${SBSS_END_SYMBOLS}}
   }"
   SBSS2=".sbss2        ${RELOCATING-0} : { *(.sbss2${RELOCATING+ .sbss2.* .gnu.linkonce.sb2.*}) }"
   SDATA="/* We want the small data sections together, so single-instruction offsets
@@ -138,7 +140,11 @@ if test -z "${NO_SMALL_DATA}"; then
     ${CREATE_SHLIB+*(.sdata2 .sdata2.* .gnu.linkonce.s2.*)}
     *(.sdata${RELOCATING+ .sdata.* .gnu.linkonce.s.*})
   }"
-  SDATA2=".sdata2       ${RELOCATING-0} : { *(.sdata2${RELOCATING+ .sdata2.* .gnu.linkonce.s2.*}) }"
+  SDATA2=".sdata2       ${RELOCATING-0} :
+  {
+    ${RELOCATING+${SDATA2_START_SYMBOLS}}
+    *(.sdata2${RELOCATING+ .sdata2.* .gnu.linkonce.s2.*})
+  }"
   REL_SDATA=".rel.sdata    ${RELOCATING-0} : { *(.rel.sdata${RELOCATING+ .rel.sdata.* .rel.gnu.linkonce.s.*}) }
   .rela.sdata   ${RELOCATING-0} : { *(.rela.sdata${RELOCATING+ .rela.sdata.* .rela.gnu.linkonce.s.*}) }"
   REL_SBSS=".rel.sbss     ${RELOCATING-0} : { *(.rel.sbss${RELOCATING+ .rel.sbss.* .rel.gnu.linkonce.sb.*}) }
@@ -376,10 +382,24 @@ cat <<EOF
   .tdata       ${RELOCATING-0} : { *(.tdata${RELOCATING+ .tdata.* .gnu.linkonce.td.*}) }
   .tbss                ${RELOCATING-0} : { *(.tbss${RELOCATING+ .tbss.* .gnu.linkonce.tb.*})${RELOCATING+ *(.tcommon)} }
 
-  .preinit_array   ${RELOCATING-0} : { KEEP (*(.preinit_array)) }
-  .init_array   ${RELOCATING-0} : { KEEP (*(.init_array)) }
-  .fini_array   ${RELOCATING-0} : { KEEP (*(.fini_array)) }
-
+  .preinit_array   ${RELOCATING-0} :
+  {
+    ${RELOCATING+${CREATE_SHLIB-PROVIDE (__preinit_array_start = .);}}
+    KEEP (*(.preinit_array))
+    ${RELOCATING+${CREATE_SHLIB-PROVIDE (__preinit_array_end = .);}}
+  }
+  .init_array   ${RELOCATING-0} :
+  {
+     ${RELOCATING+${CREATE_SHLIB-PROVIDE (__init_array_start = .);}}
+     KEEP (*(.init_array))
+     ${RELOCATING+${CREATE_SHLIB-PROVIDE (__init_array_end = .);}}
+  }
+  .fini_array   ${RELOCATING-0} :
+  {
+    ${RELOCATING+${CREATE_SHLIB-PROVIDE (__fini_array_start = .);}}
+    KEEP (*(.fini_array))
+    ${RELOCATING+${CREATE_SHLIB-PROVIDE (__fini_array_end = .);}}
+  }
   ${SMALL_DATA_CTOR-${RELOCATING+${CTOR}}}
   ${SMALL_DATA_DTOR-${RELOCATING+${DTOR}}}
   .jcr          ${RELOCATING-0} : { KEEP (*(.jcr)) }