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]

[PATCH] Revise long section names coff extension handling for PE targets.


    Hi all,

  This patch fixes the issues previously raised[*] about the use of the long
section names extension that the PE format adds to COFF.

  Use of long section names is now a run-time rather than compile-time
decision, for those formats that support them. Long section names are always
accepted in input BFDs, but only generated in output BFDs under control of a
flag, which 'ld' can now set or clear via a target backend hook at runtime.
The behaviour of all PE executable image targets is changed to no longer
generate long section names by default.

  Tested on i686-pc-cygwin x {native, i686-pc-mingw32, x86_64-pc-mingw32}, and
on i686-pc-linux-gnu x {native --enable-targets=all, i686-pc-cygwin} so far,
with no regressions.  However, on x86_64, three of the new tests fail.  This
is due to what appears to be a discrepancy between the behaviours of the
32-bit PE and 64-bit PE+ emulations, which I will follow up in a separate
thread and then post a patch to either adjust the testcases or remove the
discrepancy, when it is clearer at which end the problem lies.

  I'll try a few more COFF cross-targets overnight, and, assuming still no
regressions, OK to install?

bfd/ChangeLog

	* coff-alpha.c (alpha_ecoff_backend_data):  Initialise fields which
	control long section name handling with ECOFF_NO_LONG_SECTION_NAMES.
	* coff-mips.c (mips_ecoff_backend_data):  Likewise.
	* coff-rs6000.c (bfd_xcoff_backend_data):  Initialise fields which
	control long section name handling with XCOFF_NO_LONG_SECTION_NAMES.
	(bfd_pmac_xcoff_backend_data):  Likewise.
	* coff64-rs6000.c (bfd_xcoff_backend_data):  Likewise.
	(bfd_xcoff_aix5_backend_data):  Likewise.
	(xcoff64_write_object_contents):  Delete unused long_section_names
	local variable.
	* coff-sh.c (bfd_coff_small_swap_table):  Initialise long section
	name members using COFF_DEFAULT_LONG_SECTION_NAMES and make entire
	struct non-const.
	* coffcode.h (documentation):  Update to describe long section names.
	(COFFLONGSECTIONCATHELPER):  New helper macro.
	(BLANKOR1TOODD):  Likewise.
	(COFF_ENABLE_LONG_SECTION_NAMES):  Likewise.
	(COFF_LONG_SECTION_NAMES_SETTER):  Likewise.
	(COFF_DEFAULT_LONG_SECTION_NAMES):  Likewise.
	(bfd_coff_set_long_section_names_allowed):  New function.
	(bfd_coff_set_long_section_names_disallowed):  Likewise.
	(struct bfd_coff_backend_data):  Add new backend hook function
	pointer _bfd_coff_set_long_section_names.
	(bfd_coff_set_long_section_names):  New backend hook.
	(coff_write_object_contents):  Only generate long section names if
	bfd_coff_long_section_names() indicates they are currently enabled.
	(bfd_coff_std_swap_table):  Make non-const, and initialise long
	section name fields using COFF_DEFAULT_LONG_SECTION_NAMES.
	(ticoff0_swap_table):  Likewise to both.
	(ticoff1_swap_table):  Again, likewise to both.
	* coffgen.c (make_a_section_from_file):  Allow long section names
	as inputs even if not currently allowed for outputs.
	* ecoff.c (_bfd_ecoff_no_long_sections):  New function.
	* efi-app-ia32.c (COFF_LONG_SECTION_NAMES):  Define to 0, not blank.
	* efi-app-ia64.c (COFF_LONG_SECTION_NAMES):  Likewise.
	* efi-app-x86_64.c (COFF_LONG_SECTION_NAMES):  Likewise.
	* efi-bsdrv-ia32.c (COFF_LONG_SECTION_NAMES):  Likewise.
	* efi-bsdrv-ia64.c (COFF_LONG_SECTION_NAMES):  Likewise.
	* efi-bsdrv-x86_64.c (COFF_LONG_SECTION_NAMES):  Likewise.
	* efi-rtdrv-ia32.c (COFF_LONG_SECTION_NAMES):  Likewise.
	* efi-rtdrv-ia64.c (COFF_LONG_SECTION_NAMES):  Likewise.
	* efi-rtdrv-x86_64.c (COFF_LONG_SECTION_NAMES):  Likewise.
	* pei-arm.c (COFF_LONG_SECTION_NAMES):  Likewise.
	* pei-i386.c (COFF_LONG_SECTION_NAMES):  Likewise.
	* pei-mcore.c (COFF_LONG_SECTION_NAMES):  Likewise.
	* pei-mips.c (COFF_LONG_SECTION_NAMES):  Likewise.
	* pei-ppc.c (COFF_LONG_SECTION_NAMES):  Likewise.
	* pei-sh.c (COFF_LONG_SECTION_NAMES):  Likewise.
	* pei-x86_64.c (COFF_LONG_SECTION_NAMES):  Likewise.
	* libcoff-in.h:  Update copyright year to cause updated copyright
	year in generated libcoff.h, and fix typo.
	* libcoff.h:  Regenerated.
	* libecoff.h (ECOFF_NO_LONG_SECTION_NAMES):  New macro.
	(_bfd_ecoff_no_long_sections):  Add prototype.
	* libxcoff.h (XCOFF_NO_LONG_SECTION_NAMES):  New macro.
	* pe-mips.c (COFF_LONG_SECTION_NAMES):  Define to 0 if not already
	defined by an including .c file.
	* ticoff.h (ticoff0_swap_table):  Make non-const, and initialise
	long section name fields using COFF_DEFAULT_LONG_SECTION_NAMES.
	(ticoff1_swap_table):  Likewise to both.

ld/ChangeLog

	* ld.texinfo:  Update to mention long section name options.
	* NEWS:  Mention new behaviour and command-line options.
	* pe-dll.c (pe_use_coff_long_section_names):  New global variable.
	(pe_output_file_set_long_section_names):  New function.
	(pe_dll_build_sections):  Call it on output BFDs.
	(pe_exe_build_sections):  Likewise.
	(pe_dll_fill_sections):  Likewise.
	(pe_exe_fill_sections):  Likewise.
	* pe-dll.h (pe_use_coff_long_section_names):  Declare extern.
	* pep-dll.c (pe_use_coff_long_section_names):  Define pep_ alias.
	* pep-dll.h (pep_use_coff_long_section_names):  Declare extern.
	* pe.em (OPTION_ENABLE_LONG_SECTION_NAMES):  New getopt value macro.
	(OPTION_DISABLE_LONG_SECTION_NAMES):  Likewise.
	(gld${EMULATION_NAME}_add_options):  Add new options to xtra_long[].
	(gld_${EMULATION_NAME}_list_options):  Describe them.
	(gld${EMULATION_NAME}_handle_option):  Set or clear global
	pe_use_coff_long_section_names flag when options recognised.
	* pep.em (enum options):  Extend enum with new getopt option values.
	(gld${EMULATION_NAME}_add_options):  Add new options to xtra_long[].
	(gld_${EMULATION_NAME}_list_options):  Describe them.
	(gld${EMULATION_NAME}_handle_option):  Set or clear global
	pe_use_coff_long_section_names flag when options recognised.

ld/testsuite/ChangeLog

	* ld-pe/longsecn-1.d:  New test file.
	* ld-pe/longsecn-2.d:  Likewise.
	* ld-pe/longsecn-3.d:  Likewise.
	* ld-pe/longsecn-4.d:  Likewise.
	* ld-pe/longsecn-5.d:  Likewise.
	* ld-pe/longsecn.d:  Likewise.
	* ld-pe/longsecn.exp:  New test control script.
	* ld-pe/longsecn.s:  New test source file.

    cheers,
      DaveK

-- 
[*] - http://gcc.gnu.org/ml/gcc/2009-02/threads.html#00026, continued at
http://sourceware.org/ml/binutils/2009-02/threads.html#00010

Index: bfd/coff-alpha.c
===================================================================
RCS file: /cvs/src/src/bfd/coff-alpha.c,v
retrieving revision 1.38
diff -p -u -r1.38 coff-alpha.c
--- bfd/coff-alpha.c	18 Jul 2008 11:30:22 -0000	1.38
+++ bfd/coff-alpha.c	12 Feb 2009 22:13:10 -0000
@@ -1,6 +1,6 @@
 /* BFD back-end for ALPHA Extended-Coff files.
    Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-   2003, 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
+   2003, 2004, 2005, 2007, 2008, 2009 Free Software Foundation, Inc.
    Modified from coff-mips.c by Steve Chamberlain <sac@cygnus.com> and
    Ian Lance Taylor <ian@cygnus.com>.
 
@@ -2297,7 +2297,8 @@ static const struct ecoff_backend_data a
     (unsigned (*) PARAMS ((bfd *,PTR,PTR))) bfd_void, /* reloc_out */
     alpha_ecoff_swap_filehdr_out, alpha_ecoff_swap_aouthdr_out,
     alpha_ecoff_swap_scnhdr_out,
-    FILHSZ, AOUTSZ, SCNHSZ, 0, 0, 0, 0, FILNMLEN, TRUE, FALSE, 4, FALSE, 2,
+    FILHSZ, AOUTSZ, SCNHSZ, 0, 0, 0, 0, FILNMLEN, TRUE, 
+    ECOFF_NO_LONG_SECTION_NAMES, 4, FALSE, 2,
     alpha_ecoff_swap_filehdr_in, alpha_ecoff_swap_aouthdr_in,
     alpha_ecoff_swap_scnhdr_in, NULL,
     alpha_ecoff_bad_format_hook, _bfd_ecoff_set_arch_mach_hook,
Index: bfd/coff-mips.c
===================================================================
RCS file: /cvs/src/src/bfd/coff-mips.c,v
retrieving revision 1.35
diff -p -u -r1.35 coff-mips.c
--- bfd/coff-mips.c	18 Jul 2008 11:30:22 -0000	1.35
+++ bfd/coff-mips.c	12 Feb 2009 22:13:10 -0000
@@ -1,6 +1,6 @@
 /* BFD back-end for MIPS Extended-Coff files.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003, 2004, 2007, 2008
+   2000, 2001, 2002, 2003, 2004, 2007, 2008, 2009
    Free Software Foundation, Inc.
    Original version by Per Bothner.
    Full support added by Ian Lance Taylor, ian@cygnus.com.
@@ -1312,7 +1312,8 @@ static const struct ecoff_backend_data m
     (unsigned (*) PARAMS ((bfd *,PTR,PTR))) bfd_void, /* reloc_out */
     mips_ecoff_swap_filehdr_out, mips_ecoff_swap_aouthdr_out,
     mips_ecoff_swap_scnhdr_out,
