diff options
author | Alan Modra <amodra@gmail.com> | 2009-05-15 14:22:36 +0000 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2009-05-15 14:22:36 +0000 |
commit | d127ecce68b9052033148696008a8a905f661301 (patch) | |
tree | c4b31acc130ee14648913fb99d0a280de36dcb3c | |
parent | 0643c12ee1f4e258e1efea52d46b4c4e67fc8f78 (diff) | |
download | gdb-d127ecce68b9052033148696008a8a905f661301.zip gdb-d127ecce68b9052033148696008a8a905f661301.tar.gz gdb-d127ecce68b9052033148696008a8a905f661301.tar.bz2 |
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.
-rw-r--r-- | ld/ChangeLog | 17 | ||||
-rw-r--r-- | ld/emultempl/elf32.em | 43 | ||||
-rw-r--r-- | ld/emultempl/pe.em | 79 | ||||
-rw-r--r-- | ld/emultempl/pep.em | 62 | ||||
-rw-r--r-- | ld/ldlang.c | 49 | ||||
-rw-r--r-- | ld/ldlang.h | 4 | ||||
-rw-r--r-- | ld/testsuite/ChangeLog | 11 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/orphan3.d | 21 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/orphan3a.s | 12 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/orphan3b.s | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/orphan3c.s | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/orphan3d.s | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/orphan3e.s | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/orphan3f.s | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-pe/direct.exp | 4 | ||||
-rwxr-xr-x | ld/testsuite/ld-pe/longsecn.exp | 35 | ||||
-rw-r--r-- | ld/testsuite/ld-pe/orphan.d | 13 | ||||
-rw-r--r-- | ld/testsuite/ld-pe/orphana.s | 8 | ||||
-rw-r--r-- | ld/testsuite/ld-pe/orphanb.s | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-pe/orphand.s | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-pe/orphane.s | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-pe/pe.exp | 117 |
22 files changed, 321 insertions, 170 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog index b9c2965..01323e0 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,20 @@ +2009-05-15 Alan Modra <amodra@bigpond.net.au> + + * 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 <uweigand@de.ibm.com> * emultempl/spuelf.em (PARSE_AND_LIST_ARGS_CASES): Always use diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em index bb299d9..2d7a88d 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 30f8619..2437bfb 100644 --- a/ld/emultempl/pe.em +++ b/ld/emultempl/pe.em @@ -242,9 +242,12 @@ fragment <<EOF static void gld${EMULATION_NAME}_add_options - (int ns ATTRIBUTE_UNUSED, char **shortopts ATTRIBUTE_UNUSED, int nl, - struct option **longopts, int nrl ATTRIBUTE_UNUSED, - struct option **really_longopts ATTRIBUTE_UNUSED) + (int ns ATTRIBUTE_UNUSED, + char **shortopts ATTRIBUTE_UNUSED, + int nl, + struct option **longopts, + int nrl ATTRIBUTE_UNUSED, + struct option **really_longopts ATTRIBUTE_UNUSED) { static const struct option xtra_long[] = { /* PE options */ @@ -267,8 +270,8 @@ gld${EMULATION_NAME}_add_options {"use-nul-prefixed-import-tables", no_argument, NULL, OPTION_USE_NUL_PREFIXED_IMPORT_TABLES}, #ifdef DLL_SUPPORT - /* getopt allows abbreviations, so we do this to stop it from treating -o - as an abbreviation for this option */ + /* getopt allows abbreviations, so we do this to stop it + from treating -o as an abbreviation for this option. */ {"output-def", required_argument, NULL, OPTION_OUT_DEF}, {"output-def", required_argument, NULL, OPTION_OUT_DEF}, {"export-all-symbols", no_argument, NULL, OPTION_EXPORT_ALL}, @@ -311,8 +314,8 @@ gld${EMULATION_NAME}_add_options {NULL, no_argument, NULL, 0} }; - *longopts = (struct option *) - 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)); } @@ -819,12 +822,15 @@ 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 = (pe_enable_auto_image_base) ? - compute_dll_image_base (output_filename) : NT_DLL_IMAGE_BASE; + init[IMAGEBASEOFF].value = (pe_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; @@ -859,8 +865,7 @@ gld_${EMULATION_NAME}_set_symbols (void) /* Restore the pointer. */ pop_stat_ptr (); - if (pe.FileAlignment > - 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 f855618..e4519c5 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 65e092b..d97a55b 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 0b57b85..f9a1143 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 215d2e4..5fd731d 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,14 @@ +2009-05-15 Alan Modra <amodra@bigpond.net.au> + + * 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 <ams@codesourcery.com> Paul Brook <paul@codesourcery.com> diff --git a/ld/testsuite/ld-elf/orphan3.d b/ld/testsuite/ld-elf/orphan3.d new file mode 100644 index 0000000..4a03437 --- /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 0000000..7589dea --- /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 0000000..f57d3be --- /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 0000000..fedcf09 --- /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 0000000..1cf21bd --- /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 0000000..bcd7a18 --- /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 0000000..aa0c754 --- /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 2af2bf7..b4bb629 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 77de531..0000000 --- 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 0000000..1bace6b --- /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 0000000..0fff05e --- /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 0000000..0738616 --- /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 0000000..f0953ee --- /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 0000000..3f7e228 --- /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 2aa4d20..3cff6b4 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" |