This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

fix_excluded_sec_syms for non-ELF


There's nothing ELF specific in _bfd_elf_fix_excluded_sec_syms, and
we ought to use it whenever we call strip_excluded_output_sections.
This fixes some non-ELF ld testsuite failures.

bfd/
	* 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.


Index: bfd/bfd-in.h
===================================================================
RCS file: /cvs/src/src/bfd/bfd-in.h,v
retrieving revision 1.107
diff -u -p -r1.107 bfd-in.h
--- bfd/bfd-in.h	29 Jul 2005 02:46:02 -0000	1.107
+++ bfd/bfd-in.h	4 Aug 2005 00:32:03 -0000
@@ -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: bfd/elflink.c
===================================================================
RCS file: /cvs/src/src/bfd/elflink.c,v
retrieving revision 1.185
diff -u -p -r1.185 elflink.c
--- bfd/elflink.c	31 Jul 2005 06:14:15 -0000	1.185
+++ bfd/elflink.c	4 Aug 2005 00:32:12 -0000
@@ -9890,39 +9890,6 @@ _bfd_elf_provide_section_bound_symbols (
   _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: bfd/linker.c
===================================================================
RCS file: /cvs/src/src/bfd/linker.c,v
retrieving revision 1.49
diff -u -p -r1.49 linker.c
--- bfd/linker.c	4 May 2005 15:53:35 -0000	1.49
+++ bfd/linker.c	4 Aug 2005 00:32:14 -0000
@@ -3071,3 +3071,36 @@ _bfd_generic_section_already_linked (bfd
   /* 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: ld/ldemul.c
===================================================================
RCS file: /cvs/src/src/ld/ldemul.c,v
retrieving revision 1.21
diff -u -p -r1.21 ldemul.c
--- ld/ldemul.c	15 Jul 2005 12:19:14 -0000	1.21
+++ ld/ldemul.c	4 Aug 2005 00:32:27 -0000
@@ -94,8 +94,7 @@ ldemul_set_output_arch (void)
 void
 ldemul_finish (void)
 {
-  if (ld_emulation->finish)
-    ld_emulation->finish ();
+  ld_emulation->finish ();
 }
 
 void
@@ -228,6 +227,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)
 {
   /* Set the output architecture and machine if possible.  */
Index: ld/ldemul.h
===================================================================
RCS file: /cvs/src/src/ld/ldemul.h,v
retrieving revision 1.15
diff -u -p -r1.15 ldemul.h
--- ld/ldemul.h	15 Jul 2005 12:19:14 -0000	1.15
+++ ld/ldemul.h	4 Aug 2005 00:32:27 -0000
@@ -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
Index: ld/emultempl/aix.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/aix.em,v
retrieving revision 1.39
diff -u -p -r1.39 aix.em
--- ld/emultempl/aix.em	15 Jul 2005 12:19:14 -0000	1.39
+++ ld/emultempl/aix.em	4 Aug 2005 00:32:28 -0000
@@ -788,8 +788,7 @@ gld${EMULATION_NAME}_before_allocation (
 	}
     }
 
-  if (!link_info.relocatable)
-    strip_excluded_output_sections ();
+  before_allocation_default ();
 }
 
 static char *