-    FILHSZ, AOUTSZ, SCNHSZ, 0, 0, 0, 0, FILNMLEN, TRUE, FALSE, 4, FALSE, 2,
+    FILHSZ, AOUTSZ, SCNHSZ, 0, 0, 0, 0, FILNMLEN, TRUE, 
+    ECOFF_NO_LONG_SECTION_NAMES, 4, FALSE, 2,
     mips_ecoff_swap_filehdr_in, mips_ecoff_swap_aouthdr_in,
     mips_ecoff_swap_scnhdr_in, NULL,
     mips_ecoff_bad_format_hook, _bfd_ecoff_set_arch_mach_hook,
Index: bfd/coff-rs6000.c
===================================================================
RCS file: /cvs/src/src/bfd/coff-rs6000.c,v
retrieving revision 1.83
diff -p -u -r1.83 coff-rs6000.c
--- bfd/coff-rs6000.c	18 Jul 2008 11:30:22 -0000	1.83
+++ bfd/coff-rs6000.c	12 Feb 2009 22:13:10 -0000
@@ -1,6 +1,6 @@
 /* BFD back-end for IBM RS/6000 "XCOFF" files.
    Copyright 1990-1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
-   2008  Free Software Foundation, Inc.
+   2008, 2009  Free Software Foundation, Inc.
    Written by Metin G. Ozisik, Mimi Phuong-Thao Vo, and John Gilmore.
    Archive support from Damon A. Permezel.
    Contributed by IBM Corporation and Cygnus Support.
@@ -4011,7 +4011,7 @@ static const struct xcoff_backend_data_r
       LINESZ,
       FILNMLEN,
       TRUE,			/* _bfd_coff_long_filenames */
-      FALSE,			/* _bfd_coff_long_section_names */
+      XCOFF_NO_LONG_SECTION_NAMES,  /* _bfd_coff_long_section_names */
       3,			/* _bfd_coff_default_section_alignment_power */
       FALSE,			/* _bfd_coff_force_symnames_in_strings */
       2,			/* _bfd_coff_debug_string_prefix_length */
@@ -4263,7 +4263,7 @@ static const struct xcoff_backend_data_r
       LINESZ,
       FILNMLEN,
       TRUE,			/* _bfd_coff_long_filenames */
-      FALSE,			/* _bfd_coff_long_section_names */
+      XCOFF_NO_LONG_SECTION_NAMES,  /* _bfd_coff_long_section_names */
       3,			/* _bfd_coff_default_section_alignment_power */
       FALSE,			/* _bfd_coff_force_symnames_in_strings */
       2,			/* _bfd_coff_debug_string_prefix_length */
Index: bfd/coff-sh.c
===================================================================
RCS file: /cvs/src/src/bfd/coff-sh.c,v
retrieving revision 1.39
diff -p -u -r1.39 coff-sh.c
--- bfd/coff-sh.c	21 Jul 2008 14:09:57 -0000	1.39
+++ bfd/coff-sh.c	12 Feb 2009 22:13:10 -0000
@@ -1,6 +1,6 @@
 /* BFD back-end for Renesas Super-H COFF binaries.
    Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-   2003, 2004, 2005, 2007, 2008  Free Software Foundation, Inc.
+   2003, 2004, 2005, 2007, 2008, 2009  Free Software Foundation, Inc.
    Contributed by Cygnus Support.
    Written by Steve Chamberlain, <sac@cygnus.com>.
    Relaxing code written by Ian Lance Taylor, <ian@cygnus.com>.
@@ -3121,7 +3121,7 @@ coff_small_new_section_hook (abfd, secti
 /* This is copied from bfd_coff_std_swap_table so that we can change
    the default section alignment power.  */
 
