bfd/
authorAlan Modra <amodra@gmail.com>
Thu, 14 Jul 2005 13:54:23 +0000 (13:54 +0000)
committerAlan Modra <amodra@gmail.com>
Thu, 14 Jul 2005 13:54:23 +0000 (13:54 +0000)
* bfd-in.h (_bfd_elf_fix_excluded_sec_syms): Declare.
(_bfd_elf_provide_section_bound_symbols): Remove param name.
Formatting.
* bfd-in2.h: Regenerate.
* elflink.c (bfd_elf_gc_sections): Don't call generic function.
(_bfd_elf_provide_symbol): Formatting.
(_bfd_elf_provide_section_bound_symbols): Remove all hacks, just
create section relative syms.
(fix_syms, _bfd_elf_fix_excluded_sec_syms): New functions.
* elf32-ppc.c (ppc_elf_set_sdata_syms): Use
_bfd_elf_provide_section_bound_symbols.
* reloc.c (bfd_mark_used_section): Delete.
(bfd_generic_gc_sections): Don't call the above.
ld/
* ldlang.c (strip_excluded_output_sections): Don't call
bfd_gc_sections.
* emultempl/elf32.em (gld*_provide_bound_symbols): Move.
(gld*_provide_init_fini_syms): Move.
(gld*_before_allocation): Call the above from here..
(gld*_finish): ..not here.  Call _bfd_elf_fix_excluded_sec_syms.
* emultempl/hppaelf.em (hppaelf_finish): Likewise.
* emultempl/ppc64elf.em (ppc_finish): Likewise.

bfd/ChangeLog
bfd/bfd-in.h
bfd/bfd-in2.h
bfd/elf32-ppc.c
bfd/elflink.c
bfd/reloc.c
ld/ChangeLog
ld/emultempl/elf32.em
ld/emultempl/hppaelf.em
ld/emultempl/ppc64elf.em
ld/ldlang.c

index ddb07b74c1c7c7dd1bab2cc8db65271e8b90ee23..17d27fac5c5caa98ecc1c836e4ef49657df650a7 100644 (file)
@@ -1,3 +1,19 @@
+2005-07-14  Alan Modra  <amodra@bigpond.net.au>
+
+       * bfd-in.h (_bfd_elf_fix_excluded_sec_syms): Declare.
+       (_bfd_elf_provide_section_bound_symbols): Remove param name.
+       Formatting.
+       * bfd-in2.h: Regenerate.
+       * elflink.c (bfd_elf_gc_sections): Don't call generic function.
+       (_bfd_elf_provide_symbol): Formatting.
+       (_bfd_elf_provide_section_bound_symbols): Remove all hacks, just
+       create section relative syms.
+       (fix_syms, _bfd_elf_fix_excluded_sec_syms): New functions.
+       * elf32-ppc.c (ppc_elf_set_sdata_syms): Use
+       _bfd_elf_provide_section_bound_symbols.
+       * reloc.c (bfd_mark_used_section): Delete.
+       (bfd_generic_gc_sections): Don't call the above.
+
 2005-07-14  Paul Woegerer <paul.woegerer@nsc.com>
 
        PR 1063
@@ -10,7 +26,7 @@
        Alpha binaries and issue a helpful error message.
        (alpha_ecoff_swap_reloc_out): Increase maximum allowed internal
        symbol index to 15 to allow for binaries produced by DEC
-       compilers.      
+       compilers.
 
 2005-07-13  Steve Ellcey  <sje@cup.hp.com>
 
@@ -42,7 +58,7 @@
 2005-07-08  Ralf Corsepius <ralf.corsepius@rtems.org>
 
        * config.bfd: Mark i960-*-rtems*, or32-*-rtems* as obsolete.
-       Mark a29k-*rtems*, hppa*-*-rtems*, *-go32-rtems*, 
+       Mark a29k-*rtems*, hppa*-*-rtems*, *-go32-rtems*,
        i[3-7]86*-*-rtemscoff*, mips*el-*-rtems*, powerpcle-*-rtems*,
        sparc*-*-rtemsaout* as removed
 
index 4d999b9f1d06c95025e39a2f3ae97195186d6edc..34188d118e96e5972be8ade9a54d1b3bcab6b0dc 100644 (file)
@@ -704,10 +704,14 @@ 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 *sec, const char *, const char *);
+  (struct bfd_link_info *, struct bfd_section *, const char *, const char *);
+
+extern void _bfd_elf_fix_excluded_sec_syms
+  (bfd *, struct bfd_link_info *);
 
 extern bfd_boolean bfd_m68k_elf32_create_embedded_relocs
