bfd/
authorAlan Modra <amodra@gmail.com>
Thu, 4 Aug 2005 01:19:10 +0000 (01:19 +0000)
committerAlan Modra <amodra@gmail.com>
Thu, 4 Aug 2005 01:19:10 +0000 (01:19 +0000)
* elflink.c (fix_syms, _bfd_elf_fix_excluded_sec_syms): Move to..
* linker.c (fix_syms, _bfd_fix_excluded_sec_syms): ..here.
* bfd-in.h (_bfd_fix_excluded_sec_syms): Rename.
* bfd-in2.h: Regenerate.
ld/
* ldemul.c (ldemul_finish): Call ld_emulation->finish unconditionally.
(finish_default): New function.
* ldemul.h (finish_default): Declare.
* emultempl/aix.em (gld*_before_allocation): Call
before_allocation_default rather than strip_excluded_output_sections.
(ld_*_emulation): Init finish field to finish_default.
* emultempl/armcoff.em: Likewise.
* emultempl/beos.em: Likewise.
* emultempl/elf32.em: Likewise.
* emultempl/generic.em: Likewise.
* emultempl/gld960.em: Likewise.
* emultempl/gld960c.em: Likewise.
* emultempl/hppaelf.em: Likewise.
* emultempl/linux.em: Likewise.
* emultempl/lnk960.em: Likewise.
* emultempl/m68kcoff.em: Likewise.
* emultempl/mmo.em: Likewise.
* emultempl/pe.em: Likewise.
* emultempl/ppc64elf.em: Likewise.
* emultempl/sunos.em: Likewise.
* emultempl/ticoff.em: Likewise.
* emultempl/vanilla.em: Likewise.

25 files changed:
bfd/ChangeLog
bfd/bfd-in.h
bfd/bfd-in2.h
bfd/elflink.c
bfd/linker.c
ld/ChangeLog
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/hppaelf.em
ld/emultempl/linux.em
ld/emultempl/lnk960.em
ld/emultempl/m68kcoff.em
ld/emultempl/mmo.em
ld/emultempl/pe.em
ld/emultempl/ppc64elf.em
ld/emultempl/sunos.em
ld/emultempl/ticoff.em
ld/emultempl/vanilla.em
ld/ldemul.c
ld/ldemul.h

index 1f82cdc14a5c28cf27324677f7400bd6ea09daef..98fb93690e6d30fe6d2f6fe79eefb9fd901d54c9 100644 (file)
@@ -1,3 +1,10 @@
+2005-08-04  Alan Modra  <amodra@bigpond.net.au>
+
+       * elflink.c (fix_syms, _bfd_elf_fix_excluded_sec_syms): Move to..
+       * linker.c (fix_syms, _bfd_fix_excluded_sec_syms): ..here.
+       * bfd-in.h (_bfd_fix_excluded_sec_syms): Rename.
+       * bfd-in2.h: Regenerate.
+
 2005-08-03  H.J. Lu  <hongjiu.lu@intel.com>
 
        * elfxx-ia64.c (elfNN_ia64_relax_section): Resize .rela.got
index 10b4c13b7f59b4ba598f2be407abacaf02d26444..39a82cbffc5e8ec8dd18daa45d35ab0a77d3f6a6 100644 (file)
@@ -708,7 +708,7 @@ extern void _bfd_elf_provide_symbol
 extern void _bfd_elf_provide_section_bound_symbols
   (struct bfd_link_info *, struct bfd_section *, const char *, const char *);
 
-extern void _bfd_elf_fix_excluded_sec_syms
+extern void _bfd_fix_excluded_sec_syms
   (bfd *, struct bfd_link_info *);
 
 extern bfd_boolean bfd_m68k_elf32_create_embedded_relocs
index e8c597266e8358e89b61462d25dbe4b9f65ba2ad..50ac26328620e9d9c65e0df0e2a552a9baa6732c 100644 (file)
@@ -715,7 +715,7 @@ extern void _bfd_elf_provide_symbol
 extern void _bfd_elf_provide_section_bound_symbols
   (struct bfd_link_info *, struct bfd_section *, const char *, const char *);
 