-static const bfd_coff_backend_data bfd_coff_small_swap_table =
+static bfd_coff_backend_data bfd_coff_small_swap_table =
 {
   coff_swap_aux_in, coff_swap_sym_in, coff_swap_lineno_in,
   coff_swap_aux_out, coff_swap_sym_out,
@@ -3134,11 +3134,7 @@ static const bfd_coff_backend_data bfd_c
 #else
   FALSE,
 #endif
-#ifdef COFF_LONG_SECTION_NAMES
-  TRUE,
-#else
-  FALSE,
-#endif
+  COFF_DEFAULT_LONG_SECTION_NAMES,
   2,
 #ifdef COFF_FORCE_SYMBOLS_IN_STRINGS
   TRUE,
Index: bfd/coff64-rs6000.c
===================================================================
RCS file: /cvs/src/src/bfd/coff64-rs6000.c,v
retrieving revision 1.72
diff -p -u -r1.72 coff64-rs6000.c
--- bfd/coff64-rs6000.c	30 Sep 2008 10:50:03 -0000	1.72
+++ bfd/coff64-rs6000.c	12 Feb 2009 22:13:11 -0000
@@ -1,5 +1,5 @@
 /* BFD back-end for IBM RS/6000 "XCOFF64" files.
-   Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+   Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
    Free Software Foundation, Inc.
    Written Clinton Popetz.
    Contributed by Cygnus Support.
@@ -767,7 +767,6 @@ xcoff64_write_object_contents (abfd)
   file_ptr sym_base;
   unsigned long reloc_size = 0;
   unsigned long lnno_size = 0;
-  bfd_boolean long_section_names;
   asection *text_sec = ((void *) 0);
   asection *data_sec = ((void *) 0);
   asection *bss_sec = ((void *) 0);
@@ -837,7 +836,6 @@ xcoff64_write_object_contents (abfd)
   if (bfd_seek (abfd, scn_base, SEEK_SET) != 0)
     return FALSE;
 
-  long_section_names = FALSE;
   for (current = abfd->sections; current != NULL; current = current->next)
     {
       struct internal_scnhdr section;
@@ -2561,7 +2559,7 @@ static const struct xcoff_backend_data_r
       LINESZ,
       FILNMLEN,
       TRUE,			/* _bfd_coff_long_filenames */
-      FALSE,			/* _bfd_coff_long_section_names */
+      XCOFF_NO_LONG_SECTION_NAMES,  /* _bfd_coff_long_section_names */
       3,			/* _bfd_coff_default_section_alignment_power */
       TRUE,			/* _bfd_coff_force_symnames_in_strings */
       4,			/* _bfd_coff_debug_string_prefix_length */
@@ -2815,7 +2813,7 @@ static const struct xcoff_backend_data_r
       LINESZ,
       FILNMLEN,
       TRUE,			/* _bfd_coff_long_filenames */
-      FALSE,			/* _bfd_coff_long_section_names */
+      XCOFF_NO_LONG_SECTION_NAMES,  /* _bfd_coff_long_section_names */
       3,			/* _bfd_coff_default_section_alignment_power */
       TRUE,			/* _bfd_coff_force_symnames_in_strings */
       4,			/* _bfd_coff_debug_string_prefix_length */
Index: bfd/coffcode.h
===================================================================
RCS file: /cvs/src/src/bfd/coffcode.h,v
retrieving revision 1.146
diff -p -u -r1.146 coffcode.h
--- bfd/coffcode.h	16 Jan 2009 15:09:20 -0000	1.146
+++ bfd/coffcode.h	12 Feb 2009 22:13:12 -0000
@@ -1,6 +1,6 @@
 /* Support for the generic parts of most COFF variants, for BFD.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
    Free Software Foundation, Inc.
    Written by Cygnus Support.
 
@@ -108,6 +108,60 @@ SUBSUBSECTION
 	@file{coffcode.h} because it would not be used by any other
 	target.
 
+SUBSECTION
+	Coff long section names
+
+	In the standard Coff object format, section names are limited to
+	the eight bytes available in the @code{s_name} field of the
+	@code{SCNHDR} section header structure.  The format requires the
+	field to be NUL-padded, but not necessarily NUL-terminated, so
+	the longest section names permitted are a full eight characters.
+
+	The Microsoft PE variants of the Coff object file format add
+	an extension to support the use of long section names.  This
+	extension is defined in section 4 of the Microsoft PE/COFF 
+	specification (rev 8.1).  If a section name is too long to fit
+	into the section header's @code{s_name} field, it is instead
+	placed into the string table, and the @code{s_name} field is
+	filled with a slash ("/") followed by the ASCII decimal 
+	representation of the offset of the full name relative to the
+	string table base.
+
+	Note that this implies that the extension can only be used in object
+	files, as executables do not contain a string table.  The standard
+	specifies that long section names from objects emitted into executable
+	images are to be truncated.
+
+	However, as a GNU extension, BFD can generate executable images
+	that contain a string table and long section names.  This
+	would appear to be technically valid, as the standard only says
+	that Coff debugging information is deprecated, not forbidden,
+	and in practice it works, although some tools that parse PE files
+	expecting the MS standard format may become confused; @file{PEview} is
+	one known example.
+
+	The functionality is supported in BFD by code implemented under 
+	the control of the macro @code{COFF_LONG_SECTION_NAMES}.  If not
+	defined, the format does not support long section names in any way.
+	If defined, it is used to initialise a flag, 
+	@code{_bfd_coff_long_section_names}, and a hook function pointer, 
+	@code{_bfd_coff_set_long_section_names}, in the Coff backend data
+	structure.  The flag controls the generation of long section names
+	in output BFDs at runtime; if it is false, as it will be by default
+	when generating an executable image, long section names are truncated;
+	if true, the long section names extension is employed.  The hook
+	points to a function that allows the value of the flag to be altered
+	at runtime, on formats that support long section names at all; on
+	other formats it points to a stub that returns an error indication.
+
+	If @code{COFF_LONG_SECTION_NAMES} is simply defined (blank), or is
+	defined to the value "1", then long section names are enabled by
+	default; if it is defined to the value zero, they are disabled by
+	default (but still accepted in input BFDs).  The header @file{coffcode.h}
+	defines a macro, @code{COFF_DEFAULT_LONG_SECTION_NAMES}, which is
+	used in the backends to initialise the backend data structure fields
+	appropriately; see the comments for further detail.
+
 SUBSUBSECTION
 	Bit twiddling
 
@@ -310,6 +364,40 @@ CODE_FRAGMENT
 #define DOT_DEBUG	".debug"
 #define GNU_LINKONCE_WI ".gnu.linkonce.wi."
 
+#if defined (COFF_LONG_SECTION_NAMES)
+/* Needed to expand the inputs to BLANKOR1TOODD.  */
+#define COFFLONGSECTIONCATHELPER(x,y)    x ## y
+/* If the input macro Y is blank or '1', return an odd number; if it is
+   '0', return an even number.  Result undefined in all other cases.  */
+#define BLANKOR1TOODD(y)                 COFFLONGSECTIONCATHELPER(1,y)
+/* Defined to numerical 0 or 1 according to whether generation of long
+   section names is disabled or enabled by default.  */
+#define COFF_ENABLE_LONG_SECTION_NAMES   (BLANKOR1TOODD(COFF_LONG_SECTION_NAMES) & 1)
+/* Where long section names are supported, we allow them to be enabled
+   and disabled at runtime, so select an appropriate hook function for
+   _bfd_coff_set_long_section_names.  */
+#define COFF_LONG_SECTION_NAMES_SETTER   bfd_coff_set_long_section_names_allowed
+#else /* !defined (COFF_LONG_SECTION_NAMES) */
+/* If long section names are not supported, this stub disallows any
+   attempt to enable them at run-time.  */
+#define COFF_LONG_SECTION_NAMES_SETTER   bfd_coff_set_long_section_names_disallowed
+#endif /* defined (COFF_LONG_SECTION_NAMES) */
+
+/* Define a macro that can be used to initialise both the fields relating
+   to long section names in the backend data struct simultaneously.  */
+#if COFF_ENABLE_LONG_SECTION_NAMES
+#define COFF_DEFAULT_LONG_SECTION_NAMES  (TRUE), COFF_LONG_SECTION_NAMES_SETTER
+#else /* !COFF_ENABLE_LONG_SECTION_NAMES */
+#define COFF_DEFAULT_LONG_SECTION_NAMES  (FALSE), COFF_LONG_SECTION_NAMES_SETTER
+#endif /* COFF_ENABLE_LONG_SECTION_NAMES */
+
+#if defined (COFF_LONG_SECTION_NAMES)
+static bfd_boolean bfd_coff_set_long_section_names_allowed
+  (bfd *, int);
+#else /* !defined (COFF_LONG_SECTION_NAMES) */
+static bfd_boolean bfd_coff_set_long_section_names_disallowed
+  (bfd *, int);
+#endif /* defined (COFF_LONG_SECTION_NAMES) */
 static long sec_to_styp_flags
   (const char *, flagword);
 static bfd_boolean styp_to_sec_flags
@@ -372,6 +460,23 @@ static bfd_boolean ticoff1_bad_format_ho
 
 /* void warning(); */
 
+#if defined (COFF_LONG_SECTION_NAMES)
+static bfd_boolean
+bfd_coff_set_long_section_names_allowed (bfd *abfd, int enable)
+{
+  coff_backend_info (abfd)->_bfd_coff_long_section_names = enable;
+  return TRUE;
+}
+#else /* !defined (COFF_LONG_SECTION_NAMES) */
+static bfd_boolean
+bfd_coff_set_long_section_names_disallowed (bfd *abfd, int enable)
+{
+  (void) abfd;
+  (void) enable;
+  return FALSE;
+}
+#endif /* defined (COFF_LONG_SECTION_NAMES) */
+
 /* Return a word with STYP_* (scnhdr.s_flags) flags set to represent
    the incoming SEC_* flags.  The inverse of this function is
    styp_to_sec_flags().  NOTE: If you add to/change this routine, you
@@ -1214,7 +1319,11 @@ Special entry points for gdb to swap in 
 .  unsigned int _bfd_linesz;
 .  unsigned int _bfd_filnmlen;
 .  bfd_boolean _bfd_coff_long_filenames;
+.
 .  bfd_boolean _bfd_coff_long_section_names;
+.  bfd_boolean (*_bfd_coff_set_long_section_names)
+.    (bfd *, int);
+.  
 .  unsigned int _bfd_coff_default_section_alignment_power;
 .  bfd_boolean _bfd_coff_force_symnames_in_strings;
 .  unsigned int _bfd_coff_debug_string_prefix_length;
@@ -1351,6 +1460,8 @@ Special entry points for gdb to swap in 
 .  (coff_backend_info (abfd)->_bfd_coff_long_filenames)
 .#define bfd_coff_long_section_names(abfd) \
 .  (coff_backend_info (abfd)->_bfd_coff_long_section_names)
+.#define bfd_coff_set_long_section_names(abfd, enable) \
+.  ((coff_backend_info (abfd)->_bfd_coff_set_long_section_names) (abfd, enable))
 .#define bfd_coff_default_section_alignment_power(abfd) \
 .  (coff_backend_info (abfd)->_bfd_coff_default_section_alignment_power)
 .#define bfd_coff_swap_filehdr_in(abfd, i,o) \
@@ -3511,18 +3622,19 @@ coff_write_object_contents (bfd * abfd)
 #ifdef COFF_LONG_SECTION_NAMES
       /* Handle long section names as in PE.  This must be compatible
 	 with the code in coff_write_symbols and _bfd_coff_final_link.  */
-      {
-	size_t len;
+      if (bfd_coff_long_section_names (abfd))
+	{
+	  size_t len;
 
-	len = strlen (current->name);
-	if (len > SCNNMLEN)
-	  {
-	    memset (section.s_name, 0, SCNNMLEN);
-	    sprintf (section.s_name, "/%lu", (unsigned long) string_size);
-	    string_size += len + 1;
-	    long_section_names = TRUE;
-	  }
-      }
+	  len = strlen (current->name);
+	  if (len > SCNNMLEN)
+	    {
+	      memset (section.s_name, 0, SCNNMLEN);
+	      sprintf (section.s_name, "/%lu", (unsigned long) string_size);
+	      string_size += len + 1;
+	      long_section_names = TRUE;
+	    }
+	}
 #endif
 
 #ifdef _LIB
@@ -5246,7 +5358,7 @@ coff_final_link_postscript (bfd * abfd A
 #define coff_SWAP_scnhdr_in coff_swap_scnhdr_in
 #endif
 
-static const bfd_coff_backend_data bfd_coff_std_swap_table ATTRIBUTE_UNUSED =
+static bfd_coff_backend_data bfd_coff_std_swap_table ATTRIBUTE_UNUSED =
 {
   coff_SWAP_aux_in, coff_SWAP_sym_in, coff_SWAP_lineno_in,
   coff_SWAP_aux_out, coff_SWAP_sym_out,
@@ -5259,11 +5371,7 @@ static const bfd_coff_backend_data bfd_c
 #else
   FALSE,
 #endif
-#ifdef COFF_LONG_SECTION_NAMES
-  TRUE,
-#else
-  FALSE,
-#endif
+  COFF_DEFAULT_LONG_SECTION_NAMES,
   COFF_DEFAULT_SECTION_ALIGNMENT_POWER,
 #ifdef COFF_FORCE_SYMBOLS_IN_STRINGS
   TRUE,
@@ -5290,7 +5398,7 @@ static const bfd_coff_backend_data bfd_c
 #ifdef TICOFF
 /* COFF0 differs in file/section header size and relocation entry size.  */
 
-static const bfd_coff_backend_data ticoff0_swap_table =
+static bfd_coff_backend_data ticoff0_swap_table =
 {
   coff_SWAP_aux_in, coff_SWAP_sym_in, coff_SWAP_lineno_in,
   coff_SWAP_aux_out, coff_SWAP_sym_out,
@@ -5303,11 +5411,7 @@ static const bfd_coff_backend_data ticof
 #else
   FALSE,
 #endif
-#ifdef COFF_LONG_SECTION_NAMES
-  TRUE,
-#else
-  FALSE,
-#endif
+  COFF_DEFAULT_LONG_SECTION_NAMES,
   COFF_DEFAULT_SECTION_ALIGNMENT_POWER,
 #ifdef COFF_FORCE_SYMBOLS_IN_STRINGS
   TRUE,
@@ -5335,7 +5439,7 @@ static const bfd_coff_backend_data ticof
 #ifdef TICOFF
 /* COFF1 differs in section header size.  */
 
-static const bfd_coff_backend_data ticoff1_swap_table =
+static bfd_coff_backend_data ticoff1_swap_table =
 {
   coff_SWAP_aux_in, coff_SWAP_sym_in, coff_SWAP_lineno_in,
   coff_SWAP_aux_out, coff_SWAP_sym_out,
@@ -5348,11 +5452,7 @@ static const bfd_coff_backend_data ticof
 #else
   FALSE,
 #endif
-#ifdef COFF_LONG_SECTION_NAMES
-  TRUE,
-#else
-  FALSE,
-#endif
+  COFF_DEFAULT_LONG_SECTION_NAMES,
   COFF_DEFAULT_SECTION_ALIGNMENT_POWER,
 #ifdef COFF_FORCE_SYMBOLS_IN_STRINGS
   TRUE,
Index: bfd/coffgen.c
===================================================================
RCS file: /cvs/src/src/bfd/coffgen.c,v
retrieving revision 1.68
diff -p -u -r1.68 coffgen.c
--- bfd/coffgen.c	30 Sep 2008 10:50:03 -0000	1.68
+++ bfd/coffgen.c	12 Feb 2009 22:13:12 -0000
@@ -1,6 +1,6 @@
 /* Support for the generic parts of COFF, for BFD.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008
+   2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009
    Free Software Foundation, Inc.
    Written by Cygnus Support.
 
@@ -59,8 +59,13 @@ make_a_section_from_file (bfd *abfd,
 
   name = NULL;
 
-  /* Handle long section names as in PE.  */
-  if (bfd_coff_long_section_names (abfd)
+  /* Handle long section names as in PE.  On reading, we want to
+    accept long names if the format permits them at all, regardless
+    of the current state of the flag that dictates if we would generate
+    them in outputs; this construct checks if that is the case by
+    attempting to set the flag, without changing its state; the call
+    will fail for formats that do not support long names at all.  */
+  if (bfd_coff_set_long_section_names (abfd, bfd_coff_long_section_names (abfd))
       && hdr->s_name[0] == '/')
     {
       char buf[SCNNMLEN];
Index: bfd/ecoff.c
===================================================================
RCS file: /cvs/src/src/bfd/ecoff.c,v
retrieving revision 1.61
diff -p -u -r1.61 ecoff.c
--- bfd/ecoff.c	30 Jul 2008 04:34:56 -0000	1.61
+++ bfd/ecoff.c	12 Feb 2009 22:13:12 -0000
@@ -1,6 +1,6 @@
 /* Generic ECOFF (Extended-COFF) routines.
    Copyright 1990, 1991, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
-   2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+   2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
    Original version by Per Bothner.
    Full support added by Ian Lance Taylor, ian@cygnus.com.
 
@@ -233,6 +233,16 @@ _bfd_ecoff_set_arch_mach_hook (bfd *abfd
   return bfd_default_set_arch_mach (abfd, arch, mach);
 }
 
+bfd_boolean
+_bfd_ecoff_no_long_sections (abfd, enable)
+     bfd *abfd;
+     int enable;
+{
+  (void) abfd;
+  (void) enable;
+  return FALSE;
+}
+
 /* Get the magic number to use based on the architecture and machine.
    This is the inverse of _bfd_ecoff_set_arch_mach_hook, above.  */
 
Index: bfd/efi-app-ia32.c
===================================================================
RCS file: /cvs/src/src/bfd/efi-app-ia32.c,v
retrieving revision 1.10
diff -p -u -r1.10 efi-app-ia32.c
--- bfd/efi-app-ia32.c	3 Jul 2007 14:26:40 -0000	1.10
+++ bfd/efi-app-ia32.c	12 Feb 2009 22:13:12 -0000
@@ -1,5 +1,5 @@
 /* BFD back-end for Intel IA-32 EFI application files.
-   Copyright 1999, 2000, 2001, 2002, 2007 Free Software Foundation, Inc.
+   Copyright 1999, 2000, 2001, 2002, 2007, 2009 Free Software Foundation, Inc.
    Contributed by David Mosberger <davidm@hpl.hp.com>
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -28,7 +28,8 @@
 #define COFF_WITH_PE
 #define PCRELOFFSET TRUE
 #define TARGET_UNDERSCORE '_'
-#define COFF_LONG_SECTION_NAMES
+/* Long section names not allowed in executable images, only object files.  */
+#define COFF_LONG_SECTION_NAMES 0
 #define PEI_TARGET_SUBSYSTEM	IMAGE_SUBSYSTEM_EFI_APPLICATION
 #define PEI_FORCE_MINIMUM_ALIGNMENT
 
Index: bfd/efi-app-ia64.c
===================================================================
RCS file: /cvs/src/src/bfd/efi-app-ia64.c,v
retrieving revision 1.8
diff -p -u -r1.8 efi-app-ia64.c
--- bfd/efi-app-ia64.c	3 Jul 2007 14:26:40 -0000	1.8
+++ bfd/efi-app-ia64.c	12 Feb 2009 22:13:12 -0000
@@ -1,5 +1,5 @@
 /* BFD back-end for HP/Intel IA-64 EFI application files.
-   Copyright 1999, 2000, 2001, 2002, 2007 Free Software Foundation, Inc.
+   Copyright 1999, 2000, 2001, 2002, 2007, 2009 Free Software Foundation, Inc.
    Contributed by David Mosberger <davidm@hpl.hp.com>
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -29,7 +29,8 @@
 #define COFF_WITH_pep
 #define PCRELOFFSET TRUE
 #define TARGET_UNDERSCORE '_'
-#define COFF_LONG_SECTION_NAMES
+/* Long section names not allowed in executable images, only object files.  */
+#define COFF_LONG_SECTION_NAMES 0
 #define PEI_TARGET_SUBSYSTEM		IMAGE_SUBSYSTEM_EFI_APPLICATION
 #define PEI_FORCE_MINIMUM_ALIGNMENT
 
Index: bfd/efi-app-x86_64.c
===================================================================
RCS file: /cvs/src/src/bfd/efi-app-x86_64.c,v
retrieving revision 1.3
diff -p -u -r1.3 efi-app-x86_64.c
--- bfd/efi-app-x86_64.c	3 Jul 2007 14:26:40 -0000	1.3
+++ bfd/efi-app-x86_64.c	12 Feb 2009 22:13:12 -0000
@@ -1,5 +1,5 @@
 /* BFD back-end for Intel64 UEFI application files.
-   Copyright 2007 Free Software Foundation, Inc.
+   Copyright 2007, 2009 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -28,7 +28,8 @@
 #define COFF_WITH_pep
 #define PCRELOFFSET TRUE
 #define TARGET_UNDERSCORE '_'
-#define COFF_LONG_SECTION_NAMES
+/* Long section names not allowed in executable images, only object files.  */
+#define COFF_LONG_SECTION_NAMES 0
 #define PEI_TARGET_SUBSYSTEM	IMAGE_SUBSYSTEM_EFI_APPLICATION
 #define PEI_FORCE_MINIMUM_ALIGNMENT
 
Index: bfd/efi-bsdrv-ia32.c
===================================================================
RCS file: /cvs/src/src/bfd/efi-bsdrv-ia32.c,v
retrieving revision 1.1
diff -p -u -r1.1 efi-bsdrv-ia32.c
--- bfd/efi-bsdrv-ia32.c	14 Feb 2008 15:20:26 -0000	1.1
+++ bfd/efi-bsdrv-ia32.c	12 Feb 2009 22:13:12 -0000
@@ -1,5 +1,5 @@
 /* BFD back-end for Intel IA-32 EFI Boot Service driver files.
-   Copyright 1999, 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
+   Copyright 1999, 2000, 2001, 2002, 2007, 2008, 2009 Free Software Foundation, Inc.
    Contributed by Peter Jones <pjones@redhat.com>
    Based on efi-app-ia32.c by David Mosberger <davidm@hpl.hp.com>
 
@@ -29,7 +29,8 @@
 #define COFF_WITH_PE
 #define PCRELOFFSET TRUE
 #define TARGET_UNDERSCORE '_'
-#define COFF_LONG_SECTION_NAMES
+/* Long section names not allowed in executable images, only object files.  */
+#define COFF_LONG_SECTION_NAMES 0
 #define PEI_TARGET_SUBSYSTEM	IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER
 #define PEI_FORCE_MINIMUM_ALIGNMENT
 
Index: bfd/efi-bsdrv-ia64.c
===================================================================
RCS file: /cvs/src/src/bfd/efi-bsdrv-ia64.c,v
retrieving revision 1.1
diff -p -u -r1.1 efi-bsdrv-ia64.c
--- bfd/efi-bsdrv-ia64.c	14 Feb 2008 15:20:26 -0000	1.1
+++ bfd/efi-bsdrv-ia64.c	12 Feb 2009 22:13:12 -0000
@@ -1,5 +1,5 @@
 /* BFD back-end for HP/Intel IA-64 EFI Boot Service driver files.
-   Copyright 1999, 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
+   Copyright 1999, 2000, 2001, 2002, 2007, 2008, 2009 Free Software Foundation, Inc.
    Contributed by Peter Jones <pjones@redhat.com>
    Based on efi-app-ia64.c by David Mosberger <davidm@hpl.hp.com>
 
@@ -30,7 +30,8 @@
 #define COFF_WITH_pep
 #define PCRELOFFSET TRUE
 #define TARGET_UNDERSCORE '_'
-#define COFF_LONG_SECTION_NAMES
+/* Long section names not allowed in executable images, only object files.  */
+#define COFF_LONG_SECTION_NAMES 0
 #define PEI_TARGET_SUBSYSTEM		IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER
 #define PEI_FORCE_MINIMUM_ALIGNMENT
 
Index: bfd/efi-bsdrv-x86_64.c
===================================================================
RCS file: /cvs/src/src/bfd/efi-bsdrv-x86_64.c,v
retrieving revision 1.1
diff -p -u -r1.1 efi-bsdrv-x86_64.c
--- bfd/efi-bsdrv-x86_64.c	14 Feb 2008 15:20:26 -0000	1.1
+++ bfd/efi-bsdrv-x86_64.c	12 Feb 2009 22:13:12 -0000
@@ -1,5 +1,5 @@
 /* BFD back-end for Intel64 UEFI Boot Service driver files.
-   Copyright 1999, 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
+   Copyright 1999, 2000, 2001, 2002, 2007, 2008, 2009 Free Software Foundation, Inc.
    Contributed by Peter Jones <pjones@redhat.com>
    Based on efi-app-x86_64.c by David Mosberger <davidm@hpl.hp.com>
 
@@ -30,7 +30,8 @@
 #define COFF_WITH_pep
 #define PCRELOFFSET TRUE
 #define TARGET_UNDERSCORE '_'
-#define COFF_LONG_SECTION_NAMES
+/* Long section names not allowed in executable images, only object files.  */
+#define COFF_LONG_SECTION_NAMES 0
 #define PEI_TARGET_SUBSYSTEM	IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER
 #define PEI_FORCE_MINIMUM_ALIGNMENT
 
Index: bfd/efi-rtdrv-ia32.c
===================================================================
RCS file: /cvs/src/src/bfd/efi-rtdrv-ia32.c,v
retrieving revision 1.1
diff -p -u -r1.1 efi-rtdrv-ia32.c
--- bfd/efi-rtdrv-ia32.c	14 Feb 2008 15:20:26 -0000	1.1
+++ bfd/efi-rtdrv-ia32.c	12 Feb 2009 22:13:12 -0000
@@ -1,5 +1,5 @@
 /* BFD back-end for Intel IA-32 EFI runtime driver files.
-   Copyright 1999, 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
+   Copyright 1999, 2000, 2001, 2002, 2007, 2008, 2009 Free Software Foundation, Inc.
    Contributed by Peter Jones <pjones@redhat.com>
    Based on efi-app-ia32.c by David Mosberger <davidm@hpl.hp.com>
 
@@ -29,7 +29,8 @@
 #define COFF_WITH_PE
 #define PCRELOFFSET TRUE
 #define TARGET_UNDERSCORE '_'
-#define COFF_LONG_SECTION_NAMES
+/* Long section names not allowed in executable images, only object files.  */
+#define COFF_LONG_SECTION_NAMES 0
 #define PEI_TARGET_SUBSYSTEM	IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER
 #define PEI_FORCE_MINIMUM_ALIGNMENT
 
Index: bfd/efi-rtdrv-ia64.c
===================================================================
RCS file: /cvs/src/src/bfd/efi-rtdrv-ia64.c,v
retrieving revision 1.1
diff -p -u -r1.1 efi-rtdrv-ia64.c
--- bfd/efi-rtdrv-ia64.c	14 Feb 2008 15:20:26 -0000	1.1
+++ bfd/efi-rtdrv-ia64.c	12 Feb 2009 22:13:12 -0000
@@ -1,5 +1,5 @@
 /* BFD back-end for HP/Intel IA-64 EFI runtime driver files.
-   Copyright 1999, 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
+   Copyright 1999, 2000, 2001, 2002, 2007, 2008, 2009 Free Software Foundation, Inc.
    Contributed by Peter Jones <pjones@redhat.com>
    Based on efi-app-ia64.c by David Mosberger <davidm@hpl.hp.com>
 
@@ -30,7 +30,8 @@
 #define COFF_WITH_pep
 #define PCRELOFFSET TRUE
 #define TARGET_UNDERSCORE '_'
-#define COFF_LONG_SECTION_NAMES
+/* Long section names not allowed in executable images, only object files.  */
+#define COFF_LONG_SECTION_NAMES 0
 #define PEI_TARGET_SUBSYSTEM		IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER
 #define PEI_FORCE_MINIMUM_ALIGNMENT
 
Index: bfd/efi-rtdrv-x86_64.c
===================================================================
RCS file: /cvs/src/src/bfd/efi-rtdrv-x86_64.c,v
retrieving revision 1.1
diff -p -u -r1.1 efi-rtdrv-x86_64.c
--- bfd/efi-rtdrv-x86_64.c	14 Feb 2008 15:20:26 -0000	1.1
+++ bfd/efi-rtdrv-x86_64.c	12 Feb 2009 22:13:12 -0000
@@ -1,5 +1,5 @@
 /* BFD back-end for Intel64 UEFI runtime driver files.
-   Copyright 1999, 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
+   Copyright 1999, 2000, 2001, 2002, 2007, 2008, 2009 Free Software Foundation, Inc.
    Contributed by Peter Jones <pjones@redhat.com>
    Based on efi-app-x86_64.c by David Mosberger <davidm@hpl.hp.com>
 
@@ -30,7 +30,8 @@
 #define COFF_WITH_pep
 #define PCRELOFFSET TRUE
 #define TARGET_UNDERSCORE '_'
-#define COFF_LONG_SECTION_NAMES
+/* Long section names not allowed in executable images, only object files.  */
+#define COFF_LONG_SECTION_NAMES 0
 #define PEI_TARGET_SUBSYSTEM	IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER
 #define PEI_FORCE_MINIMUM_ALIGNMENT
 
Index: bfd/libcoff-in.h
===================================================================
RCS file: /cvs/src/src/bfd/libcoff-in.h,v
retrieving revision 1.32
diff -p -u -r1.32 libcoff-in.h
--- bfd/libcoff-in.h	18 Jul 2008 11:30:22 -0000	1.32
+++ bfd/libcoff-in.h	12 Feb 2009 22:13:12 -0000
@@ -1,6 +1,6 @@
 /* BFD COFF object file private structure.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
    Free Software Foundation, Inc.
    Written by Cygnus Support.
 
@@ -593,7 +593,7 @@ extern bfd_boolean _bfd_ppc_xcoff_reloca
   (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
    struct internal_reloc *, struct internal_syment *, asection **);
 
-/* Functions in coff-ppc.c.  FIXME: These are called be pe.em in the
+/* Functions in coff-ppc.c.  FIXME: These are called by pe.em in the
    linker, and so should start with bfd and be declared in bfd.h.  */
 
 extern bfd_boolean ppc_allocate_toc_section
Index: bfd/libcoff.h
===================================================================
RCS file: /cvs/src/src/bfd/libcoff.h,v
retrieving revision 1.48
diff -p -u -r1.48 libcoff.h
--- bfd/libcoff.h	30 Jul 2008 04:34:56 -0000	1.48
+++ bfd/libcoff.h	12 Feb 2009 22:13:12 -0000
@@ -4,7 +4,7 @@
 
 /* BFD COFF object file private structure.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
    Free Software Foundation, Inc.
    Written by Cygnus Support.
 
@@ -597,7 +597,7 @@ extern bfd_boolean _bfd_ppc_xcoff_reloca
   (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
    struct internal_reloc *, struct internal_syment *, asection **);
 
-/* Functions in coff-ppc.c.  FIXME: These are called be pe.em in the
+/* Functions in coff-ppc.c.  FIXME: These are called by pe.em in the
    linker, and so should start with bfd and be declared in bfd.h.  */
 
 extern bfd_boolean ppc_allocate_toc_section
@@ -715,7 +715,11 @@ typedef struct
   unsigned int _bfd_linesz;
   unsigned int _bfd_filnmlen;
   bfd_boolean _bfd_coff_long_filenames;
+
   bfd_boolean _bfd_coff_long_section_names;
+  bfd_boolean (*_bfd_coff_set_long_section_names)
+    (bfd *, int);
+  
   unsigned int _bfd_coff_default_section_alignment_power;
   bfd_boolean _bfd_coff_force_symnames_in_strings;
   unsigned int _bfd_coff_debug_string_prefix_length;
@@ -852,6 +856,8 @@ typedef struct
   (coff_backend_info (abfd)->_bfd_coff_long_filenames)
 #define bfd_coff_long_section_names(abfd) \
   (coff_backend_info (abfd)->_bfd_coff_long_section_names)
+#define bfd_coff_set_long_section_names(abfd, enable) \
+  ((coff_backend_info (abfd)->_bfd_coff_set_long_section_names) (abfd, enable))
 #define bfd_coff_default_section_alignment_power(abfd) \
   (coff_backend_info (abfd)->_bfd_coff_default_section_alignment_power)
 #define bfd_coff_swap_filehdr_in(abfd, i,o) \
Index: bfd/libecoff.h
===================================================================
RCS file: /cvs/src/src/bfd/libecoff.h,v
retrieving revision 1.24
diff -p -u -r1.24 libecoff.h
--- bfd/libecoff.h	21 Jan 2008 03:48:10 -0000	1.24
+++ bfd/libecoff.h	12 Feb 2009 22:13:12 -0000
@@ -1,6 +1,6 @@
 /* BFD ECOFF object file private structure.
    Copyright 1993, 1994, 1995, 1996, 1999, 2001, 2002, 2003, 2004,
-   2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+   2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Cygnus Support.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -76,6 +76,11 @@ struct ecoff_backend_data
   bfd *(*get_elt_at_filepos) (bfd *, file_ptr);
 };
 
+/* ECOFF targets don't support COFF long section names, so this
+  macro is provided to use as an initialiser for the related
+  members of the embedded bfd_coff_backend_data struct.  */
+#define ECOFF_NO_LONG_SECTION_NAMES (FALSE), _bfd_ecoff_no_long_sections
+
 /* This is the target specific information kept for ECOFF files.  */
 
 #define ecoff_data(abfd) ((abfd)->tdata.ecoff_obj_data)
@@ -320,6 +325,8 @@ extern void * _bfd_ecoff_mkobject_hook (
   ((void (*) (bfd *, asection *, void *)) bfd_void)
 extern bfd_boolean _bfd_ecoff_set_arch_mach_hook
   (bfd *, void *);
+extern bfd_boolean _bfd_ecoff_no_long_sections
+  (bfd *abfd, int enable);
 extern bfd_boolean _bfd_ecoff_styp_to_sec_flags
   (bfd *, void *, const char *, asection *, flagword *);
 extern bfd_boolean _bfd_ecoff_slurp_symbol_table (bfd *);
Index: bfd/libxcoff.h
===================================================================
RCS file: /cvs/src/src/bfd/libxcoff.h,v
retrieving revision 1.17
diff -p -u -r1.17 libxcoff.h
--- bfd/libxcoff.h	3 Jul 2007 14:26:42 -0000	1.17
+++ bfd/libxcoff.h	12 Feb 2009 22:13:12 -0000
@@ -223,6 +223,8 @@ extern bfd_boolean (*xcoff_calculate_rel
 extern bfd_boolean (*xcoff_complain_overflow[XCOFF_MAX_COMPLAIN_OVERFLOW])
   (XCOFF_COMPLAIN_FUNCTION_ARGS);
 
+#define XCOFF_NO_LONG_SECTION_NAMES  (FALSE), bfd_coff_set_long_section_names_disallowed
+
 /* Relocation functions */
 bfd_boolean xcoff_reloc_type_noop (XCOFF_RELOC_FUNCTION_ARGS);
 bfd_boolean xcoff_reloc_type_fail (XCOFF_RELOC_FUNCTION_ARGS);
Index: bfd/pe-mips.c
===================================================================
RCS file: /cvs/src/src/bfd/pe-mips.c,v
retrieving revision 1.22
diff -p -u -r1.22 pe-mips.c
--- bfd/pe-mips.c	18 Jul 2008 11:30:22 -0000	1.22
+++ bfd/pe-mips.c	12 Feb 2009 22:13:13 -0000
@@ -1,6 +1,6 @@
 /* BFD back-end for MIPS PE COFF files.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008
+   2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009
    Free Software Foundation, Inc.
    Modified from coff-i386.c by DJ Delorie, dj@cygnus.com
 
@@ -22,7 +22,13 @@
    MA 02110-1301, USA.  */
 
 #define COFF_WITH_PE
+/* pei-mips.c may have defined this to default off (0) before
+  including this file, so don't redefine if that's the case.
+  Otherwise we're generating objects, not executable images,
+  so we want to define it to default on.  */
+#ifndef COFF_LONG_SECTION_NAMES
 #define COFF_LONG_SECTION_NAMES
+#endif /* COFF_LONG_SECTION_NAMES */
 #define PCRELOFFSET TRUE
 
 #include "sysdep.h"
Index: bfd/pei-arm.c
===================================================================
RCS file: /cvs/src/src/bfd/pei-arm.c,v
retrieving revision 1.13
diff -p -u -r1.13 pei-arm.c
--- bfd/pei-arm.c	3 Jul 2007 14:26:42 -0000	1.13
+++ bfd/pei-arm.c	12 Feb 2009 22:13:13 -0000
@@ -1,5 +1,5 @@
 /* BFD back-end for arm PE IMAGE COFF files.
-   Copyright 1995, 1996, 1999, 2002, 2007 Free Software Foundation, Inc.
+   Copyright 1995, 1996, 1999, 2002, 2007, 2009 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -31,7 +31,8 @@
 #define COFF_IMAGE_WITH_PE
 #define COFF_WITH_PE
 #define PCRELOFFSET        TRUE
-#define COFF_LONG_SECTION_NAMES
+/* Long section names not allowed in executable images, only object files.  */
+#define COFF_LONG_SECTION_NAMES 0
 
 #define COFF_SECTION_ALIGNMENT_ENTRIES \
 { COFF_SECTION_NAME_EXACT_MATCH (".bss"), \
Index: bfd/pei-i386.c
===================================================================
RCS file: /cvs/src/src/bfd/pei-i386.c,v
retrieving revision 1.13
diff -p -u -r1.13 pei-i386.c
--- bfd/pei-i386.c	9 Nov 2007 08:35:29 -0000	1.13
+++ bfd/pei-i386.c	12 Feb 2009 22:13:13 -0000
@@ -1,5 +1,5 @@
 /* BFD back-end for Intel 386 PE IMAGE COFF files.
-   Copyright 1995, 1996, 1999, 2002, 2004, 2007
+   Copyright 1995, 1996, 1999, 2002, 2004, 2007, 2009
    Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -28,7 +28,8 @@
 #define COFF_WITH_PE
 #define PCRELOFFSET 		TRUE
 #define TARGET_UNDERSCORE 	'_'
-#define COFF_LONG_SECTION_NAMES
+/* Long section names not allowed in executable images, only object files.  */
+#define COFF_LONG_SECTION_NAMES 0
 #define COFF_SUPPORT_GNU_LINKONCE
 #define COFF_LONG_FILENAMES
 
Index: bfd/pei-mcore.c
===================================================================
RCS file: /cvs/src/src/bfd/pei-mcore.c,v
retrieving revision 1.8
diff -p -u -r1.8 pei-mcore.c
--- bfd/pei-mcore.c	18 Jul 2008 11:30:22 -0000	1.8
+++ bfd/pei-mcore.c	12 Feb 2009 22:13:13 -0000
@@ -1,5 +1,5 @@
 /* BFD back-end for MCore PECOFF files.
-   Copyright 1999, 2002, 2007, 2008  Free Software Foundation, Inc.
+   Copyright 1999, 2002, 2007, 2008, 2009  Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -31,7 +31,8 @@
 #define COFF_IMAGE_WITH_PE
 #define COFF_WITH_PE
 #define PCRELOFFSET        TRUE
-#define COFF_LONG_SECTION_NAMES
+/* Long section names not allowed in executable images, only object files.  */
+#define COFF_LONG_SECTION_NAMES 0
 
 #define MCORE_PE
 
Index: bfd/pei-mips.c
===================================================================
RCS file: /cvs/src/src/bfd/pei-mips.c,v
retrieving revision 1.8
diff -p -u -r1.8 pei-mips.c
--- bfd/pei-mips.c	3 Jul 2007 14:26:42 -0000	1.8
+++ bfd/pei-mips.c	12 Feb 2009 22:13:13 -0000
@@ -1,5 +1,5 @@
 /* BFD back-end for MIPS PE IMAGE COFF files.
-   Copyright 1995, 2000, 2001, 2002, 2007 Free Software Foundation, Inc.
+   Copyright 1995, 2000, 2001, 2002, 2007, 2009 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -25,7 +25,8 @@
 #define TARGET_NAME "pei-mips"
 #define COFF_IMAGE_WITH_PE
 #define PCRELOFFSET TRUE
-#define COFF_LONG_SECTION_NAMES
+/* Long section names not allowed in executable images, only object files.  */
+#define COFF_LONG_SECTION_NAMES 0
 
 #include "pe-mips.c"
 
Index: bfd/pei-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/pei-ppc.c,v
retrieving revision 1.9
diff -p -u -r1.9 pei-ppc.c
--- bfd/pei-ppc.c	18 Jul 2008 11:30:22 -0000	1.9
+++ bfd/pei-ppc.c	12 Feb 2009 22:13:13 -0000
@@ -1,5 +1,5 @@
 /* BFD back-end for PowerPC PE IMAGE COFF files.
-   Copyright 1995, 1996, 1999, 2007, 2008  Free Software Foundation, Inc.
+   Copyright 1995, 1996, 1999, 2007, 2008, 2009  Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -35,7 +35,8 @@
 #define COFF_IMAGE_WITH_PE
 #define COFF_WITH_PE
 
-#define COFF_LONG_SECTION_NAMES
+/* Long section names not allowed in executable images, only object files.  */
+#define COFF_LONG_SECTION_NAMES 0
 
 /* FIXME: Verify PCRELOFFSET is always false */
 
Index: bfd/pei-sh.c
===================================================================
RCS file: /cvs/src/src/bfd/pei-sh.c,v
retrieving revision 1.8
diff -p -u -r1.8 pei-sh.c
--- bfd/pei-sh.c	3 Jul 2007 14:26:42 -0000	1.8
+++ bfd/pei-sh.c	12 Feb 2009 22:13:13 -0000
@@ -1,5 +1,5 @@
 /* BFD back-end for SH PE IMAGE COFF files.
-   Copyright 1995, 2000, 2001, 2002, 2007 Free Software Foundation, Inc.
+   Copyright 1995, 2000, 2001, 2002, 2007, 2009 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -28,7 +28,8 @@
 #define COFF_WITH_PE
 #define PCRELOFFSET TRUE
 #define TARGET_UNDERSCORE '_'
-#define COFF_LONG_SECTION_NAMES
+/* Long section names not allowed in executable images, only object files.  */
+#define COFF_LONG_SECTION_NAMES 0
 
 #include "coff-sh.c"
 
Index: bfd/pei-x86_64.c
===================================================================
RCS file: /cvs/src/src/bfd/pei-x86_64.c,v
retrieving revision 1.3
diff -p -u -r1.3 pei-x86_64.c
--- bfd/pei-x86_64.c	3 Jul 2007 14:26:42 -0000	1.3
+++ bfd/pei-x86_64.c	12 Feb 2009 22:13:13 -0000
@@ -1,5 +1,5 @@
 /* BFD back-end for Intel 386 PE IMAGE COFF files.
-   Copyright 2006, 2007 Free Software Foundation, Inc.
+   Copyright 2006, 2007, 2009 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -30,7 +30,8 @@
 #define COFF_WITH_pex64
 #define PCRELOFFSET 		TRUE
 #define TARGET_UNDERSCORE 	'_'
-#define COFF_LONG_SECTION_NAMES
+/* Long section names not allowed in executable images, only object files.  */
+#define COFF_LONG_SECTION_NAMES 0
 #define COFF_SUPPORT_GNU_LINKONCE
 #define COFF_LONG_FILENAMES
 
Index: bfd/ticoff.h
===================================================================
RCS file: /cvs/src/src/bfd/ticoff.h,v
retrieving revision 1.5
diff -p -u -r1.5 ticoff.h
--- bfd/ticoff.h	3 Jul 2007 14:26:42 -0000	1.5
+++ bfd/ticoff.h	12 Feb 2009 22:13:13 -0000
@@ -1,4 +1,4 @@
-/* Copyright 2002, 2007 Free Software Foundation, Inc.
+/* Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -68,7 +68,7 @@ ticoff_bfd_is_local_label_name (abfd, na
 #include "coffcode.h"
 
 /* COFF0 differs in file/section header size and relocation entry size.  */
-static const bfd_coff_backend_data ticoff0_swap_table = 
+static bfd_coff_backend_data ticoff0_swap_table = 
 {
   coff_SWAP_aux_in, coff_SWAP_sym_in, coff_SWAP_lineno_in,
   coff_SWAP_aux_out, coff_SWAP_sym_out,
@@ -81,10 +81,7 @@ static const bfd_coff_backend_data ticof
 #else
   FALSE,
 #endif
-#ifdef COFF_LONG_SECTION_NAMES
-  TRUE,
-#else
-  FALSE,
+  COFF_DEFAULT_LONG_SECTION_NAMES,
 #endif
   COFF_DEFAULT_SECTION_ALIGNMENT_POWER,
   coff_SWAP_filehdr_in, coff_SWAP_aouthdr_in, coff_SWAP_scnhdr_in,
@@ -99,7 +96,7 @@ static const bfd_coff_backend_data ticof
 };
 
 /* COFF1 differs in section header size.  */
-static const bfd_coff_backend_data ticoff1_swap_table = 
+static bfd_coff_backend_data ticoff1_swap_table = 
 {
   coff_SWAP_aux_in, coff_SWAP_sym_in, coff_SWAP_lineno_in,
   coff_SWAP_aux_out, coff_SWAP_sym_out,
@@ -112,11 +109,7 @@ static const bfd_coff_backend_data ticof
 #else
   FALSE,
 #endif
-#ifdef COFF_LONG_SECTION_NAMES
-  TRUE,
-#else
-  FALSE,
-#endif
+  COFF_DEFAULT_LONG_SECTION_NAMES,
   COFF_DEFAULT_SECTION_ALIGNMENT_POWER,
   coff_SWAP_filehdr_in, coff_SWAP_aouthdr_in, coff_SWAP_scnhdr_in,
   coff_SWAP_reloc_in, ticoff1_bad_format_hook, coff_set_arch_mach_hook,
Index: ld/NEWS
===================================================================
RCS file: /cvs/src/src/ld/NEWS,v
retrieving revision 1.96
diff -p -u -r1.96 NEWS
--- ld/NEWS	3 Feb 2009 15:56:59 -0000	1.96
+++ ld/NEWS	12 Feb 2009 22:13:14 -0000
@@ -1,5 +1,10 @@
 -*- text -*-
 
+* PE targets no longer make use of the long section names PE extension to
+  the COFF format when generating executable images, by default.  The old
+  (slightly non-conformant) behaviour can still be invoked by using the
+  new '--enable-long-section-names' command-line option.
+
 * --as-needed now links in a dynamic library if it satisfies undefined
   symbols in regular objects, or in other dynamic libraries.  In the
   latter case the library is not linked if it is found in a DT_NEEDED
Index: ld/ld.texinfo
===================================================================
RCS file: /cvs/src/src/ld/ld.texinfo,v
retrieving revision 1.230
diff -p -u -r1.230 ld.texinfo
--- ld/ld.texinfo	4 Feb 2009 09:13:22 -0000	1.230
+++ ld/ld.texinfo	12 Feb 2009 22:13:15 -0000
@@ -2098,6 +2098,22 @@ Create a DLL instead of a regular execut
 file.
 [This option is specific to the i386 PE targeted port of the linker]
 
+@kindex --enable-long-section-names
+@kindex --disable-long-section-names
+@item --enable-long-section-names
+@itemx --disable-long-section-names
+The PE variants of the Coff object format add an extension that permits
+the use of section names longer than eight characters, the normal limit
+for Coff.  By default, these names are only allowed in object files, as
+fully-linked executable images do not carry the Coff string table required
+to support the longer names.  As a GNU extension, it is possible to
+allow their use in executable images as well, or to (probably pointlessly!)
+disallow it in object files, by using these two options.  Executable images
+generated with these long section names are slightly non-standard, carrying
+as they do a string table, and may generate confusing output when examined
+with non-GNU PE-aware tools, such as file viewers and dumpers.
+[This option is valid for all PE targeted ports of the linker]
+
 @kindex --enable-stdcall-fixup
 @kindex --disable-stdcall-fixup
 @item --enable-stdcall-fixup
Index: ld/pe-dll.c
===================================================================
RCS file: /cvs/src/src/ld/pe-dll.c,v
retrieving revision 1.116
diff -p -u -r1.116 pe-dll.c
--- ld/pe-dll.c	26 Jan 2009 10:29:11 -0000	1.116
+++ ld/pe-dll.c	12 Feb 2009 22:13:16 -0000
@@ -1,6 +1,6 @@
 /* Routines to help build PEI-format DLLs (Win32 etc)
    Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
-   2008 Free Software Foundation, Inc.
+   2008, 2009 Free Software Foundation, Inc.
    Written by DJ Delorie <dj@cygnus.com>
 
    This file is part of the GNU Binutils.
@@ -156,6 +156,7 @@ int pe_dll_warn_dup_exports = 0;
 int pe_dll_compat_implib = 0;
 int pe_dll_extra_pe_debug = 0;
 int pe_use_nul_prefixed_import_tables = 0;
+int pe_use_coff_long_section_names = -1;
 
 /* Static variables and types.  */
 
@@ -3033,6 +3034,15 @@ pe_implied_import_dll (const char *filen
   return TRUE;
 }
 
+static void
+pe_output_file_set_long_section_names (bfd *abfd)
+{
+  if (pe_use_coff_long_section_names < 0)
+    return;
+  if (!bfd_coff_set_long_section_names (abfd, pe_use_coff_long_section_names))
+    einfo (_("%XError: can't use long section names on this arch\n"));
+}
+
 /* These are the main functions, called from the emulation.  The first
    is called after the bfds are read, so we can guess at how much space
    we need.  The second is called after everything is placed, so we
@@ -3042,6 +3052,7 @@ void
 pe_dll_build_sections (bfd *abfd, struct bfd_link_info *info)
 {
   pe_dll_id_target (bfd_get_target (abfd));
+  pe_output_file_set_long_section_names (abfd);
   process_def_file (abfd, info);
 
   if (pe_def_file->num_exports == 0 && !info->shared)
@@ -3049,19 +3060,23 @@ pe_dll_build_sections (bfd *abfd, struct
 
   generate_edata (abfd, info);
   build_filler_bfd (1);
+  pe_output_file_set_long_section_names (filler_bfd);
 }
 
 void
 pe_exe_build_sections (bfd *abfd, struct bfd_link_info *info ATTRIBUTE_UNUSED)
 {
   pe_dll_id_target (bfd_get_target (abfd));
+  pe_output_file_set_long_section_names (abfd);
   build_filler_bfd (0);
+  pe_output_file_set_long_section_names (filler_bfd);
 }
 
 void
 pe_dll_fill_sections (bfd *abfd, struct bfd_link_info *info)
 {
   pe_dll_id_target (bfd_get_target (abfd));
+  pe_output_file_set_long_section_names (abfd);
   image_base = pe_data (abfd)->pe_opthdr.ImageBase;
 
   generate_reloc (abfd, info);
@@ -3093,6 +3108,7 @@ void
 pe_exe_fill_sections (bfd *abfd, struct bfd_link_info *info)
 {
   pe_dll_id_target (bfd_get_target (abfd));
+  pe_output_file_set_long_section_names (abfd);
   image_base = pe_data (abfd)->pe_opthdr.ImageBase;
 
   generate_reloc (abfd, info);
Index: ld/pe-dll.h
===================================================================
RCS file: /cvs/src/src/ld/pe-dll.h,v
retrieving revision 1.19
diff -p -u -r1.19 pe-dll.h
--- ld/pe-dll.h	8 Jan 2009 13:28:48 -0000	1.19
+++ ld/pe-dll.h	12 Feb 2009 22:13:16 -0000
@@ -1,5 +1,5 @@
 /* pe-dll.h: Header file for routines used to build Windows DLLs.
-   Copyright 1999, 2000, 2001, 2002, 2003, 2007
+   Copyright 1999, 2000, 2001, 2002, 2003, 2007, 2009
    Free Software Foundation, Inc.
 
    This file is part of the GNU Binutils.
@@ -36,6 +36,7 @@ extern int pe_dll_warn_dup_exports;
 extern int pe_dll_compat_implib;
 extern int pe_dll_extra_pe_debug;
 extern int pe_use_nul_prefixed_import_tables;
+extern int pe_use_coff_long_section_names;
 
 typedef enum { EXCLUDESYMS, EXCLUDELIBS, EXCLUDEFORIMPLIB } exclude_type;
 
Index: ld/pep-dll.c
===================================================================
RCS file: /cvs/src/src/ld/pep-dll.c,v
retrieving revision 1.4
diff -p -u -r1.4 pep-dll.c
--- ld/pep-dll.c	8 Jan 2009 13:28:48 -0000	1.4
+++ ld/pep-dll.c	12 Feb 2009 22:13:16 -0000
@@ -1,5 +1,5 @@
 /* Routines to help build PEPI-format DLLs (Win64 etc)
-   Copyright 2006, 2007 Free Software Foundation, Inc.
+   Copyright 2006, 2007, 2009 Free Software Foundation, Inc.
    Written by Kai Tietz, OneVision Software GmbH&CoKg.
 
    This file is part of the GNU Binutils.
@@ -34,7 +34,9 @@
 #define pe_dll_stdcall_aliases      pep_dll_stdcall_aliases
 #define pe_dll_warn_dup_exports     pep_dll_warn_dup_exports
 #define pe_use_nul_prefixed_import_tables \
-  pep_use_nul_prefixed_import_tables
+				    pep_use_nul_prefixed_import_tables
+#define pe_use_coff_long_section_names \
+				    pep_use_coff_long_section_names
 
 /* External globals.  */
 #define pe_data_import_dll          pep_data_import_dll
Index: ld/pep-dll.h
===================================================================
RCS file: /cvs/src/src/ld/pep-dll.h,v
retrieving revision 1.7
diff -p -u -r1.7 pep-dll.h
--- ld/pep-dll.h	8 Jan 2009 13:28:48 -0000	1.7
+++ ld/pep-dll.h	12 Feb 2009 22:13:16 -0000
@@ -1,5 +1,5 @@
 /* pep-dll.h: Header file for routines used to build Windows DLLs.
-   Copyright 2006, 2007 Free Software Foundation, Inc.
+   Copyright 2006, 2007, 2009 Free Software Foundation, Inc.
    Written by Kai Tietz, OneVision Software GmbH&CoKg.
 
    This file is part of the GNU Binutils.
@@ -36,6 +36,7 @@ extern int pep_dll_warn_dup_exports;
 extern int pep_dll_compat_implib;
 extern int pep_dll_extra_pe_debug;
 extern int pep_use_nul_prefixed_import_tables;
+extern int pep_use_coff_long_section_names;
 
 typedef enum { EXCLUDESYMS, EXCLUDELIBS, EXCLUDEFORIMPLIB } exclude_type;
 
Index: ld/emultempl/pe.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/pe.em,v
retrieving revision 1.141
diff -p -u -r1.141 pe.em
--- ld/emultempl/pe.em	8 Jan 2009 13:28:48 -0000	1.141
+++ ld/emultempl/pe.em	12 Feb 2009 22:13:16 -0000
@@ -10,7 +10,7 @@ rm -f e${EMULATION_NAME}.c
 (echo;echo;echo;echo;echo)>e${EMULATION_NAME}.c # there, now line numbers match ;-)
 fragment <<EOF
 /* Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-   2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+   2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
 
    This file is part of the GNU Binutils.
 
@@ -210,7 +210,11 @@ gld_${EMULATION_NAME}_before_parse (void
 #define OPTION_EXCLUDE_MODULES_FOR_IMPLIB \
 					(OPTION_DLL_ENABLE_RUNTIME_PSEUDO_RELOC_V2 + 1)
 #define OPTION_USE_NUL_PREFIXED_IMPORT_TABLES \
-  (OPTION_EXCLUDE_MODULES_FOR_IMPLIB + 1)
+					(OPTION_EXCLUDE_MODULES_FOR_IMPLIB + 1)
+#define OPTION_ENABLE_LONG_SECTION_NAMES \
+					(OPTION_USE_NUL_PREFIXED_IMPORT_TABLES + 1)
+#define OPTION_DISABLE_LONG_SECTION_NAMES \
+					(OPTION_ENABLE_LONG_SECTION_NAMES + 1)
 
 static void
 gld${EMULATION_NAME}_add_options
@@ -270,6 +274,8 @@ gld${EMULATION_NAME}_add_options
     {"enable-runtime-pseudo-reloc-v2", no_argument, NULL, OPTION_DLL_ENABLE_RUNTIME_PSEUDO_RELOC_V2},
 #endif
     {"large-address-aware", no_argument, NULL, OPTION_LARGE_ADDRESS_AWARE},
+    {"enable-long-section-names", no_argument, NULL, OPTION_ENABLE_LONG_SECTION_NAMES},
+    {"disable-long-section-names", no_argument, NULL, OPTION_DISABLE_LONG_SECTION_NAMES},
     {NULL, no_argument, NULL, 0}
   };
 
@@ -377,6 +383,10 @@ gld_${EMULATION_NAME}_list_options (FILE
 #endif
   fprintf (file, _("  --large-address-aware              Executable supports virtual addresses\n\
                                        greater than 2 gigabytes\n"));
+  fprintf (file, _("  --enable-long-section-names        Use long COFF section names even in\n\
+                                       executable image files\n"));
+  fprintf (file, _("  --disable-long-section-names       Never use long COFF section names, even\n\
+                                       in object files\n"));
 }
 
 
@@ -677,6 +687,12 @@ gld${EMULATION_NAME}_handle_option (int 
     case OPTION_LARGE_ADDRESS_AWARE:
       real_flags |= IMAGE_FILE_LARGE_ADDRESS_AWARE;
       break;
+    case OPTION_ENABLE_LONG_SECTION_NAMES:
+      pe_use_coff_long_section_names = 1;
+      break;
+    case OPTION_DISABLE_LONG_SECTION_NAMES:
+      pe_use_coff_long_section_names = 0;
+      break;
     }
   return TRUE;
 }
Index: ld/emultempl/pep.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/pep.em,v
retrieving revision 1.20
diff -p -u -r1.20 pep.em
--- ld/emultempl/pep.em	8 Jan 2009 13:28:48 -0000	1.20
+++ ld/emultempl/pep.em	12 Feb 2009 22:13:16 -0000
@@ -9,7 +9,7 @@ fi
 rm -f e${EMULATION_NAME}.c
 (echo;echo;echo;echo;echo)>e${EMULATION_NAME}.c # there, now line numbers match ;-)
 fragment <<EOF
-/* Copyright 2006, 2007, 2008 Free Software Foundation, Inc.
+/* Copyright 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
    Written by Kai Tietz, OneVision Software GmbH&CoKg.
 
    This file is part of the GNU Binutils.
@@ -177,7 +177,9 @@ enum options
   OPTION_DLL_ENABLE_RUNTIME_PSEUDO_RELOC_V1,
   OPTION_DLL_ENABLE_RUNTIME_PSEUDO_RELOC_V2,
   OPTION_EXCLUDE_MODULES_FOR_IMPLIB,
-  OPTION_USE_NUL_PREFIXED_IMPORT_TABLES
+  OPTION_USE_NUL_PREFIXED_IMPORT_TABLES,
+  OPTION_ENABLE_LONG_SECTION_NAMES,
+  OPTION_DISABLE_LONG_SECTION_NAMES
 };
 
 static void
@@ -240,6 +242,8 @@ gld${EMULATION_NAME}_add_options
     {"enable-runtime-pseudo-reloc-v1", no_argument, NULL, OPTION_DLL_ENABLE_RUNTIME_PSEUDO_RELOC_V1},
     {"enable-runtime-pseudo-reloc-v2", no_argument, NULL, OPTION_DLL_ENABLE_RUNTIME_PSEUDO_RELOC_V2},
 #endif
+    {"enable-long-section-names", no_argument, NULL, OPTION_ENABLE_LONG_SECTION_NAMES},
+    {"disable-long-section-names", no_argument, NULL, OPTION_DISABLE_LONG_SECTION_NAMES},
     {NULL, no_argument, NULL, 0}
   };
 
@@ -338,6 +342,10 @@ gld_${EMULATION_NAME}_list_options (FILE
                                        auto-imported DATA.\n"));
   fprintf (file, _("  --enable-extra-pep-debug            Enable verbose debug output when building\n\
                                        or linking to DLLs (esp. auto-import)\n"));
+  fprintf (file, _("  --enable-long-section-names        Use long COFF section names even in\n\
+                                       executable image files\n"));
+  fprintf (file, _("  --disable-long-section-names       Never use long COFF section names, even\n\
+                                       in object files\n"));
 #endif
 }
 
@@ -633,6 +641,12 @@ gld${EMULATION_NAME}_handle_option (int 
       pep_dll_extra_pe_debug = 1;
       break;
 #endif
+    case OPTION_ENABLE_LONG_SECTION_NAMES:
+      pep_use_coff_long_section_names = 1;
+      break;
+    case OPTION_DISABLE_LONG_SECTION_NAMES:
+      pep_use_coff_long_section_names = 0;
+      break;
     }
   return TRUE;
 }
Index: ld/testsuite/ld-pe/longsecn-1.d
===================================================================
RCS file: ld/testsuite/ld-pe/longsecn-1.d
diff -N ld/testsuite/ld-pe/longsecn-1.d
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ld/testsuite/ld-pe/longsecn-1.d	12 Feb 2009 22:13:17 -0000
@@ -0,0 +1,24 @@
+#name: PE-COFF Long section names (disabled)
+#ld: --disable-long-section-names
+#objdump: -h
+#source: longsecn.s
+
+.*:     file format .*
+
+Sections:
+Idx Name          Size      VMA +LMA +File off  Algn
+  0 \.text         [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, READONLY, CODE
+  1 \.text\.ve      [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, READONLY, CODE, DATA
+  2 \.data         [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, DATA
+  3 \.rodata       [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, DATA
+  4 \.data\.ve      [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, DATA
+  5 \.rodata\.      [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, DATA
+  6 \.idata        [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, DATA
+
Index: ld/testsuite/ld-pe/longsecn-2.d
===================================================================
RCS file: ld/testsuite/ld-pe/longsecn-2.d
diff -N ld/testsuite/ld-pe/longsecn-2.d
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ld/testsuite/ld-pe/longsecn-2.d	12 Feb 2009 22:13:17 -0000
@@ -0,0 +1,23 @@
+#name: PE-COFF Long section names (enabled)
+#ld: --enable-long-section-names
+#objdump: -h
+#source: longsecn.s
+
+.*:     file format .*
+
+Sections:
+Idx Name          Size      VMA +LMA +File off  Algn
+  0 \.text         [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, READONLY, CODE
+  1 \.text\.very\.long\.section\.name [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, READONLY, CODE, DATA
+  2 \.data         [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, DATA
+  3 \.rodata       [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, DATA
+  4 \.data\.very\.long\.section [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, DATA
+  5 \.rodata\.very.long\.section [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, DATA
+  6 \.idata        [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, DATA
Index: ld/testsuite/ld-pe/longsecn-3.d
===================================================================
RCS file: ld/testsuite/ld-pe/longsecn-3.d
diff -N ld/testsuite/ld-pe/longsecn-3.d
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ld/testsuite/ld-pe/longsecn-3.d	12 Feb 2009 22:13:17 -0000
@@ -0,0 +1,43 @@
+#name: PE-COFF Long section names in objects (default)
+#ld:  -r
+#objdump: -h
+#source: longsecn.s
+
+.*:     file format .*
+
+Sections:
+Idx Name          Size      VMA +LMA +File off  Algn
+  0 \.text         [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, READONLY, CODE
+  1 \.text\.very\.long\.section\.name [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, READONLY, CODE, DATA
+  2 \.data         [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, DATA
+  3 \.data\$1       [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, DATA
+  4 \.rodata\$1     [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, DATA
+  5 \.data\$123     [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, DATA
+  6 \.rodata\$123   [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, DATA
+  7 \.data\$123456789 [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, DATA
+  8 \.rodata\$123456789 [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, DATA
+  9 \.data\.very\.long\.section [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, DATA
+ 10 \.rodata\.very\.long\.section [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, DATA
+ 11 \.data\.very\.long\.section\$1 [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, DATA
+ 12 \.rodata\.very\.long\.section\$1 [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, DATA
+ 13 \.data\.very\.long\.section\$1234 [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, DATA
+ 14 \.rodata\.very\.long\.section\$1234 [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, DATA
+ 15 \.bss          [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  ALLOC
+ 16 \.reloc        [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, READONLY, DATA
Index: ld/testsuite/ld-pe/longsecn-4.d
===================================================================
RCS file: ld/testsuite/ld-pe/longsecn-4.d
diff -N ld/testsuite/ld-pe/longsecn-4.d
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ld/testsuite/ld-pe/longsecn-4.d	12 Feb 2009 22:13:17 -0000
@@ -0,0 +1,43 @@
+#name: PE-COFF Long section names in objects (disabled)
+#ld:  --disable-long-section-names -r
+#objdump: -h
+#source: longsecn.s
+
+.*:     file format .*
+
+Sections:
+Idx Name          Size      VMA +LMA +File off  Algn
+  0 \.text         [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, READONLY, CODE
+  1 \.text\.ve      [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, READONLY, CODE, DATA
+  2 \.data         [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, DATA
+  3 \.data\$1       [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, DATA
+  4 \.rodata\$      [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, DATA
+  5 \.data\$12      [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, DATA
+  6 \.rodata\$      [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, DATA
+  7 \.data\$12      [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, DATA
+  8 \.rodata\$      [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, DATA
+  9 \.data\.ve      [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, DATA
+ 10 \.rodata\.      [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, DATA
+ 11 \.data\.ve      [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, DATA
+ 12 \.rodata\.      [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, DATA
+ 13 \.data\.ve      [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, DATA
+ 14 \.rodata\.      [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, DATA
+ 15 \.bss          [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  ALLOC
+ 16 \.reloc        [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, READONLY, DATA
Index: ld/testsuite/ld-pe/longsecn-5.d
===================================================================
RCS file: ld/testsuite/ld-pe/longsecn-5.d
diff -N ld/testsuite/ld-pe/longsecn-5.d
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ld/testsuite/ld-pe/longsecn-5.d	12 Feb 2009 22:13:17 -0000
@@ -0,0 +1,43 @@
+#name: PE-COFF Long section names in objects (enabled)
+#ld:  --enable-long-section-names -r
+#objdump: -h
+#source: longsecn.s
+
+.*:     file format .*
+
+Sections:
+Idx Name          Size      VMA +LMA +File off  Algn
+  0 \.text         [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, READONLY, CODE
+  1 \.text\.very\.long\.section\.name [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, READONLY, CODE, DATA
+  2 \.data         [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, DATA
+  3 \.data\$1       [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, DATA
+  4 \.rodata\$1     [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, DATA
+  5 \.data\$123     [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, DATA
+  6 \.rodata\$123   [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, DATA
+  7 \.data\$123456789 [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, DATA
+  8 \.rodata\$123456789 [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, DATA
+  9 \.data\.very\.long\.section [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, DATA
+ 10 \.rodata\.very\.long\.section [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, DATA
+ 11 \.data\.very\.long\.section\$1 [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, DATA
+ 12 \.rodata\.very\.long\.section\$1 [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, DATA
+ 13 \.data\.very\.long\.section\$1234 [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, DATA
+ 14 \.rodata\.very\.long\.section\$1234 [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, DATA
+ 15 \.bss          [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  ALLOC
+ 16 \.reloc        [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, READONLY, DATA
Index: ld/testsuite/ld-pe/longsecn.d
===================================================================
RCS file: ld/testsuite/ld-pe/longsecn.d
diff -N ld/testsuite/ld-pe/longsecn.d
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ld/testsuite/ld-pe/longsecn.d	12 Feb 2009 22:13:17 -0000
@@ -0,0 +1,24 @@
+#name: PE-COFF Long section names (default)
+#ld:
+#objdump: -h
+#source: longsecn.s
+
+.*:     file format .*
+
+Sections:
+Idx Name          Size      VMA +LMA +File off  Algn
+  0 \.text         [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, READONLY, CODE
+  1 \.text\.ve      [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, READONLY, CODE, DATA
+  2 \.data         [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, DATA
+  3 \.rodata       [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, DATA
+  4 \.data\.ve      [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, DATA
+  5 \.rodata\.      [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, DATA
+  6 \.idata        [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+                  CONTENTS, ALLOC, LOAD, DATA
+
Index: ld/testsuite/ld-pe/longsecn.exp
===================================================================
RCS file: ld/testsuite/ld-pe/longsecn.exp
diff -N ld/testsuite/ld-pe/longsecn.exp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ld/testsuite/ld-pe/longsecn.exp	12 Feb 2009 22:13:17 -0000
@@ -0,0 +1,35 @@
+# Expect script for COFF long section name tests
+#   Copyright 2009
+#   Free Software Foundation, Inc.
+#
+# This file is part of the GNU Binutils.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+# MA 02110-1301, USA.
+#
+ 
+# This test can only be run on PE/COFF platforms.
+if {![is_pecoff_format]} {
+    return
+}
+
+run_dump_test "longsecn"
+
+run_dump_test "longsecn-1"
+run_dump_test "longsecn-2"
+run_dump_test "longsecn-3"
+run_dump_test "longsecn-4"
+run_dump_test "longsecn-5"
+
Index: ld/testsuite/ld-pe/longsecn.s
===================================================================
RCS file: ld/testsuite/ld-pe/longsecn.s
diff -N ld/testsuite/ld-pe/longsecn.s
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ld/testsuite/ld-pe/longsecn.s	12 Feb 2009 22:13:17 -0000
@@ -0,0 +1,42 @@
+	.text
+	.global _start
+_start:
+	.byte 1
+	.global data
+	.data
+data:
+	.byte 2
+
+	.section .text.very.long.section.name,"rx"
+vls:
+	.byte 3
+
+	.section .data$1,"wd"
+	.byte 4
+	.section .rodata$1,"rd"
+	.byte 5
+
+	.section .data$123,"wd"
+	.byte 4
+	.section .rodata$123,"rd"
+	.byte 5
+	.section .data$123456789,"wd"
+	.byte 4
+	.section .rodata$123456789,"rd"
+	.byte 5
+
+	.section .data.very.long.section,"wd"
+	.byte 6
+	.section .rodata.very.long.section,"rd"
+	.byte 7
+
+	.section .data.very.long.section$1,"wd"
+	.byte 6
+	.section .rodata.very.long.section$1,"rd"
+	.byte 7
+	.section .data.very.long.section$1234,"wd"
+	.byte 6
+	.section .rodata.very.long.section$1234,"rd"
+	.byte 7
+
+	.end

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