-  (bfd *, struct bfd_link_info *, struct bfd_section *, struct bfd_section *, char **);
+  (bfd *, struct bfd_link_info *, struct bfd_section *, struct bfd_section *,
+   char **);
 
 /* SunOS shared library support routines for the linker.  */
 
@@ -716,7 +720,8 @@ extern struct bfd_link_needed_list *bfd_sunos_get_needed_list
 extern bfd_boolean bfd_sunos_record_link_assignment
   (bfd *, struct bfd_link_info *, const char *);
 extern bfd_boolean bfd_sunos_size_dynamic_sections
-  (bfd *, struct bfd_link_info *, struct bfd_section **, struct bfd_section **, struct bfd_section **);
+  (bfd *, struct bfd_link_info *, struct bfd_section **,
+   struct bfd_section **, struct bfd_section **);
 
 /* Linux shared library support routines for the linker.  */
 
index ada5e0ebf8ce6501ec26bef11ed0c6d755f21da5..0073c12d196eb342d475bc8d85254405e1e105db 100644 (file)
@@ -711,10 +711,14 @@ 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 *sec, const char *, const char *);
+  (struct bfd_link_info *, struct bfd_section *, const char *, const char *);
+
+extern void _bfd_elf_fix_excluded_sec_syms
+  (bfd *, struct bfd_link_info *);
 
 extern bfd_boolean bfd_m68k_elf32_create_embedded_relocs
-  (bfd *, struct bfd_link_info *, struct bfd_section *, struct bfd_section *, char **);
+  (bfd *, struct bfd_link_info *, struct bfd_section *, struct bfd_section *,
+   char **);
 
 /* SunOS shared library support routines for the linker.  */
 
@@ -723,7 +727,8 @@ extern struct bfd_link_needed_list *bfd_sunos_get_needed_list
 extern bfd_boolean bfd_sunos_record_link_assignment
   (bfd *, struct bfd_link_info *, const char *);
 extern bfd_boolean bfd_sunos_size_dynamic_sections
-  (bfd *, struct bfd_link_info *, struct bfd_section **, struct bfd_section **, struct bfd_section **);
+  (bfd *, struct bfd_link_info *, struct bfd_section **,
+   struct bfd_section **, struct bfd_section **);
 
 /* Linux shared library support routines for the linker.  */
 
index 9b306e51ced5aac94339ac51648d7c2c1e883889..d4ef6120d25792afc1ea34eff6d2ac44e0182d75 100644 (file)
@@ -5307,13 +5307,10 @@ ppc_elf_set_sdata_syms (bfd *obfd, struct bfd_link_info *info)
     }
 
   s = bfd_get_section_by_name (obfd, ".sbss");
-  val = 0;
-  _bfd_elf_provide_symbol (info, "__sbss_start", val, s);
-  _bfd_elf_provide_symbol (info, "___sbss_start", val, s);
-  if (s != NULL)
-    val = s->size;
-  _bfd_elf_provide_symbol (info, "__sbss_end", val, s);
-  _bfd_elf_provide_symbol (info, "___sbss_end", val, s);
+  _bfd_elf_provide_section_bound_symbols (info, s,
+                                         "__sbss_start", "__sbss_end");
+  _bfd_elf_provide_section_bound_symbols (info, s,
+                                         "___sbss_start", "___sbss_end");
   return TRUE;
 }
 \f
index 6177f5324e411828c210b55417e4d31d870a0732..791575ba07a37d66362f4670cf67586464bd0433 100644 (file)
@@ -9119,9 +9119,6 @@ bfd_elf_gc_sections (bfd *abfd, struct bfd_link_info *info)
     (asection *, struct bfd_link_info *, Elf_Internal_Rela *,
      struct elf_link_hash_entry *h, Elf_Internal_Sym *);
 