-extern void _bfd_elf_fix_excluded_sec_syms
+extern void _bfd_fix_excluded_sec_syms
   (bfd *, struct bfd_link_info *);
 
 extern bfd_boolean bfd_m68k_elf32_create_embedded_relocs
index 082b5303021ba472c187b5b7768e6cbce332cbac..457ba8e6213209f8480ae8d628d6cd9484e406a8 100644 (file)
@@ -9890,39 +9890,6 @@ _bfd_elf_provide_section_bound_symbols (struct bfd_link_info *info,
   _bfd_elf_provide_symbol (info, end, val, sec);
 }
 
-/* Convert symbols in excluded output sections to absolute.  */
-
-static bfd_boolean
-fix_syms (struct bfd_link_hash_entry *h, void *data)
-{
-  bfd *obfd = (bfd *) data;
-
-  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_EXCLUDE) != 0
-         && bfd_section_removed_from_list (obfd, s->output_section))
-       {
-         h->u.def.value += s->output_offset + s->output_section->vma;
-         h->u.def.section = bfd_abs_section_ptr;
-       }
-    }
-
-  return TRUE;
-}
-
-void
-_bfd_elf_fix_excluded_sec_syms (bfd *obfd, struct bfd_link_info *info)
-{
-  bfd_link_hash_traverse (info->hash, fix_syms, obfd);
-}
-
 bfd_boolean
 _bfd_elf_common_definition (Elf_Internal_Sym *sym)
 {
index 426d545e32ce4e9e1a8ac1aa792490b11e8f86c2..0bfdfb23706c530ee985490928d4a2ce242ae0b9 100644 (file)
@@ -3071,3 +3071,36 @@ _bfd_generic_section_already_linked (bfd *abfd, asection *sec)
   /* This is the first section with this name.  Record it.  */
   bfd_section_already_linked_table_insert (already_linked_list, sec);
 }
+
+/* Convert symbols in excluded output sections to absolute.  */
+
+static bfd_boolean
+fix_syms (struct bfd_link_hash_entry *h, void *data)
+{
+  bfd *obfd = (bfd *) data;
+
+  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_EXCLUDE) != 0
+         && bfd_section_removed_from_list (obfd, s->output_section))
+       {
+         h->u.def.value += s->output_offset + s->output_section->vma;
+         h->u.def.section = bfd_abs_section_ptr;
+       }
+    }
+
+  return TRUE;
+}
+
+void
+_bfd_fix_excluded_sec_syms (bfd *obfd, struct bfd_link_info *info)
+{
+  bfd_link_hash_traverse (info->hash, fix_syms, obfd);
+}
index 14f2bf4ddea395a7a2f907d5201132453670ca15..b21834ec1eadfe5c5babcb2c1f36aac9e0b7f8a5 100644 (file)
@@ -1,3 +1,28 @@
+2005-08-04  Alan Modra  <amodra@bigpond.net.au>
+
+       * ldemul.c (ldemul_finish): Call ld_emulation->finish unconditionally.
+       (finish_default): New function.
+       * ldemul.h (finish_default): Declare.
+       * emultempl/aix.em (gld*_before_allocation): Call
+       before_allocation_default rather than strip_excluded_output_sections.
+       (ld_*_emulation): Init finish field to finish_default.
+       * emultempl/armcoff.em: Likewise.
+       * emultempl/beos.em: Likewise.
+       * emultempl/elf32.em: Likewise.
+       * emultempl/generic.em: Likewise.
+       * emultempl/gld960.em: Likewise.
+       * emultempl/gld960c.em: Likewise.
+       * emultempl/hppaelf.em: Likewise.
+       * emultempl/linux.em: Likewise.
+       * emultempl/lnk960.em: Likewise.
+       * emultempl/m68kcoff.em: Likewise.
+       * emultempl/mmo.em: Likewise.
+       * emultempl/pe.em: Likewise.
+       * emultempl/ppc64elf.em: Likewise.
+       * emultempl/sunos.em: Likewise.
+       * emultempl/ticoff.em: Likewise.
+       * emultempl/vanilla.em: Likewise.
+
 2005-08-03  Alan Modra  <amodra@bigpond.net.au>
 
        * ldlang.c (exp_init_os): Handle etree_provide.
