More futzing with the ld testsuite (supersedes previous patches)

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

More futzing with the ld testsuite (supersedes previous patches)

Zack Weinberg

This patch supersedes my two previous ld testsuite patches.  Compared
to them, it also addresses these problems:

1) The failure of ld-scripts/align1 is a general PECOFF problem, not
   specific to arm-epoc-pe.

2) arm-wince-pe has a lot of spurious failures due to the linker
   emitting a junk diagnostic:

     ld-new: warning: cannot find entry symbol WinMainCRTStartup;
     defaulting to <address>

   This is because ldlang.c assumes that if lang_add_entry has been
   called, the user specified an entry point, and they want to hear
   about it if it isn't defined.  However, pe.em and beos.em use
   lang_add_entry internally, to override ldlang.c's ultimate default
   of "start" for the entry symbol.  "WinMainCRTStartup" should get
   the same treatment as "start" on other targets - look for it, but
   don't complain if it's not found.  I have added a new interface,
   lang_default_entry, which .em files can use to change the default
   without triggering the diagnostic.

   It is debatable whether this interface should be used to implement
   --subsystem.  In this patch, I have chosen to do that, because
   it seems most consistent.  I could argue the other way, though.
   Comments are welcome.

With this patch, I get clean (no FAILs) ld test results on all the
following targets:

arm-elf
arm-aout
arm-epoc-pe
arm-nto
arm-vxworks
arm-wince-pe
arm-symbianelf
arm-none-eabi
xscale-coff
xscale-elf

Note I have not tested the change to beos.em at all.

OK to apply?

zw

ld:

        * ldlang.c (entry_symbol_default): New file-scope global.
        (lang_finish): Use it, not a hardwired "start".
        (lang_default_entry): Set it.
        * ldlang.h: Declare lang_default_entry.
        * emultempl/beos.em, emultempl/pe.em: Use lang_default_entry,
        not lang_add_entry, to override default entry point symbol.

ld/testsuite:

        * align.exp: Mark align1 XFAIL on PECOFF targets.
        * data.exp: Mark data UNSUPPORTED on a.out targets.
        * provide.exp, size.exp: Mark all tests UNSUPPORTED on a.out
        targets.  Tidy.

===================================================================
Index: ld/ldlang.c
--- ld/ldlang.c 17 May 2005 16:42:46 -0000 1.185
+++ ld/ldlang.c 31 May 2005 23:38:46 -0000
@@ -91,6 +91,7 @@ lang_statement_list_type lang_output_sec
 lang_statement_list_type *stat_ptr = &statement_list;
 lang_statement_list_type file_chain = { NULL, NULL };
 struct bfd_sym_chain entry_symbol = { NULL, NULL };
+static const char *entry_symbol_default = "start";
 const char *entry_section = ".text";
 bfd_boolean entry_from_cmdline;
 bfd_boolean lang_has_input_file = FALSE;
@@ -4743,9 +4744,9 @@ lang_finish (void)
 
   if (entry_symbol.name == NULL)
     {
-      /* No entry has been specified.  Look for start, but don't warn
- if we don't find it.  */
-      entry_symbol.name = "start";
+      /* No entry has been specified.  Look for the default entry, but
+ don't warn if we don't find it.  */
+      entry_symbol.name = entry_symbol_default;
       warn = FALSE;
     }
 
@@ -5582,6 +5583,16 @@ lang_add_entry (const char *name, bfd_bo
     }
 }
 