-  if (!info->gc_sections)
-    return bfd_generic_gc_sections (abfd, info);
-
   if (!get_elf_backend_data (abfd)->can_gc_sections
       || info->relocatable
       || info->emitrelocations
@@ -9846,8 +9843,7 @@ _bfd_elf_provide_symbol (struct bfd_link_info *info, const char *name,
 {
   struct elf_link_hash_entry *h;
 
-  h = elf_link_hash_lookup (elf_hash_table (info), name, FALSE, FALSE,
-                           FALSE);
+  h = elf_link_hash_lookup (elf_hash_table (info), name, FALSE, FALSE, FALSE);
   if (h != NULL && !h->def_regular)
     bfd_elf_set_symbol (h, val, s);
 }
@@ -9861,45 +9857,41 @@ _bfd_elf_provide_section_bound_symbols (struct bfd_link_info *info,
                                        const char *start,
                                        const char *end)
 {
-  struct elf_link_hash_entry *hs, *he;
-  bfd_vma start_val, end_val;
-  bfd_boolean do_start, do_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);
+}
 
-  /* Check if we need them or not first.  */
-  hs = elf_link_hash_lookup (elf_hash_table (info), start, FALSE,
-                            FALSE, FALSE);
-  do_start = hs != NULL && !hs->def_regular;
+/* Convert symbols in excluded output sections to absolute.  */
 
-  he = elf_link_hash_lookup (elf_hash_table (info), end, FALSE,
-                            FALSE, FALSE);
-  do_end = he != NULL && !he->def_regular;
+static bfd_boolean
+fix_syms (struct bfd_link_hash_entry *h, void *data)
+{
+  bfd *obfd = (bfd *) data;
 
-  if (!do_start && !do_end)
-    return;
+  if (h->type == bfd_link_hash_warning)
+    h = h->u.i.link;
 
-  if (sec != NULL)
+  if (h->type == bfd_link_hash_defined
+      || h->type == bfd_link_hash_defweak)
     {
-      start_val = sec->vma;
-      end_val = start_val + sec->size;
-    }
-  else
-    {
-      /* We have to choose those values very carefully.  Some targets,
-        like alpha, may have relocation overflow with 0. "__bss_start"
-        should be defined in all cases.  */
-      struct elf_link_hash_entry *h
-       = elf_link_hash_lookup (elf_hash_table (info), "__bss_start",
-                               FALSE, FALSE, FALSE);
-      if (h != NULL && h->root.type == bfd_link_hash_defined)
-       start_val = h->root.u.def.value;
-      else
-       start_val = 0;
-      end_val = start_val;
+      asection *s = h->u.def.section;
+      if (s != NULL
+         && s == s->output_section
+         && bfd_section_removed_from_list (obfd, s))
+       {
+         h->u.def.value += s->vma;
+         h->u.def.section = bfd_abs_section_ptr;
+       }
     }
 
-  if (do_start)
-    bfd_elf_set_symbol (hs, start_val, NULL);
+  return TRUE;
+}
 
-  if (do_end)
-    bfd_elf_set_symbol (he, end_val, NULL);
+void
+_bfd_elf_fix_excluded_sec_syms (bfd *obfd, struct bfd_link_info *info)
+{
+  bfd_link_hash_traverse (info->hash, fix_syms, obfd);
 }
index 1b15e6a6e4d469372ee46e4a131d3a9c06f087de..9d10d25d24e9993ed31b42aeebbfe3252a551ed7 100644 (file)
@@ -4520,27 +4520,6 @@ bfd_generic_relax_section (bfd *abfd ATTRIBUTE_UNUSED,
   return TRUE;
 }
 
-/* Mark sections containing global symbols.  This is called through
-   bfd_link_hash_traverse.  */
-
-static bfd_boolean
-bfd_mark_used_section (struct bfd_link_hash_entry *h,
-                      void *data ATTRIBUTE_UNUSED)
-{
-  if (h->type == bfd_link_hash_warning)
-    h = h->u.i.link;
-
-  if (h->type == bfd_link_hash_defined
-      || h->type == bfd_link_hash_defweak)
-    {
-      asection *s = h->u.def.section;
-      if (s != NULL && s->output_section != NULL)
-       s->output_section->flags |= SEC_KEEP;
-    }
-
-  return TRUE;
-}
-
 /*
 INTERNAL_FUNCTION
        bfd_generic_gc_sections
@@ -4551,18 +4530,13 @@ SYNOPSIS
 
 DESCRIPTION
        Provides default handling for relaxing for back ends which
-       don't do section gc -- i.e., does nothing besides the special
-       case for marking sections having global symbols.
+       don't do section gc -- i.e., does nothing.
 */
 
 bfd_boolean
 bfd_generic_gc_sections (bfd *abfd ATTRIBUTE_UNUSED,
-                        struct bfd_link_info *info)
+                        struct bfd_link_info *info ATTRIBUTE_UNUSED)
 {
-  /* If called when info->gc_sections is 0, then mark all sections
-     containing global symbols with SEC_KEEP.  */
-  if (!info->gc_sections && !info->relocatable)
-    bfd_link_hash_traverse (info->hash, bfd_mark_used_section, NULL);
   return TRUE;
 }
 