index 8030b477c06646b190ff519ee4503ce17a1ab60c..8763155b7e2533fa7f9bb9e1c61bf5a3e17a29b1 100644 (file)
@@ -788,8 +788,7 @@ gld${EMULATION_NAME}_before_allocation (void)
        }
     }
 
-  if (!link_info.relocatable)
-    strip_excluded_output_sections ();
+  before_allocation_default ();
 }
 
 static char *
@@ -1344,7 +1343,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = {
   gld${EMULATION_NAME}_get_script,
   "${EMULATION_NAME}",
   "${OUTPUT_FORMAT}",
-  0,                           /* finish */
+  finish_default,
   gld${EMULATION_NAME}_create_output_section_statements,
   0,                           /* open_dynamic_archive */
   0,                           /* place_orphan */
index 64a2b32d8220755d29f9ed91da7d952b098b36f8..acf117cb414adeaa720af83d977b70560e66f3ba 100644 (file)
@@ -126,8 +126,7 @@ gld${EMULATION_NAME}_before_allocation (void)
   /* We have seen it all. Allocate it, and carry on */
   bfd_arm_allocate_interworking_sections (& link_info);
 
-  if (!link_info.relocatable)
-    strip_excluded_output_sections ();
+  before_allocation_default ();
 }
 
 static void
@@ -194,6 +193,8 @@ gld${EMULATION_NAME}_finish (void)
     }
   else
     einfo (_("%P: warning: connot find thumb start symbol %s\n"), thumb_entry_symbol);
+
+  finish_default ();
 }
 
 static char *
index 7a014ce210c9b51d53b7b7c86b6b19c78bef1f40..e07677b314240c672d5852d948a2c4e0abea87c3 100644 (file)
@@ -647,8 +647,7 @@ gld_${EMULATION_NAME}_before_allocation (void)
 
   sort_sections (stat_ptr->head);
 
-  if (!link_info.relocatable)
-    strip_excluded_output_sections ();
+  before_allocation_default ();
 }
 \f
 /* Place an orphan section.  We use this to put sections with a '\$' in them
@@ -771,7 +770,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
   gld_${EMULATION_NAME}_get_script,
   "${EMULATION_NAME}",
   "${OUTPUT_FORMAT}",
-  NULL, /* finish */
+  finish_default,
   NULL, /* create output section statements */
   NULL, /* open dynamic archive */
   gld${EMULATION_NAME}_place_orphan,
index b04d624adea2e6fb80a42297264bf9ca92b9bc97..e43c8c5a8305bda13b3958c486ece65e1a46204c 100644 (file)
@@ -1169,8 +1169,7 @@ ${ELF_INTERPRETER_SET_DEFAULT}
       }
   }
 
-  if (!link_info.relocatable)
-    strip_excluded_output_sections ();
+  before_allocation_default ();
 
   if (!bfd_elf_size_dynsym_hash_dynstr (output_bfd, &link_info))
     einfo ("%P%F: failed to set dynamic section sizes: %E\n");
@@ -1511,7 +1510,7 @@ gld${EMULATION_NAME}_finish (void)
   if (bfd_elf_discard_info (output_bfd, &link_info))
     gld${EMULATION_NAME}_layout_sections_again ();
 
-  _bfd_elf_fix_excluded_sec_syms (output_bfd, &link_info);
+  finish_default ();
 }
 EOF
 fi
index a37bdc6cb1dc03061bed2acd7039244390ef0e7a..f7153b682e9994b6b2cc76f2a6ae714798d2ac53 100644 (file)
@@ -132,7 +132,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
   ${LDEMUL_GET_SCRIPT-gld${EMULATION_NAME}_get_script},
   "${EMULATION_NAME}",
   "${OUTPUT_FORMAT}",
-  ${LDEMUL_FINISH-NULL},
+  ${LDEMUL_FINISH-finish_default},
   ${LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS-NULL},
   ${LDEMUL_OPEN_DYNAMIC_ARCHIVE-NULL},
   ${LDEMUL_PLACE_ORPHAN-NULL},