+/* Set the default start symbol to NAME.  .em files should use this,
+   not lang_add_entry, to override the use of "start" if neither the
+   linker script nor the command line specifies an entry point.  NAME
+   must be permanently allocated.  */
+void
+lang_default_entry (const char *name)
+{
+  entry_symbol_default = name;
+}
+
 void
 lang_add_target (const char *name)
 {
===================================================================
Index: ld/ldlang.h
--- ld/ldlang.h 17 May 2005 16:42:48 -0000 1.49
+++ ld/ldlang.h 31 May 2005 23:38:46 -0000
@@ -474,6 +474,8 @@ extern void lang_section_start
   (const char *, union etree_union *, const segment_type *);
 extern void lang_add_entry
   (const char *, bfd_boolean);
+extern void lang_default_entry
+  (const char *);
 extern void lang_add_target
   (const char *);
 extern void lang_add_wild
===================================================================
Index: ld/emultempl/beos.em
--- ld/emultempl/beos.em 12 May 2005 07:32:03 -0000 1.29
+++ ld/emultempl/beos.em 31 May 2005 23:38:48 -0000
@@ -216,23 +216,8 @@ set_pe_subsystem (void)
   set_pe_name ("__subsystem__", v[i].value);
 
   /* If the subsystem is windows, we use a different entry
-     point.  We also register the entry point as an undefined
-     symbol. from lang_add_entry() The reason we do
-     this is so that the user
-     doesn't have to because they would have to use the -u
-     switch if they were specifying an entry point other than
-     _mainCRTStartup.  Specifically, if creating a windows
-     application, entry point _WinMainCRTStartup must be
-     specified.  What I have found for non console
-     applications (entry not _mainCRTStartup) is that the .obj
-     that contains mainCRTStartup is brought in since it is
-     the first encountered in libc.lib and it has other
-     symbols in it which will be pulled in by the link
-     process.  To avoid this, adding -u with the entry point
-     name specified forces the correct .obj to be used.  We
-     can avoid making the user do this by always adding the
-     entry point name as an undefined symbol.  */
-  lang_add_entry (v[i].entry, 1);
+     point.  */
+  lang_default_entry (v[i].entry);
 
   return;
  }