@@ -1344,7 +1343,7 @@ struct ld_emulation_xfer_struct ld_${EMU
   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: ld/emultempl/armcoff.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/armcoff.em,v
retrieving revision 1.21
diff -u -p -r1.21 armcoff.em
--- ld/emultempl/armcoff.em	15 Jul 2005 12:19:14 -0000	1.21
+++ ld/emultempl/armcoff.em	4 Aug 2005 00:32:28 -0000
@@ -126,8 +126,7 @@ gld${EMULATION_NAME}_before_allocation (
   /* 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: ld/emultempl/beos.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/beos.em,v
retrieving revision 1.31
diff -u -p -r1.31 beos.em
--- ld/emultempl/beos.em	15 Jul 2005 12:19:14 -0000	1.31
+++ ld/emultempl/beos.em	4 Aug 2005 00:32:29 -0000
@@ -647,8 +647,7 @@ gld_${EMULATION_NAME}_before_allocation 
 
   sort_sections (stat_ptr->head);
 
-  if (!link_info.relocatable)
-    strip_excluded_output_sections ();
+  before_allocation_default ();
 }
 
 /* Place an orphan section.  We use this to put sections with a '\$' in them
@@ -771,7 +770,7 @@ struct ld_emulation_xfer_struct ld_${EMU
   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: ld/emultempl/elf32.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/elf32.em,v
retrieving revision 1.153
diff -u -p -r1.153 elf32.em
--- ld/emultempl/elf32.em	16 Jul 2005 03:30:24 -0000	1.153
+++ ld/emultempl/elf32.em	4 Aug 2005 00:32:29 -0000
@@ -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: ld/emultempl/generic.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/generic.em,v
retrieving revision 1.17
diff -u -p -r1.17 generic.em
--- ld/emultempl/generic.em	15 Jul 2005 12:19:14 -0000	1.17
+++ ld/emultempl/generic.em	4 Aug 2005 00:32:30 -0000
@@ -132,7 +132,7 @@ struct ld_emulation_xfer_struct ld_${EMU
   ${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: ld/emultempl/gld960.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/gld960.em,v
retrieving revision 1.17
diff -u -p -r1.17 gld960.em
--- ld/emultempl/gld960.em	15 Jul 2005 12:19:14 -0000	1.17
+++ ld/emultempl/gld960.em	4 Aug 2005 00:32:30 -0000
@@ -138,7 +138,7 @@ struct ld_emulation_xfer_struct ld_gld96
   gld960_get_script,
   "960",
   "",
-  NULL,	/* finish */
+  finish_default,
   NULL,	/* create output section statements */
   NULL,	/* open dynamic archive */
   NULL,	/* place orphan */
Index: ld/emultempl/gld960c.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/gld960c.em,v
retrieving revision 1.19
diff -u -p -r1.19 gld960c.em
--- ld/emultempl/gld960c.em	15 Jul 2005 12:19:14 -0000	1.19
+++ ld/emultempl/gld960c.em	4 Aug 2005 00:32:30 -0000
@@ -153,7 +153,7 @@ struct ld_emulation_xfer_struct ld_gld96
   gld960_get_script,
   "960coff",
   "",
-  NULL,	/* finish */
+  finish_default,
   NULL,	/* create output section statements */
   NULL,	/* open dynamic archive */
   NULL,	/* place orphan */
Index: ld/emultempl/hppaelf.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/hppaelf.em,v
retrieving revision 1.43
diff -u -p -r1.43 hppaelf.em
--- ld/emultempl/hppaelf.em	14 Jul 2005 13:54:23 -0000	1.43
+++ ld/emultempl/hppaelf.em	4 Aug 2005 00:32:30 -0000
@@ -305,7 +305,7 @@ hppaelf_finish (void)
 	}
     }
 
-  _bfd_elf_fix_excluded_sec_syms (output_bfd, &link_info);
+  finish_default ();
 }
 
 
