diff options
Diffstat (limited to 'ld')
-rw-r--r-- | ld/ChangeLog | 32 | ||||
-rw-r--r-- | ld/NEWS | 5 | ||||
-rw-r--r-- | ld/emultempl/pe.em | 19 | ||||
-rw-r--r-- | ld/emultempl/pep.em | 17 | ||||
-rw-r--r-- | ld/ld.texinfo | 16 | ||||
-rw-r--r-- | ld/pe-dll.c | 18 | ||||
-rw-r--r-- | ld/pe-dll.h | 6 | ||||
-rw-r--r-- | ld/pep-dll.c | 8 | ||||
-rw-r--r-- | ld/pep-dll.h | 5 | ||||
-rw-r--r-- | ld/testsuite/ChangeLog | 11 | ||||
-rwxr-xr-x | ld/testsuite/ld-pe/longsecn-1.d | 24 | ||||
-rwxr-xr-x | ld/testsuite/ld-pe/longsecn-2.d | 23 | ||||
-rwxr-xr-x | ld/testsuite/ld-pe/longsecn-3.d | 41 | ||||
-rwxr-xr-x | ld/testsuite/ld-pe/longsecn-4.d | 41 | ||||
-rwxr-xr-x | ld/testsuite/ld-pe/longsecn-5.d | 41 | ||||
-rwxr-xr-x | ld/testsuite/ld-pe/longsecn.d | 24 | ||||
-rwxr-xr-x | ld/testsuite/ld-pe/longsecn.exp | 35 | ||||
-rwxr-xr-x | ld/testsuite/ld-pe/longsecn.s | 44 |
18 files changed, 403 insertions, 7 deletions
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 |