diff options
49 files changed, 710 insertions, 110 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 8111592..fad6a18 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,66 @@ +2009-18-02 Dave Korn <dave.korn.cygwin@gmail.com> + + * 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 empty 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. + 2009-02-18 Christophe Lyon <christophe.lyon@st.com> * elf32-arm.c (arm_build_one_stub): Fix relocation target for pic diff --git a/bfd/coff-alpha.c b/bfd/coff-alpha.c index 98bed84..efe2dd3 100644 --- a/bfd/coff-alpha.c +++ b/bfd/coff-alpha.c @@ -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 alpha_ecoff_backend_data = (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, diff --git a/bfd/coff-mips.c b/bfd/coff-mips.c index 929b3c1..f82c52d 100644 --- a/bfd/coff-mips.c +++ b/bfd/coff-mips.c @@ -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 mips_ecoff_backend_data = (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, diff --git a/bfd/coff-rs6000.c b/bfd/coff-rs6000.c index 17c6907..1db66e7 100644 --- a/bfd/coff-rs6000.c +++ b/bfd/coff-rs6000.c @@ -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_rec bfd_xcoff_backend_data = 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_rec bfd_pmac_xcoff_backend_data = 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 */ diff --git a/bfd/coff-sh.c b/bfd/coff-sh.c index 1a5d63d..05d99d4 100644 --- a/bfd/coff-sh.c +++ b/bfd/coff-sh.c @@ -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, section) /* 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_coff_small_swap_table = #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, diff --git a/bfd/coff64-rs6000.c b/bfd/coff64-rs6000.c index ee797ed..776b6a2 100644 --- a/bfd/coff64-rs6000.c +++ b/bfd/coff64-rs6000.c @@ -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_rec bfd_xcoff_backend_data = 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_rec bfd_xcoff_aix5_backend_data = 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 */ diff --git a/bfd/coffcode.h b/bfd/coffcode.h index db0b2e9..cfa1a40 100644 --- a/bfd/coffcode.h +++ b/bfd/coffcode.h @@ -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. @@ -109,6 +109,60 @@ SUBSUBSECTION target. SUBSUBSECTION + 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 Each flavour of coff supported in BFD has its own header file @@ -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_hook /* 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 coff symbol table parts: . 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 symbol table parts: . (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 ATTRIBUTE_UNUSED, #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_coff_std_swap_table ATTRIBUTE_UNUSED = #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_coff_std_swap_table ATTRIBUTE_UNUSED = #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 ticoff0_swap_table = #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 ticoff0_swap_table = #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 ticoff1_swap_table = #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, diff --git a/bfd/coffgen.c b/bfd/coffgen.c index 469cdfa..0a1c97c 100644 --- a/bfd/coffgen.c +++ b/bfd/coffgen.c @@ -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]; diff --git a/bfd/ecoff.c b/bfd/ecoff.c index a31bdb9..a78273e 100644 --- a/bfd/ecoff.c +++ b/bfd/ecoff.c @@ -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, void * filehdr) 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. */ diff --git a/bfd/efi-app-ia32.c b/bfd/efi-app-ia32.c index e8eef5d..aaa80c5 100644 --- a/bfd/efi-app-ia32.c +++ b/bfd/efi-app-ia32.c @@ -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 diff --git a/bfd/efi-app-ia64.c b/bfd/efi-app-ia64.c index 67e137d..449c4c7 100644 --- a/bfd/efi-app-ia64.c +++ b/bfd/efi-app-ia64.c @@ -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 diff --git a/bfd/efi-app-x86_64.c b/bfd/efi-app-x86_64.c index 5d60cdf..d2a04f3 100644 --- a/bfd/efi-app-x86_64.c +++ b/bfd/efi-app-x86_64.c @@ -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 diff --git a/bfd/efi-bsdrv-ia32.c b/bfd/efi-bsdrv-ia32.c index 2825b11..112b2b4 100644 --- a/bfd/efi-bsdrv-ia32.c +++ b/bfd/efi-bsdrv-ia32.c @@ -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 diff --git a/bfd/efi-bsdrv-ia64.c b/bfd/efi-bsdrv-ia64.c index ed4f6ca..f08c568 100644 --- a/bfd/efi-bsdrv-ia64.c +++ b/bfd/efi-bsdrv-ia64.c @@ -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 diff --git a/bfd/efi-bsdrv-x86_64.c b/bfd/efi-bsdrv-x86_64.c index def32f1..dfe00f4 100644 --- a/bfd/efi-bsdrv-x86_64.c +++ b/bfd/efi-bsdrv-x86_64.c @@ -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 diff --git a/bfd/efi-rtdrv-ia32.c b/bfd/efi-rtdrv-ia32.c index aa47181..b127cbc 100644 --- a/bfd/efi-rtdrv-ia32.c +++ b/bfd/efi-rtdrv-ia32.c @@ -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 diff --git a/bfd/efi-rtdrv-ia64.c b/bfd/efi-rtdrv-ia64.c index 65bc5ee..d93416d 100644 --- a/bfd/efi-rtdrv-ia64.c +++ b/bfd/efi-rtdrv-ia64.c @@ -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 diff --git a/bfd/efi-rtdrv-x86_64.c b/bfd/efi-rtdrv-x86_64.c index 8f7b5fc..c66b63c 100644 --- a/bfd/efi-rtdrv-x86_64.c +++ b/bfd/efi-rtdrv-x86_64.c @@ -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 diff --git a/bfd/libcoff-in.h b/bfd/libcoff-in.h index 8f11df4..8c65158 100644 --- a/bfd/libcoff-in.h +++ b/bfd/libcoff-in.h @@ -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_relocate_section (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 diff --git a/bfd/libcoff.h b/bfd/libcoff.h index 9d3b33f..c594d4b 100644 --- a/bfd/libcoff.h +++ b/bfd/libcoff.h @@ -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_relocate_section (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) \ diff --git a/bfd/libecoff.h b/bfd/libecoff.h index 443b9a7..0e7ea85 100644 --- a/bfd/libecoff.h +++ b/bfd/libecoff.h @@ -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 (bfd *, void *, void *); ((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 *); diff --git a/bfd/libxcoff.h b/bfd/libxcoff.h index c2f0d1e..bd70636 100644 --- a/bfd/libxcoff.h +++ b/bfd/libxcoff.h @@ -223,6 +223,8 @@ extern bfd_boolean (*xcoff_calculate_relocation[XCOFF_MAX_CALCULATE_RELOCATION]) 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); diff --git a/bfd/pe-mips.c b/bfd/pe-mips.c index f28a2c2..31b87f4 100644 --- a/bfd/pe-mips.c +++ b/bfd/pe-mips.c @@ -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" diff --git a/bfd/pei-arm.c b/bfd/pei-arm.c index 0b56bcb..f1a7c55 100644 --- a/bfd/pei-arm.c +++ b/bfd/pei-arm.c @@ -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"), \ diff --git a/bfd/pei-i386.c b/bfd/pei-i386.c index 35e9f69..bea7aea 100644 --- a/bfd/pei-i386.c +++ b/bfd/pei-i386.c @@ -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 diff --git a/bfd/pei-mcore.c b/bfd/pei-mcore.c index 209c9fa..f81062d 100644 --- a/bfd/pei-mcore.c +++ b/bfd/pei-mcore.c @@ -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 diff --git a/bfd/pei-mips.c b/bfd/pei-mips.c index 809d754..af6ed22 100644 --- a/bfd/pei-mips.c +++ b/bfd/pei-mips.c @@ -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" diff --git a/bfd/pei-ppc.c b/bfd/pei-ppc.c index 420e33e..41a8d2d 100644 --- a/bfd/pei-ppc.c +++ b/bfd/pei-ppc.c @@ -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 */ diff --git a/bfd/pei-sh.c b/bfd/pei-sh.c index 56c9b18..b5e3952 100644 --- a/bfd/pei-sh.c +++ b/bfd/pei-sh.c @@ -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" diff --git a/bfd/pei-x86_64.c b/bfd/pei-x86_64.c index f4dd3e1..f62e697 100644 --- a/bfd/pei-x86_64.c +++ b/bfd/pei-x86_64.c @@ -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 diff --git a/bfd/ticoff.h b/bfd/ticoff.h index 50f0577..7002ed9 100644 --- a/bfd/ticoff.h +++ b/bfd/ticoff.h @@ -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, name) #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 ticoff0_swap_table = #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 ticoff0_swap_table = }; /* 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 ticoff1_swap_table = #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, diff --git a/ld/ChangeLog b/ld/ChangeLog index d5a1288..2a21e7f 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,35 @@ +2009-18-02 Dave Korn <dave.korn.cygwin@gmail.com> + + * 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. + (pe_output_file_set_long_section_names): Add prototype. + * pep-dll.c (pe_use_coff_long_section_names): Define pep_ alias. + (pe_output_file_set_long_section_names): Likewise. + * pep-dll.h (pep_use_coff_long_section_names): Declare extern. + (pep_output_file_set_long_section_names): Add prototype. + * 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. + (gld_${EMULATION_NAME}_after_open): En/disable long section names + for main output bfd by calling pe_output_file_set_long_section_names. + * 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. + (gld_${EMULATION_NAME}_after_open): En/disable long section names + for main output bfd by calling pep_output_file_set_long_section_names. + 2009-02-16 Dave Korn <dave.korn.cygwin@gmail.com> * emultempl/pe.em (gld_${EMULATION_NAME}_after_open): Don't emit @@ -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 diff --git a/ld/emultempl/pe.em b/ld/emultempl/pe.em index 79f383a..5478435 100644 --- a/ld/emultempl/pe.em +++ b/ld/emultempl/pe.em @@ -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 *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 optc) 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; } @@ -1046,6 +1062,7 @@ gld_${EMULATION_NAME}_after_open (void) pe_data (link_info.output_bfd)->pe_opthdr = pe; pe_data (link_info.output_bfd)->dll = init[DLLOFF].value; pe_data (link_info.output_bfd)->real_flags |= real_flags; + pe_output_file_set_long_section_names (link_info.output_bfd); #ifdef DLL_SUPPORT if (pe_enable_stdcall_fixup) /* -1=warn or 1=disable */ diff --git a/ld/emultempl/pep.em b/ld/emultempl/pep.em index 559773a..0ab913b 100644 --- a/ld/emultempl/pep.em +++ b/ld/emultempl/pep.em @@ -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 *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 optc) 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; } @@ -1039,6 +1053,7 @@ gld_${EMULATION_NAME}_after_open (void) pe_data (link_info.output_bfd)->pe_opthdr = pep; pe_data (link_info.output_bfd)->dll = init[DLLOFF].value; pe_data (link_info.output_bfd)->real_flags |= real_flags; + pep_output_file_set_long_section_names (link_info.output_bfd); #ifdef DLL_SUPPORT if (pep_enable_stdcall_fixup) /* -1=warn or 1=disable */ diff --git a/ld/ld.texinfo b/ld/ld.texinfo index f38386b..082f655 100644 --- a/ld/ld.texinfo +++ b/ld/ld.texinfo @@ -2098,6 +2098,22 @@ Create a DLL instead of a regular executable. You may also use 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 diff --git a/ld/pe-dll.c b/ld/pe-dll.c index 5aaae17..397b66e 100644 --- a/ld/pe-dll.c +++ b/ld/pe-dll.c @@ -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 *filename) return TRUE; } +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 bfd_link_info *info) 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); diff --git a/ld/pe-dll.h b/ld/pe-dll.h index 22630dc..0cec4c1 100644 --- a/ld/pe-dll.h +++ b/ld/pe-dll.h @@ -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; @@ -65,5 +66,8 @@ extern void pe_create_import_fixup (arelent * rel, asection *, bfd_vma); extern bfd_boolean pe_bfd_is_dll (bfd *); +extern void pe_output_file_set_long_section_names + (bfd *abfd); + #endif /* PE_DLL_H */ diff --git a/ld/pep-dll.c b/ld/pep-dll.c index a7c31a7..8f7cc99 100644 --- a/ld/pep-dll.c +++ b/ld/pep-dll.c @@ -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 @@ -53,6 +55,8 @@ #define pe_dll_add_excludes pep_dll_add_excludes #define pe_walk_relocs_of_symbol pep_walk_relocs_of_symbol #define pe_bfd_is_dll pep_bfd_is_dll +#define pe_output_file_set_long_section_names \ + pep_output_file_set_long_section_names /* Uses x86_64 PE+. */ #define pe_use_x86_64 diff --git a/ld/pep-dll.h b/ld/pep-dll.h index 76ad61a..7734cce 100644 --- a/ld/pep-dll.h +++ b/ld/pep-dll.h @@ -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; @@ -53,5 +54,7 @@ extern void pep_walk_relocs_of_symbol (struct bfd_link_info *, const char *, int (*) (arelent *, asection *)); extern void pep_create_import_fixup (arelent * rel, asection *, bfd_vma); extern bfd_boolean pep_bfd_is_dll (bfd *); +extern void pep_output_file_set_long_section_names + (bfd *abfd); #endif /* PEP_DLL_H */ diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index c1ab26f..5d41613 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,14 @@ +2009-18-02 Dave Korn <dave.korn.cygwin@gmail.com> + + * 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. + 2009-02-18 Christophe Lyon <christophe.lyon@st.com> * ld-arm/farcall-arm-arm-pic-veneer.d, diff --git a/ld/testsuite/ld-pe/longsecn-1.d b/ld/testsuite/ld-pe/longsecn-1.d new file mode 100755 index 0000000..f860f1e --- /dev/null +++ b/ld/testsuite/ld-pe/longsecn-1.d @@ -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 + diff --git a/ld/testsuite/ld-pe/longsecn-2.d b/ld/testsuite/ld-pe/longsecn-2.d new file mode 100755 index 0000000..278dc75 --- /dev/null +++ b/ld/testsuite/ld-pe/longsecn-2.d @@ -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 diff --git a/ld/testsuite/ld-pe/longsecn-3.d b/ld/testsuite/ld-pe/longsecn-3.d new file mode 100755 index 0000000..0317be3 --- /dev/null +++ b/ld/testsuite/ld-pe/longsecn-3.d @@ -0,0 +1,41 @@ +#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|bss ) [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ 2\*\*[0-9] + (CONTENTS, ALLOC, LOAD, (READONLY, )?CODE|ALLOC) + 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 |text) [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ 2\*\*[0-9] + (ALLOC|CONTENTS, ALLOC, LOAD, (READONLY, )?CODE) diff --git a/ld/testsuite/ld-pe/longsecn-4.d b/ld/testsuite/ld-pe/longsecn-4.d new file mode 100755 index 0000000..565ef38 --- /dev/null +++ b/ld/testsuite/ld-pe/longsecn-4.d @@ -0,0 +1,41 @@ +#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|bss ) [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ 2\*\*[0-9] + (CONTENTS, ALLOC, LOAD, (READONLY, )?CODE|ALLOC) + 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 |text) [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ 2\*\*[0-9] + (ALLOC|CONTENTS, ALLOC, LOAD, (READONLY, )?CODE) diff --git a/ld/testsuite/ld-pe/longsecn-5.d b/ld/testsuite/ld-pe/longsecn-5.d new file mode 100755 index 0000000..82d94b8 --- /dev/null +++ b/ld/testsuite/ld-pe/longsecn-5.d @@ -0,0 +1,41 @@ +#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|bss ) [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ 2\*\*[0-9] + (CONTENTS, ALLOC, LOAD, (READONLY, )?CODE|ALLOC) + 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 |text) [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ [0-9a-fA-F]+ 2\*\*[0-9] + (ALLOC|CONTENTS, ALLOC, LOAD, (READONLY, )?CODE) diff --git a/ld/testsuite/ld-pe/longsecn.d b/ld/testsuite/ld-pe/longsecn.d new file mode 100755 index 0000000..92269fa --- /dev/null +++ b/ld/testsuite/ld-pe/longsecn.d @@ -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 + diff --git a/ld/testsuite/ld-pe/longsecn.exp b/ld/testsuite/ld-pe/longsecn.exp new file mode 100755 index 0000000..77de531 --- /dev/null +++ b/ld/testsuite/ld-pe/longsecn.exp @@ -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" + diff --git a/ld/testsuite/ld-pe/longsecn.s b/ld/testsuite/ld-pe/longsecn.s new file mode 100755 index 0000000..1fc4da3 --- /dev/null +++ b/ld/testsuite/ld-pe/longsecn.s @@ -0,0 +1,44 @@ + .text + .global _start + .global _mainCRTStartup +_start: +_mainCRTStartup: + .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 |