===================================================================
Index: ld/emultempl/pe.em
--- ld/emultempl/pe.em 12 May 2005 07:32:03 -0000 1.105
+++ ld/emultempl/pe.em 31 May 2005 23:38:49 -0000
@@ -139,9 +139,9 @@ gld_${EMULATION_NAME}_before_parse (void
 
 #if (PE_DEF_SUBSYSTEM == 9) || (PE_DEF_SUBSYSTEM == 2)
 #if defined TARGET_IS_mipspe || defined TARGET_IS_armpe
-  lang_add_entry ("WinMainCRTStartup", FALSE);
+  lang_default_entry ("WinMainCRTStartup");
 #else
-  lang_add_entry ("_WinMainCRTStartup", FALSE);
+  lang_default_entry ("_WinMainCRTStartup");
 #endif
 #endif
 #endif
@@ -457,7 +457,7 @@ set_pe_subsystem (void)
     {
       char *alc_entry;
 
-      /* lang_add_entry expects its argument to be permanently
+      /* lang_default_entry expects its argument to be permanently
  allocated, so we don't free this string.  */
       alc_entry = xmalloc (strlen (initial_symbol_char)
    + strlen (entry)
@@ -467,7 +467,7 @@ set_pe_subsystem (void)
       entry = alc_entry;
     }
 
-  lang_add_entry (entry, FALSE);
+  lang_default_entry (entry);
 
   return;
 }
===================================================================
Index: ld/testsuite/ld-scripts/align.exp
--- ld/testsuite/ld-scripts/align.exp 12 May 2005 07:32:08 -0000 1.6
+++ ld/testsuite/ld-scripts/align.exp 31 May 2005 23:38:49 -0000
@@ -29,6 +29,12 @@ if ![ld_assemble $as $srcdir/$subdir/ali
     return
 }
 
+# Doesn't work on PECOFF, appears to be a genuine bug
+if [is_pecoff_format] {
+  global target_triplet
+  setup_xfail $target_triplet
+}
+
 if ![ld_simple_link $ld tmpdir/align "-T $srcdir/$subdir/align.t tmpdir/align.o"] {
     fail $testname
 } else {
===================================================================
Index: ld/testsuite/ld-scripts/data.exp
--- ld/testsuite/ld-scripts/data.exp 12 May 2005 07:32:08 -0000 1.2
+++ ld/testsuite/ld-scripts/data.exp 31 May 2005 23:38:49 -0000
@@ -17,4 +17,11 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
 
+# An a.out "objdump -s -j .text" has the file header visible inside the
+# text segment, confusing run_dump_test.
+if {[is_aout_format]} {
+ unsupported data
+ return
+}
+
 run_dump_test data
===================================================================
Index: ld/testsuite/ld-scripts/provide.exp
--- ld/testsuite/ld-scripts/provide.exp 12 May 2005 07:32:08 -0000 1.3
+++ ld/testsuite/ld-scripts/provide.exp 31 May 2005 23:38:49 -0000
@@ -15,15 +15,20 @@
 #
 # 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.
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301,
+# USA.
 
-if [istarget "rs6000-*-aix*"] {
-    # Target maps .text and .data to other sections.
+# AIX maps .text and .data to other sections.
+# a.out objdump displays the file header inside the text segment,
+# confusing run_dump_test.
+
+if {[istarget "rs6000-*-aix*"] || [is_aout_format]} {
+    unsupported provide-1
+    unsupported provide-2
+    unsupported provide-3
     return
 }
 
-set testname "provide"
-
 run_dump_test provide-1
 run_dump_test provide-2
 setup_xfail *-*-*
===================================================================
Index: ld/testsuite/ld-scripts/size.exp
--- ld/testsuite/ld-scripts/size.exp 12 May 2005 07:32:08 -0000 1.3
+++ ld/testsuite/ld-scripts/size.exp 31 May 2005 23:38:49 -0000
@@ -16,19 +16,22 @@
 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
 #
 
-if [istarget "rs6000-*-aix*"] {
-    # Target maps .text and .data to other sections.
+# AIX maps .text and .data to other sections.
+# a.out objdump displays the file header inside the text segment,
+# confusing run_dump_test.
+
+if {[istarget "rs6000-*-aix*"] || [is_aout_format]} {
+    unsupported size-1
+    unsupported size-2
     return
 }
 
 run_dump_test size-1
 
-if ![is_elf_format] {
-    return
-}
-
-if [istarget "mips*-*-*"] {
-    # MIPS inserts a REGINFO PHDR
+# size-2 only works on ELF targets.
+# MIPS inserts a REGINFO PHDR
+if {![is_elf_format] || [istarget "mips*-*-*"]} {
+    unsupported size-2
     return
 }
 
Reply | Threaded
Open this post in threaded view
|

Re: More futzing with the ld testsuite (supersedes previous patches)

Alan Modra
On Tue, May 31, 2005 at 04:42:55PM -0700, Zack Weinberg wrote:

> ld:
>
>         * ldlang.c (entry_symbol_default): New file-scope global.
>         (lang_finish): Use it, not a hardwired "start".
>         (lang_default_entry): Set it.
>         * ldlang.h: Declare lang_default_entry.
>         * emultempl/beos.em, emultempl/pe.em: Use lang_default_entry,
>         not lang_add_entry, to override default entry point symbol.
>
> ld/testsuite:
>
>         * align.exp: Mark align1 XFAIL on PECOFF targets.
>         * data.exp: Mark data UNSUPPORTED on a.out targets.
>         * provide.exp, size.exp: Mark all tests UNSUPPORTED on a.out
>         targets.  Tidy.

OK.

--
Alan Modra
IBM OzLabs - Linux Technology Centre
Reply | Threaded
Open this post in threaded view
|

Re: More futzing with the ld testsuite (supersedes previous patches)

Nick Clifton
In reply to this post by Zack Weinberg
Hi Zack,

> This patch supersedes my two previous ld testsuite patches.

Ah - sorry, I was going through my email backlog in order, and this
email was not threaded with the previous one.  So I missed it when I was
replying to your previous patches.  Please ignore the responses I sent
to them.

Cheers
   Nick