diff options
author | Dave Korn <dave.korn@artimi.com> | 2009-02-18 18:23:08 +0000 |
---|---|---|
committer | Dave Korn <dave.korn@artimi.com> | 2009-02-18 18:23:08 +0000 |
commit | 881838692219f34d1d34f0b916a5d982aab58040 (patch) | |
tree | f5ff0729cadc2f38cff6bf646c1f995d0b414efe /bfd | |
parent | 137f2437e04f733cae1120d032c7a1b24aef54af (diff) | |
download | gdb-881838692219f34d1d34f0b916a5d982aab58040.zip gdb-881838692219f34d1d34f0b916a5d982aab58040.tar.gz gdb-881838692219f34d1d34f0b916a5d982aab58040.tar.bz2 |
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 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.
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.
(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.
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.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 63 | ||||
-rw-r--r-- | bfd/coff-alpha.c | 5 | ||||
-rw-r--r-- | bfd/coff-mips.c | 5 | ||||
-rw-r--r-- | bfd/coff-rs6000.c | 6 | ||||
-rw-r--r-- | bfd/coff-sh.c | 10 | ||||
-rw-r--r-- | bfd/coff64-rs6000.c | 8 | ||||
-rw-r--r-- | bfd/coffcode.h | 160 | ||||
-rw-r--r-- | bfd/coffgen.c | 11 | ||||
-rw-r--r-- | bfd/ecoff.c | 12 | ||||
-rw-r--r-- | bfd/efi-app-ia32.c | 5 | ||||
-rw-r--r-- | bfd/efi-app-ia64.c | 5 | ||||
-rw-r--r-- | bfd/efi-app-x86_64.c | 5 | ||||
-rw-r--r-- | bfd/efi-bsdrv-ia32.c | 5 | ||||
-rw-r--r-- | bfd/efi-bsdrv-ia64.c | 5 | ||||
-rw-r--r-- | bfd/efi-bsdrv-x86_64.c | 5 | ||||
-rw-r--r-- | bfd/efi-rtdrv-ia32.c | 5 | ||||
-rw-r--r-- | bfd/efi-rtdrv-ia64.c | 5 | ||||
-rw-r--r-- | bfd/efi-rtdrv-x86_64.c | 5 | ||||
-rw-r--r-- | bfd/libcoff-in.h | 4 | ||||
-rw-r--r-- | bfd/libcoff.h | 10 | ||||
-rw-r--r-- | bfd/libecoff.h | 9 | ||||
-rw-r--r-- | bfd/libxcoff.h | 2 | ||||
-rw-r--r-- | bfd/pe-mips.c | 8 | ||||
-rw-r--r-- | bfd/pei-arm.c | 5 | ||||
-rw-r--r-- | bfd/pei-i386.c | 5 | ||||
-rw-r--r-- | bfd/pei-mcore.c | 5 | ||||
-rw-r--r-- | bfd/pei-mips.c | 5 | ||||
-rw-r--r-- | bfd/pei-ppc.c | 5 | ||||
-rw-r--r-- | bfd/pei-sh.c | 5 | ||||
-rw-r--r-- | bfd/pei-x86_64.c | 5 | ||||
-rw-r--r-- | bfd/ticoff.h | 17 |
31 files changed, 307 insertions, 103 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, |