From d127ecce68b9052033148696008a8a905f661301 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Fri, 15 May 2009 14:22:36 +0000 Subject: [PATCH] ld/ * ldlang.c (lang_output_section_statement_lookup): Add function comment. Make "name" non-const. Ensure duplicate entries use the same string, allowing simple comparison in hash bucket loop. Tweak constraint check. (next_matching_output_section_statement): New function. * ldlang.h (lang_output_section_statement_lookup): Update. (next_matching_output_section_statement): Declare. * emultempl/elf32.em (gld${EMULATION_NAME}_place_orphan): Don't combine orphan sections when input sections flags differ in alloc or load. * emultempl/pe.em: Formatting throughout. (gld${EMULATION_NAME}_place_orphan): As for elf32.em. * emultempl/pep.em: Formatting throughout. (gld${EMULATION_NAME}_place_orphan): As for elf32.em. ld/testsuite/ * ld-elf/orphan3.d, * ld-elf/orphan3a.s, * ld-elf/orphan3b.s, * ld-elf/orphan3c.s, * ld-elf/orphan3d.s, * ld-elf/orphan3e.s, * ld-elf/orphan3f.s: New test. * ld-pe/orphan.d, * ld-pe/orphana.s, * ld-pe/orphanb.s, * ld-pe/orphand.s, * ld-pe/orphane.s: New test. * ld-pe/direct.exp: Use is_pecoff_format. * ld-pe/longsecn.exp: Delete. * ld-pe/pe.exp: Run new test and longsecn tests. --- ld/ChangeLog | 17 +++++ ld/emultempl/elf32.em | 43 +++++++----- ld/emultempl/pe.em | 79 ++++++++++++--------- ld/emultempl/pep.em | 62 ++++++++++------- ld/ldlang.c | 49 ++++++++++--- ld/ldlang.h | 4 +- ld/testsuite/ChangeLog | 11 +++ ld/testsuite/ld-elf/orphan3.d | 21 ++++++ ld/testsuite/ld-elf/orphan3a.s | 12 ++++ ld/testsuite/ld-elf/orphan3b.s | 2 + ld/testsuite/ld-elf/orphan3c.s | 2 + ld/testsuite/ld-elf/orphan3d.s | 2 + ld/testsuite/ld-elf/orphan3e.s | 2 + ld/testsuite/ld-elf/orphan3f.s | 2 + ld/testsuite/ld-pe/direct.exp | 4 +- ld/testsuite/ld-pe/longsecn.exp | 35 ---------- ld/testsuite/ld-pe/orphan.d | 13 ++++ ld/testsuite/ld-pe/orphana.s | 8 +++ ld/testsuite/ld-pe/orphanb.s | 2 + ld/testsuite/ld-pe/orphand.s | 2 + ld/testsuite/ld-pe/orphane.s | 2 + ld/testsuite/ld-pe/pe.exp | 117 ++++++++++++++++++-------------- 22 files changed, 321 insertions(+), 170 deletions(-) create mode 100644 ld/testsuite/ld-elf/orphan3.d create mode 100644 ld/testsuite/ld-elf/orphan3a.s create mode 100644 ld/testsuite/ld-elf/orphan3b.s create mode 100644 ld/testsuite/ld-elf/orphan3c.s create mode 100644 ld/testsuite/ld-elf/orphan3d.s create mode 100644 ld/testsuite/ld-elf/orphan3e.s create mode 100644 ld/testsuite/ld-elf/orphan3f.s delete mode 100755 ld/testsuite/ld-pe/longsecn.exp create mode 100644 ld/testsuite/ld-pe/orphan.d create mode 100644 ld/testsuite/ld-pe/orphana.s create mode 100644 ld/testsuite/ld-pe/orphanb.s create mode 100644 ld/testsuite/ld-pe/orphand.s create mode 100644 ld/testsuite/ld-pe/orphane.s diff --git a/ld/ChangeLog b/ld/ChangeLog index b9c2965372d..01323e0bae6 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,20 @@ +2009-05-15 Alan Modra + + * ldlang.c (lang_output_section_statement_lookup): Add function + comment. Make "name" non-const. Ensure duplicate entries use + the same string, allowing simple comparison in hash bucket loop. + Tweak constraint check. + (next_matching_output_section_statement): New function. + * ldlang.h (lang_output_section_statement_lookup): Update. + (next_matching_output_section_statement): Declare. + * emultempl/elf32.em (gld${EMULATION_NAME}_place_orphan): Don't + combine orphan sections when input sections flags differ in + alloc or load. + * emultempl/pe.em: Formatting throughout. + (gld${EMULATION_NAME}_place_orphan): As for elf32.em. + * emultempl/pep.em: Formatting throughout. + (gld${EMULATION_NAME}_place_orphan): As for elf32.em. + 2009-05-14 Ulrich Weigand * emultempl/spuelf.em (PARSE_AND_LIST_ARGS_CASES): Always use diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em index bb299d98d15..2d7a88d3bfa 100644 --- a/ld/emultempl/elf32.em +++ b/ld/emultempl/elf32.em @@ -1712,23 +1712,32 @@ gld${EMULATION_NAME}_place_orphan (asection *s, } /* Look through the script to see where to place this section. */ - if (constraint == 0 - && (os = lang_output_section_find (secname)) != NULL - && os->bfd_section != NULL - && (os->bfd_section->flags == 0 - || (_bfd_elf_match_sections_by_type (link_info.output_bfd, - os->bfd_section, s->owner, s) - && ((s->flags ^ os->bfd_section->flags) - & (SEC_LOAD | SEC_ALLOC)) == 0))) - { - /* We already have an output section statement with this - name, and its bfd section has compatible flags. - If the section already exists but does not have any flags - set, then it has been created by the linker, probably as a - result of a --section-start command line switch. */ - lang_add_section (&os->children, s, os); - return os; - } + if (constraint == 0) + for (os = lang_output_section_find (secname); + os != NULL; + os = next_matching_output_section_statement (os, 0)) + { + /* If we don't match an existing output section, tell + lang_insert_orphan to create a new output section. */ + constraint = SPECIAL; + + if (os->bfd_section != NULL + && (os->bfd_section->flags == 0 + || (_bfd_elf_match_sections_by_type (link_info.output_bfd, + os->bfd_section, + s->owner, s) + && ((s->flags ^ os->bfd_section->flags) + & (SEC_LOAD | SEC_ALLOC)) == 0))) + { + /* We already have an output section statement with this + name, and its bfd section has compatible flags. + If the section already exists but does not have any flags + set, then it has been created by the linker, probably as a + result of a --section-start command line switch. */ + lang_add_section (&os->children, s, os); + return os; + } + } if (!orphan_init_done) { diff --git a/ld/emultempl/pe.em b/ld/emultempl/pe.em index 30f86194c2e..2437bfb91a2 100644 --- a/ld/emultempl/pe.em +++ b/ld/emultempl/pe.em @@ -242,9 +242,12 @@ fragment < - pe.SectionAlignment) + if (pe.FileAlignment > pe.SectionAlignment) { einfo (_("%P: warning, file alignment > section alignment.\n")); } @@ -1266,7 +1271,7 @@ gld_${EMULATION_NAME}_after_open (void) } symbols = bfd_get_outsymbols (is->the_bfd); - relocs = (arelent **) xmalloc ((size_t) relsize); + relocs = xmalloc ((size_t) relsize); nrelocs = bfd_canonicalize_reloc (is->the_bfd, sec, relocs, symbols); if (nrelocs < 0) @@ -1581,7 +1586,7 @@ gld_${EMULATION_NAME}_unrecognized_file (lang_input_statement_type *entry ATTRIB buflen = len + 2; } - buf = (char *) xmalloc (buflen); + buf = xmalloc (buflen); for (i = 0; i < pe_def_file->num_exports; i++) { @@ -1716,7 +1721,7 @@ gld_${EMULATION_NAME}_finish (void) #ifdef DLL_SUPPORT if (link_info.shared #if !defined(TARGET_IS_shpe) && !defined(TARGET_IS_mipspe) - || (!link_info.relocatable && pe_def_file->num_exports != 0) + || (!link_info.relocatable && pe_def_file->num_exports != 0) #endif ) { @@ -1786,21 +1791,32 @@ gld_${EMULATION_NAME}_place_orphan (asection *s, lang_list_init (&add_child); - if (constraint == 0 - && (os = lang_output_section_find (secname)) != NULL - && os->bfd_section != NULL - && (os->bfd_section->flags == 0 - || ((s->flags ^ os->bfd_section->flags) - & (SEC_LOAD | SEC_ALLOC)) == 0)) - { - /* We already have an output section statement with this - name, and its bfd section has compatible flags. - If the section already exists but does not have any flags set, - then it has been created by the linker, probably as a result of - a --section-start command line switch. */ - lang_add_section (&add_child, s, os); - } - else + os = NULL; + if (constraint == 0) + for (os = lang_output_section_find (secname); + os != NULL; + os = next_matching_output_section_statement (os, 0)) + { + /* If we don't match an existing output section, tell + lang_insert_orphan to create a new output section. */ + constraint = SPECIAL; + + if (os->bfd_section != NULL + && (os->bfd_section->flags == 0 + || ((s->flags ^ os->bfd_section->flags) + & (SEC_LOAD | SEC_ALLOC)) == 0)) + { + /* We already have an output section statement with this + name, and its bfd section has compatible flags. + If the section already exists but does not have any flags set, + then it has been created by the linker, probably as a result of + a --section-start command line switch. */ + lang_add_section (&add_child, s, os); + break; + } + } + + if (os == NULL) { static struct orphan_save hold[] = { @@ -1906,7 +1922,8 @@ gld_${EMULATION_NAME}_place_orphan (asection *s, static bfd_boolean gld_${EMULATION_NAME}_open_dynamic_archive - (const char *arch ATTRIBUTE_UNUSED, search_dirs_type *search, + (const char *arch ATTRIBUTE_UNUSED, + search_dirs_type *search, lang_input_statement_type *entry) { static const struct diff --git a/ld/emultempl/pep.em b/ld/emultempl/pep.em index f8556189cd3..e4519c576e1 100644 --- a/ld/emultempl/pep.em +++ b/ld/emultempl/pep.em @@ -260,10 +260,12 @@ gld${EMULATION_NAME}_add_options {"no-seh", no_argument, NULL, OPTION_NO_SEH}, {"no-bind", no_argument, NULL, OPTION_NO_BIND}, {"wdmdriver", no_argument, NULL, OPTION_WDM_DRIVER}, - {"tsaware", no_argument, NULL, OPTION_TERMINAL_SERVER_AWARE}, {NULL, no_argument, NULL, 0} + {"tsaware", no_argument, NULL, OPTION_TERMINAL_SERVER_AWARE}, + {NULL, no_argument, NULL, 0} }; - *longopts = xrealloc (*longopts, nl * sizeof (struct option) + sizeof (xtra_long)); + *longopts + = xrealloc (*longopts, nl * sizeof (struct option) + sizeof (xtra_long)); memcpy (*longopts + nl, &xtra_long, sizeof (xtra_long)); } @@ -370,7 +372,7 @@ gld_${EMULATION_NAME}_list_options (FILE *file) fprintf (file, _(" --no-isolation Image understands isolation but do not isolate the image\n")); fprintf (file, _(" --no-seh Image does not use SEH. No SE handler may\n\ be called in this image\n")); - fprintf (file, _(" --no-bind Do not bind this image\n")); + fprintf (file, _(" --no-bind Do not bind this image\n")); fprintf (file, _(" --wdmdriver Driver uses the WDM model\n")); fprintf (file, _(" --tsaware Image is Terminal Server aware\n")); #endif @@ -757,15 +759,18 @@ gld_${EMULATION_NAME}_set_symbols (void) if (link_info.relocatable) init[IMAGEBASEOFF].value = 0; else if (init[DLLOFF].value || (link_info.shared && !link_info.pie)) + { #ifdef DLL_SUPPORT - init[IMAGEBASEOFF].value = (pep_enable_auto_image_base) ? - compute_dll_image_base (output_filename) : NT_DLL_IMAGE_BASE; + init[IMAGEBASEOFF].value = (pep_enable_auto_image_base + ? compute_dll_image_base (output_filename) + : NT_DLL_IMAGE_BASE); #else - init[IMAGEBASEOFF].value = NT_DLL_IMAGE_BASE; + init[IMAGEBASEOFF].value = NT_DLL_IMAGE_BASE; #endif + } else init[IMAGEBASEOFF].value = NT_EXE_IMAGE_BASE; - init[MSIMAGEBASEOFF].value = init[IMAGEBASEOFF].value; + init[MSIMAGEBASEOFF].value = init[IMAGEBASEOFF].value; } /* Don't do any symbol assignments if this is a relocatable link. */ @@ -1057,7 +1062,7 @@ This should work unless it involves constant data structures referencing symbols } pep_walk_relocs_of_symbol (&link_info, undef->root.string, - make_import_fixup); + make_import_fixup); /* Let's differentiate it somehow from defined. */ undef->type = bfd_link_hash_defweak; @@ -1561,21 +1566,32 @@ gld_${EMULATION_NAME}_place_orphan (asection *s, lang_list_init (&add_child); - if (constraint == 0 - && (os = lang_output_section_find (secname)) != NULL - && os->bfd_section != NULL - && (os->bfd_section->flags == 0 - || ((s->flags ^ os->bfd_section->flags) - & (SEC_LOAD | SEC_ALLOC)) == 0)) - { - /* We already have an output section statement with this - name, and its bfd section has compatible flags. - If the section already exists but does not have any flags set, - then it has been created by the linker, probably as a result of - a --section-start command line switch. */ - lang_add_section (&add_child, s, os); - } - else + os = NULL; + if (constraint == 0) + for (os = lang_output_section_find (secname); + os != NULL; + os = next_matching_output_section_statement (os, 0)) + { + /* If we don't match an existing output section, tell + lang_insert_orphan to create a new output section. */ + constraint = SPECIAL; + + if (os->bfd_section != NULL + && (os->bfd_section->flags == 0 + || ((s->flags ^ os->bfd_section->flags) + & (SEC_LOAD | SEC_ALLOC)) == 0)) + { + /* We already have an output section statement with this + name, and its bfd section has compatible flags. + If the section already exists but does not have any flags set, + then it has been created by the linker, probably as a result of + a --section-start command line switch. */ + lang_add_section (&add_child, s, os); + break; + } + } + + if (os == NULL) { static struct orphan_save hold[] = { diff --git a/ld/ldlang.c b/ld/ldlang.c index 65e092bb192..d97a55b084c 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -1322,8 +1322,13 @@ lang_memory_default (asection * section) return lang_memory_region_lookup (DEFAULT_MEMORY_REGION, FALSE); } +/* Find or create an output_section_statement with the given NAME. + If CONSTRAINT is non-zero match one with that constraint, otherwise + match any non-negative constraint. If CREATE, always make a + new output_section_statement for SPECIAL CONSTRAINT. */ + lang_output_section_statement_type * -lang_output_section_statement_lookup (const char *const name, +lang_output_section_statement_lookup (const char *name, int constraint, bfd_boolean create) { @@ -1344,8 +1349,8 @@ lang_output_section_statement_lookup (const char *const name, /* We have a section of this name, but it might not have the correct constraint. */ struct out_section_hash_entry *last_ent; - unsigned long hash = entry->root.hash; + name = entry->s.output_section_statement.name; if (create && constraint == SPECIAL) /* Not traversing to the end reverses the order of the second and subsequent SPECIAL sections in the hash table chain, @@ -1354,17 +1359,15 @@ lang_output_section_statement_lookup (const char *const name, else do { - if (entry->s.output_section_statement.constraint >= 0 - && (constraint == 0 - || (constraint - == entry->s.output_section_statement.constraint))) + if (constraint == entry->s.output_section_statement.constraint + || (constraint == 0 + && entry->s.output_section_statement.constraint >= 0)) return &entry->s.output_section_statement; last_ent = entry; entry = (struct out_section_hash_entry *) entry->root.next; } while (entry != NULL - && entry->root.hash == hash - && strcmp (name, entry->s.output_section_statement.name) == 0); + && name == entry->s.output_section_statement.name); if (!create) return NULL; @@ -1388,6 +1391,36 @@ lang_output_section_statement_lookup (const char *const name, return &entry->s.output_section_statement; } +/* Find the next output_section_statement with the same name as OS. + If CONSTRAINT is non-zero, find one with that constraint otherwise + match any non-negative constraint. */ + +lang_output_section_statement_type * +next_matching_output_section_statement (lang_output_section_statement_type *os, + int constraint) +{ + /* All output_section_statements are actually part of a + struct out_section_hash_entry. */ + struct out_section_hash_entry *entry = (struct out_section_hash_entry *) + ((char *) os + - offsetof (struct out_section_hash_entry, s.output_section_statement)); + const char *name = os->name; + + ASSERT (name == entry->root.string); + do + { + entry = (struct out_section_hash_entry *) entry->root.next; + if (entry == NULL + || name != entry->s.output_section_statement.name) + return NULL; + } + while (constraint != entry->s.output_section_statement.constraint + && (constraint != 0 + || entry->s.output_section_statement.constraint < 0)); + + return &entry->s.output_section_statement; +} + /* A variant of lang_output_section_find used by place_orphan. Returns the output statement that should precede a new output statement for SEC. If an exact match is found on certain flags, diff --git a/ld/ldlang.h b/ld/ldlang.h index 0b57b857ba3..f9a11433539 100644 --- a/ld/ldlang.h +++ b/ld/ldlang.h @@ -550,7 +550,9 @@ extern lang_input_statement_type *lang_add_input_file extern void lang_add_keepsyms_file (const char *); extern lang_output_section_statement_type *lang_output_section_statement_lookup - (const char *const, int, bfd_boolean); + (const char *, int, bfd_boolean); +extern lang_output_section_statement_type *next_matching_output_section_statement + (lang_output_section_statement_type *, int); extern void ldlang_add_undef (const char *const); extern void lang_add_output_format diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index 215d2e4dd80..5fd731d7533 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,14 @@ +2009-05-15 Alan Modra + + * ld-elf/orphan3.d, * ld-elf/orphan3a.s, * ld-elf/orphan3b.s, + * ld-elf/orphan3c.s, * ld-elf/orphan3d.s, * ld-elf/orphan3e.s, + * ld-elf/orphan3f.s: New test. + * ld-pe/orphan.d, * ld-pe/orphana.s, * ld-pe/orphanb.s, + * ld-pe/orphand.s, * ld-pe/orphane.s: New test. + * ld-pe/direct.exp: Use is_pecoff_format. + * ld-pe/longsecn.exp: Delete. + * ld-pe/pe.exp: Run new test and longsecn tests. + 2009-05-15 Andrew Stubbs Paul Brook diff --git a/ld/testsuite/ld-elf/orphan3.d b/ld/testsuite/ld-elf/orphan3.d new file mode 100644 index 00000000000..4a03437ec58 --- /dev/null +++ b/ld/testsuite/ld-elf/orphan3.d @@ -0,0 +1,21 @@ +#source: orphan3a.s +#source: orphan3b.s +#source: orphan3c.s +#source: orphan3d.s +#source: orphan3e.s +#source: orphan3f.s +#ld: +#readelf: -S --wide +#xfail: "arc-*-*" "d30v-*-*" "dlx-*-*" "fr30-*-*" "frv-*-*" +#xfail: "i860-*-*" "i960-*-*" "iq2000-*-*" "mn10200-*-*" "msp430-*-*" "mt-*-*" +#xfail: "or32-*-*" "pj-*-*" +#xfail: "cr16-*-*" "crx-*-*" "d10v-*-*" "xstormy16-*-*" + +#... + \[[ 0-9]+\] \.foo +PROGBITS +[0-9a-f]+ +[0-9a-f]+ +0+8 +0+ +A +0 +0 +[0-9]+ +#... + \[[ 0-9]+\] \.foo +NOBITS +[0-9a-f]+ +[0-9a-f]+ +0+8 +0+ +A +0 +0 +[0-9]+ +#... + \[[ 0-9]+\] \.foo +PROGBITS +0+ +[0-9a-f]+ +0+8 +0+ +0 +0 +[0-9]+ + \[[ 0-9]+\] \.[^f].* +#pass diff --git a/ld/testsuite/ld-elf/orphan3a.s b/ld/testsuite/ld-elf/orphan3a.s new file mode 100644 index 00000000000..7589dea7dae --- /dev/null +++ b/ld/testsuite/ld-elf/orphan3a.s @@ -0,0 +1,12 @@ + .globl main + .globl start + .globl _start + .globl __start + .text +main: +start: +_start: +__start: + + .section .foo,"a",%nobits + .space 4 diff --git a/ld/testsuite/ld-elf/orphan3b.s b/ld/testsuite/ld-elf/orphan3b.s new file mode 100644 index 00000000000..f57d3bec424 --- /dev/null +++ b/ld/testsuite/ld-elf/orphan3b.s @@ -0,0 +1,2 @@ + .section .foo,"a",%progbits + .long 1 diff --git a/ld/testsuite/ld-elf/orphan3c.s b/ld/testsuite/ld-elf/orphan3c.s new file mode 100644 index 00000000000..fedcf09be04 --- /dev/null +++ b/ld/testsuite/ld-elf/orphan3c.s @@ -0,0 +1,2 @@ + .section .foo,"",%progbits + .long 2 diff --git a/ld/testsuite/ld-elf/orphan3d.s b/ld/testsuite/ld-elf/orphan3d.s new file mode 100644 index 00000000000..1cf21bd7cbf --- /dev/null +++ b/ld/testsuite/ld-elf/orphan3d.s @@ -0,0 +1,2 @@ + .section .foo,"a",%nobits + .space 4 diff --git a/ld/testsuite/ld-elf/orphan3e.s b/ld/testsuite/ld-elf/orphan3e.s new file mode 100644 index 00000000000..bcd7a18cf76 --- /dev/null +++ b/ld/testsuite/ld-elf/orphan3e.s @@ -0,0 +1,2 @@ + .section .foo,"a",%progbits + .long 4 diff --git a/ld/testsuite/ld-elf/orphan3f.s b/ld/testsuite/ld-elf/orphan3f.s new file mode 100644 index 00000000000..aa0c754b10e --- /dev/null +++ b/ld/testsuite/ld-elf/orphan3f.s @@ -0,0 +1,2 @@ + .section .foo,"",%progbits + .long 5 diff --git a/ld/testsuite/ld-pe/direct.exp b/ld/testsuite/ld-pe/direct.exp index 2af2bf74671..b4bb629da2b 100644 --- a/ld/testsuite/ld-pe/direct.exp +++ b/ld/testsuite/ld-pe/direct.exp @@ -49,9 +49,7 @@ # 7. run the produced executables # This test can only be run on PE/COFF platforms. -if { ![istarget *-*-cygwin*] - && ![istarget *-*-mingw*] - && ![istarget *-*-pe] } { +if {![is_pecoff_format]} { return } diff --git a/ld/testsuite/ld-pe/longsecn.exp b/ld/testsuite/ld-pe/longsecn.exp deleted file mode 100755 index 77de531f625..00000000000 --- a/ld/testsuite/ld-pe/longsecn.exp +++ /dev/null @@ -1,35 +0,0 @@ -# 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/orphan.d b/ld/testsuite/ld-pe/orphan.d new file mode 100644 index 00000000000..1bace6ba462 --- /dev/null +++ b/ld/testsuite/ld-pe/orphan.d @@ -0,0 +1,13 @@ +#source: orphana.s +#source: orphanb.s +#source: orphand.s +#source: orphane.s +#ld: --file-align 1 --section-align 1 +#objdump: -h --wide + +#... + +0 +\.text .* + +1 +\.foo +0+8 .* + +2 +\.foo +0+8 .* + +3 +\.idata .* +#pass diff --git a/ld/testsuite/ld-pe/orphana.s b/ld/testsuite/ld-pe/orphana.s new file mode 100644 index 00000000000..0fff05e76c7 --- /dev/null +++ b/ld/testsuite/ld-pe/orphana.s @@ -0,0 +1,8 @@ + .globl _mainCRTStartup + .globl _start + .text +_mainCRTStartup: +_start: + + .section .foo,"b" + .space 4 diff --git a/ld/testsuite/ld-pe/orphanb.s b/ld/testsuite/ld-pe/orphanb.s new file mode 100644 index 00000000000..0738616685b --- /dev/null +++ b/ld/testsuite/ld-pe/orphanb.s @@ -0,0 +1,2 @@ + .section .foo + .long 1 diff --git a/ld/testsuite/ld-pe/orphand.s b/ld/testsuite/ld-pe/orphand.s new file mode 100644 index 00000000000..f0953ee6a49 --- /dev/null +++ b/ld/testsuite/ld-pe/orphand.s @@ -0,0 +1,2 @@ + .section .foo,"b" + .space 4 diff --git a/ld/testsuite/ld-pe/orphane.s b/ld/testsuite/ld-pe/orphane.s new file mode 100644 index 00000000000..3f7e228df08 --- /dev/null +++ b/ld/testsuite/ld-pe/orphane.s @@ -0,0 +1,2 @@ + .section .foo + .long 4 diff --git a/ld/testsuite/ld-pe/pe.exp b/ld/testsuite/ld-pe/pe.exp index 2aa4d20f246..3cff6b4ebc9 100644 --- a/ld/testsuite/ld-pe/pe.exp +++ b/ld/testsuite/ld-pe/pe.exp @@ -1,52 +1,65 @@ -# Expect script for export table in executables tests -# Copyright 2004, 2006, 2007 -# 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 that support .secrel32. -if { ![istarget i*86-*-cygwin*] - && ![istarget i*86-*-pe] - && ![istarget i*86-*-mingw*] - && ![istarget x86_64-*-mingw*] - && ![istarget arm-wince-pe] } { - return -} - -if {[istarget x86_64-*-mingw*] } { - set pe_tests { - {".secrel32" "" "" {secrel1.s secrel2.s} - {{objdump -s secrel_64.d}} "secrel.x"} - } -} elseif {[istarget i*86-*-cygwin*] } { - set pe_tests { - {".secrel32" "--disable-auto-import" "" {secrel1.s secrel2.s} - {{objdump -s secrel.d}} "secrel.x"} - } -} else { - set pe_tests { - {".secrel32" "" "" {secrel1.s secrel2.s} - {{objdump -s secrel.d}} "secrel.x"} - } -} - -run_ld_link_tests $pe_tests - -run_dump_test "image_size" -run_dump_test "export_dynamic_warning" +# Expect script for export table in executables tests +# Copyright 2004, 2006, 2007 +# 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. +# + +# These tests can only be run on PE/COFF platforms. +if {![is_pecoff_format]} { + return +} + +# This test can only be run on PE/COFF platforms that support .secrel32. +if {[istarget i*86-*-cygwin*] + || [istarget i*86-*-pe] + || [istarget i*86-*-mingw*] + || [istarget x86_64-*-mingw*] + || [istarget arm-wince-pe] } { + + if {[istarget x86_64-*-mingw*] } { + set pe_tests { + {".secrel32" "" "" {secrel1.s secrel2.s} + {{objdump -s secrel_64.d}} "secrel.x"} + } + } elseif {[istarget i*86-*-cygwin*] } { + set pe_tests { + {".secrel32" "--disable-auto-import" "" {secrel1.s secrel2.s} + {{objdump -s secrel.d}} "secrel.x"} + } + } else { + set pe_tests { + {".secrel32" "" "" {secrel1.s secrel2.s} + {{objdump -s secrel.d}} "secrel.x"} + } + } + + run_ld_link_tests $pe_tests +} + +run_dump_test "image_size" +run_dump_test "export_dynamic_warning" + +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" + +run_dump_test "orphan" -- 2.30.2