index f995fc508d8b09ddb94537cdc438d4cf6291ef69..78f4f68b355e52b82a07f47e57a82471385405e6 100644 (file)
@@ -1,3 +1,14 @@
+2005-07-14  Alan Modra  <amodra@bigpond.net.au>
+
+       * ldlang.c (strip_excluded_output_sections): Don't call
+       bfd_gc_sections.
+       * emultempl/elf32.em (gld*_provide_bound_symbols): Move.
+       (gld*_provide_init_fini_syms): Move.
+       (gld*_before_allocation): Call the above from here..
+       (gld*_finish): ..not here.  Call _bfd_elf_fix_excluded_sec_syms.
+       * emultempl/hppaelf.em (hppaelf_finish): Likewise.
+       * emultempl/ppc64elf.em (ppc_finish): Likewise.
+
 2005-07-10  Ralf Corsepius <ralf.corsepius@rtems.org>
 
        * configure.tgt: Remove sparc*-*-rtemsaout*, i[3-7]86-go32-rtems*,
index da7af0bf38935004c1db62a87858cd5835eb4efa..9480c2c6ab713ef0de9de8918c20773e922d722e 100644 (file)
@@ -61,7 +61,6 @@ static void gld${EMULATION_NAME}_before_allocation (void);
 static bfd_boolean gld${EMULATION_NAME}_place_orphan
   (lang_input_statement_type *file, asection *s);
 static void gld${EMULATION_NAME}_layout_sections_again (void);
-static void gld${EMULATION_NAME}_provide_init_fini_syms (void);
 static void gld${EMULATION_NAME}_finish (void) ATTRIBUTE_UNUSED;
 
 EOF
@@ -1040,6 +1039,47 @@ 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.  */
 
@@ -1057,6 +1097,8 @@ gld${EMULATION_NAME}_before_allocation (void)
      referred to by dynamic objects.  */
   lang_for_each_statement (gld${EMULATION_NAME}_find_statement_assignment);
 
+  gld${EMULATION_NAME}_provide_init_fini_syms ();
+
   /* Let the ELF backend work out the sizes of any sections required
      by dynamic linking.  */
   rpath = command_line.rpath;
@@ -1447,49 +1489,6 @@ fi
 if test x"$LDEMUL_FINISH" != xgld"$EMULATION_NAME"_finish; then
 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);
-  if (s && bfd_section_removed_from_list (output_bfd, s))
-    s = NULL;
-  _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");
-    }
-}
-
 static void
 gld${EMULATION_NAME}_layout_sections_again (void)
 {
@@ -1511,7 +1510,7 @@ gld${EMULATION_NAME}_finish (void)
   if (bfd_elf_discard_info (output_bfd, &link_info))
     gld${EMULATION_NAME}_layout_sections_again ();
 
-  gld${EMULATION_NAME}_provide_init_fini_syms ();
+  _bfd_elf_fix_excluded_sec_syms (output_bfd, &link_info);
 }
 EOF
 fi
index 96a98ed2b3bd7ff5278972e5999c3c016eeec14b..430327461675cb7647730ff97f297b547489356a 100644 (file)
@@ -305,7 +305,7 @@ hppaelf_finish (void)
        }
     }
 
-  gld${EMULATION_NAME}_provide_init_fini_syms ();
+  _bfd_elf_fix_excluded_sec_syms (output_bfd, &link_info);
 }
 
 
index 483d381252365de9afdd00bc6cdddcb6b5ece515..a9ced5fcbb71e823bcab4b064f9aa802b4c1f799 100644 (file)
@@ -379,7 +379,7 @@ ppc_finish (void)
     }
 
   ppc64_elf_restore_symbols (&link_info);
-  gld${EMULATION_NAME}_provide_init_fini_syms ();
+  _bfd_elf_fix_excluded_sec_syms (output_bfd, &link_info);
 }
 
 
index ce178f18408f72e6138cffe3c03b472419e8cf29..35c507525f1f90d90f8aedba4d055fb0ba983f6f 100644 (file)
@@ -3049,7 +3049,6 @@ void
 strip_excluded_output_sections (void)
 {
   lang_output_section_statement_type *os;
-  unsigned int gc_sections;
 
   /* Run lang_size_sections (if not already done) to ensure that all
      symbols defined in the linker script are put in the bfd hash
@@ -3062,13 +3061,6 @@ strip_excluded_output_sections (void)
       lang_reset_memory_regions ();
     }
 
-  /* Now call into bfd_gc_sections to mark all sections defining global
-     symbols with SEC_KEEP.  */
-  gc_sections = link_info.gc_sections;
-  link_info.gc_sections = 0;
-  bfd_gc_sections (output_bfd, &link_info);
-  link_info.gc_sections = gc_sections;
-
   for (os = &lang_output_section_statement.head->output_section_statement;
        os != NULL;
        os = os->next)
This page took 0.041809 seconds and 4 git commands to generate.