index acacac762adb8e20d869d08154cfb11b4d2e06bd..f4076223aed202e6f17b32b9b4a7c55b5afbc958 100644 (file)
@@ -138,7 +138,7 @@ struct ld_emulation_xfer_struct ld_gld960_emulation =
   gld960_get_script,
   "960",
   "",
-  NULL,        /* finish */
+  finish_default,
   NULL,        /* create output section statements */
   NULL,        /* open dynamic archive */
   NULL,        /* place orphan */
index 452c194b456e6be13d79e1c3ae3f6cfd3ba8941c..5de01e64311e3ceb9c906547fbb107a78b1bae41 100644 (file)
@@ -153,7 +153,7 @@ struct ld_emulation_xfer_struct ld_gld960coff_emulation =
   gld960_get_script,
   "960coff",
   "",
-  NULL,        /* finish */
+  finish_default,
   NULL,        /* create output section statements */
   NULL,        /* open dynamic archive */
   NULL,        /* place orphan */
index 430327461675cb7647730ff97f297b547489356a..fc81e769186e9463ffb3dfb0783ffca4949fec55 100644 (file)
@@ -305,7 +305,7 @@ hppaelf_finish (void)
        }
     }
 
-  _bfd_elf_fix_excluded_sec_syms (output_bfd, &link_info);
+  finish_default ();
 }
 
 
index 277d1e950bb17e55474022dbd9242eb574b5383b..071af80cec292c58b824678480c016437813e9b5 100644 (file)
@@ -122,7 +122,7 @@ gld${EMULATION_NAME}_before_allocation (void)
   if (! bfd_${EMULATION_NAME}_size_dynamic_sections (output_bfd, &link_info))
     einfo ("%P%F: failed to set dynamic section sizes: %E\n");
 
-  strip_excluded_output_sections ();
+  before_allocation_default ();
 }
 
 static char *
@@ -193,7 +193,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
   gld${EMULATION_NAME}_get_script,
   "${EMULATION_NAME}",
   "${OUTPUT_FORMAT}",
-  NULL,        /* finish */
+  finish_default,
   gld${EMULATION_NAME}_create_output_section_statements,
   gld${EMULATION_NAME}_open_dynamic_archive,
   NULL,        /* place orphan */
index 1c820655cf5419d7706b17f7d5ee0c1fec8768bb..14839835d4999d9b47abf259a7f3835a4b82a3f4 100644 (file)
@@ -273,7 +273,7 @@ struct ld_emulation_xfer_struct ld_lnk960_emulation =
   lnk960_get_script,
   "lnk960",
   "",
-  NULL,        /* finish */
+  finish_default,
   NULL,        /* create output section statements */
   NULL,        /* open dynamic archive */
   NULL,        /* place orphan */
index 9b011d3eac3ca4545833790907a7a0f215fb4ad7..31f98a04652736f903f1f583f8d8e5b60db6dcc5 100644 (file)
@@ -226,7 +226,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
   gld${EMULATION_NAME}_get_script,
   "${EMULATION_NAME}",
   "${OUTPUT_FORMAT}",
-  NULL,        /* finish */
+  finish_default,
   NULL,        /* create output section statements */
   NULL,        /* open dynamic archive */
   NULL,        /* place orphan */
index a737b506ea8b40778048b84fcda52923376fd0a5..bfc9c5a50d060c37667af1cd5257e6328d23a47f 100644 (file)
@@ -112,6 +112,7 @@ static void
 mmo_finish (void)
 {
   bfd_map_over_sections (output_bfd, mmo_wipe_sec_reloc_flag, NULL);
+  finish_default ();
 }
 \f
 /* To get on-demand global register allocation right, we need to parse the
index aefe3aad60c48ec2e8812c3760fd8a2e6fd0d185..6e143304942a573cfe55bde7e8088c5eadde27d4 100644 (file)
@@ -1288,8 +1288,7 @@ gld_${EMULATION_NAME}_before_allocation (void)
   bfd_arm_pe_allocate_interworking_sections (& link_info);
 #endif /* TARGET_IS_armpe */
 