Index: ld/emultempl/linux.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/linux.em,v
retrieving revision 1.18
diff -u -p -r1.18 linux.em
--- ld/emultempl/linux.em	15 Jul 2005 12:19:14 -0000	1.18
+++ ld/emultempl/linux.em	4 Aug 2005 00:32:30 -0000
@@ -122,7 +122,7 @@ gld${EMULATION_NAME}_before_allocation (
   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_${EMU
   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: ld/emultempl/lnk960.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/lnk960.em,v
retrieving revision 1.18
diff -u -p -r1.18 lnk960.em
--- ld/emultempl/lnk960.em	15 Jul 2005 12:19:14 -0000	1.18
+++ ld/emultempl/lnk960.em	4 Aug 2005 00:32:30 -0000
@@ -273,7 +273,7 @@ struct ld_emulation_xfer_struct ld_lnk96
   lnk960_get_script,
   "lnk960",
   "",
-  NULL,	/* finish */
+  finish_default,
   NULL,	/* create output section statements */
   NULL,	/* open dynamic archive */
   NULL,	/* place orphan */
Index: ld/emultempl/m68kcoff.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/m68kcoff.em,v
retrieving revision 1.14
diff -u -p -r1.14 m68kcoff.em
--- ld/emultempl/m68kcoff.em	15 Jul 2005 12:19:14 -0000	1.14
+++ ld/emultempl/m68kcoff.em	4 Aug 2005 00:32:30 -0000
@@ -226,7 +226,7 @@ struct ld_emulation_xfer_struct ld_${EMU
   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: ld/emultempl/mmo.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/mmo.em,v
retrieving revision 1.15
diff -u -p -r1.15 mmo.em
--- ld/emultempl/mmo.em	12 May 2005 07:32:03 -0000	1.15
+++ ld/emultempl/mmo.em	4 Aug 2005 00:32:30 -0000
@@ -112,6 +112,7 @@ static void
 mmo_finish (void)
 {
   bfd_map_over_sections (output_bfd, mmo_wipe_sec_reloc_flag, NULL);
+  finish_default ();
 }
 
 /* To get on-demand global register allocation right, we need to parse the
Index: ld/emultempl/pe.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/pe.em,v
retrieving revision 1.108
diff -u -p -r1.108 pe.em
--- ld/emultempl/pe.em	15 Jul 2005 12:19:14 -0000	1.108
+++ ld/emultempl/pe.em	4 Aug 2005 00:32:31 -0000
@@ -1288,8 +1288,7 @@ gld_${EMULATION_NAME}_before_allocation 
   bfd_arm_pe_allocate_interworking_sections (& link_info);
 #endif /* TARGET_IS_armpe */
 
-  if (!link_info.relocatable)
-    strip_excluded_output_sections ();
+  before_allocation_default ();
 }
 
 #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: ld/emultempl/ppc64elf.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/ppc64elf.em,v
retrieving revision 1.47
diff -u -p -r1.47 ppc64elf.em
--- ld/emultempl/ppc64elf.em	14 Jul 2005 13:54:23 -0000	1.47
+++ ld/emultempl/ppc64elf.em	4 Aug 2005 00:32:31 -0000
@@ -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: ld/emultempl/sunos.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/sunos.em,v
retrieving revision 1.23
diff -u -p -r1.23 sunos.em
--- ld/emultempl/sunos.em	15 Jul 2005 12:19:14 -0000	1.23
+++ ld/emultempl/sunos.em	4 Aug 2005 00:32:32 -0000
@@ -809,9 +809,9 @@ gld${EMULATION_NAME}_before_allocation (
 	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_${EMU
   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: ld/emultempl/ticoff.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/ticoff.em,v
retrieving revision 1.14
diff -u -p -r1.14 ticoff.em
--- ld/emultempl/ticoff.em	15 Jul 2005 12:19:15 -0000	1.14
+++ ld/emultempl/ticoff.em	4 Aug 2005 00:32:33 -0000
@@ -166,7 +166,7 @@ struct ld_emulation_xfer_struct ld_${EMU
   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: ld/emultempl/vanilla.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/vanilla.em,v
retrieving revision 1.11
diff -u -p -r1.11 vanilla.em
--- ld/emultempl/vanilla.em	15 Jul 2005 12:19:15 -0000	1.11
+++ ld/emultempl/vanilla.em	4 Aug 2005 00:32:33 -0000
@@ -69,7 +69,7 @@ struct ld_emulation_xfer_struct ld_vanil
   vanilla_get_script,
   "vanilla",
   "a.out-sunos-big",
-  NULL,	/* finish */
+  finish_default,
   NULL,	/* create output section statements */
   NULL,	/* open dynamic archive */
   NULL,	/* place orphan */

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]