-  if (!link_info.relocatable)
-    strip_excluded_output_sections ();
+  before_allocation_default ();
 }
 \f
 #ifdef DLL_SUPPORT
@@ -1464,6 +1463,8 @@ gld_${EMULATION_NAME}_finish (void)
     }
 #endif /* defined(TARGET_IS_armpe) || defined(TARGET_IS_arm_epoc_pe) */
 
+  finish_default ();
+
 #ifdef DLL_SUPPORT
   if (link_info.shared
 #if !defined(TARGET_IS_shpe) && !defined(TARGET_IS_mipspe)
index a9ced5fcbb71e823bcab4b064f9aa802b4c1f799..f64a3d2c2ed20e01e943011b60af060d032d99eb 100644 (file)
@@ -379,7 +379,7 @@ ppc_finish (void)
     }
 
   ppc64_elf_restore_symbols (&link_info);
-  _bfd_elf_fix_excluded_sec_syms (output_bfd, &link_info);
+  finish_default ();
 }
 
 
index b114737167ac95253609a6a73f146427a772965b..19f18931c8849390c5d28c972c435196f559df92 100644 (file)
@@ -809,9 +809,9 @@ gld${EMULATION_NAME}_before_allocation (void)
        hdyn->u.def.section = sdyn;
       else
        hdyn->u.def.section = bfd_abs_section_ptr;
-
-      strip_excluded_output_sections ();
     }
+
+  before_allocation_default ();
 }
 
 /* This is called by the before_allocation routine via
@@ -1017,7 +1017,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
   gld${EMULATION_NAME}_get_script,
   "${EMULATION_NAME}",
   "${OUTPUT_FORMAT}",
-  NULL,        /* finish */
+  finish_default,
   gld${EMULATION_NAME}_create_output_section_statements,
   NULL,        /* open dynamic archive */
   NULL,        /* place orphan */
index 9c4ec2b052753c8006830c060ae1287723148c01..5938ba421e07755bb582f1c98a831a5658df07ba 100644 (file)
@@ -166,7 +166,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
   gld_${EMULATION_NAME}_get_script,
   "${EMULATION_NAME}",
   "${OUTPUT_FORMAT}",
-  NULL, /* finish */
+  finish_default,
   NULL, /* create output section statements */
   NULL, /* open dynamic archive */
   NULL, /* place orphan */
index 769fb30f8e58f073717922e7c85edf2e09ec97da..ad11f41ddbbe487a155993232f854306845a7764 100644 (file)
@@ -69,7 +69,7 @@ struct ld_emulation_xfer_struct ld_vanilla_emulation =
   vanilla_get_script,
   "vanilla",
   "a.out-sunos-big",
-  NULL,        /* finish */
+  finish_default,
   NULL,        /* create output section statements */
   NULL,        /* open dynamic archive */
   NULL,        /* place orphan */
index fbe3e1dd565c0c6f9ca2f542072e5cea7eb2adb5..5b4796a2d97254e564dd89871be40a6e24b82940 100644 (file)
@@ -94,8 +94,7 @@ ldemul_set_output_arch (void)
 void
 ldemul_finish (void)
 {
-  if (ld_emulation->finish)
-    ld_emulation->finish ();
+  ld_emulation->finish ();
 }
 
 void
@@ -227,6 +226,13 @@ do_assignments_default (void)
 {
 }
 
+void
+finish_default (void)
+{
+  if (!link_info.relocatable)
+    _bfd_fix_excluded_sec_syms (output_bfd, &link_info);
+}
+
 void
 set_output_arch_default (void)
 {
index 1a42cb63dea157ab5ada2013b272379ad333fbc3..c3ba033ecb241afc6114bdf5eab34bf86fd56acd 100644 (file)
@@ -81,6 +81,8 @@ extern void before_allocation_default
   (void);
 extern void do_assignments_default
   (void);
+extern void finish_default
+  (void);
 extern void set_output_arch_default
   (void);
 extern void syslib_default