PATCH: Support Sun assembler for 64-bit Solaris/x86

Rainer Orth
Mon Dec 8 18:22:00 GMT 2008

Prompted by a recent attempt to build gcc with Sun as on Solaris 10/x86, I
reported the problem that Sun as doesn't support the SYMBOL-. syntax used
by gas to Sun.  Cf. the thread at

for all the gory details.  After doing so, I was told that Sun as uses a
different syntax instead, namely


The first variant dates back to at least 2001 (the earliest Solaris/x86
assembler I could easily test) and could already be put to good use to fix
PR libffi/26048,

and the second was added for amd64 support.

The following patch uses this to emit the proper syntax in the only place
the SYMBOL-. syntax was used before.

It allowed me to bootstrap with Sun as on Solaris 10/x86 (both 32 and 64
bit) for the first time (together with the latest fix for the libffi PR
above).  Testsuite results are a little worse than with gas, but nothing
fundamental (a large part of the failures is due to the use of .stab*,
which seems to be a gas addition):

The sse4.1 tests e.g. fail with a runtime linker error: sse4_1-blendpd.exe: fatal: hardware capability unsupported: 0x800000  [ 0x800000 ]

The assembler marks an object file containing sse4.1 instructions as
requiring the corresponding hardware, but complains that the cpu
doesn't contain that support and refuses to load the binary.  This can be
worked around (and safely so since the code in question contains a runtime
test), though.  A similar problem occured in the OpenSolaris OS/Net
consolidation, and I'll dig up the solution there.

The tests fail do to syntax errors in

Assembler: snapshot.S
        "asm-support.s", line 29 : Illegal multiplication

So it seems we're in pretty good shape overall.

Ok for mainline?


Rainer Orth, Faculty of Technology, Bielefeld University

Mon Dec  8 18:23:49 2008  Rainer Orth  <ro@TechFak.Uni-Bielefeld.DE>

	* config/i386/sol2-10.h [!HAVE_AS_IX86_DIFF_SECT_DELTA]

Index: gcc/config/i386/sol2-10.h
--- gcc/config/i386/sol2-10.h	(revision 142371)
+++ gcc/config/i386/sol2-10.h	(working copy)
@@ -1,5 +1,5 @@
 /* Solaris 10 configuration.
-   Copyright (C) 2004, 2006, 2007 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2006, 2007, 2008 Free Software Foundation, Inc.
    Contributed by CodeSourcery, LLC.
 This file is part of GCC.
@@ -39,6 +39,15 @@ along with GCC; see the file COPYING3.  
+/* The native Solaris assembler cannot handle the SYMBOL-. syntax, but
+   requires SYMBOL@rel/@rel64 instead.  */
+  do {							\
+    fputs (integer_asm_op (SIZE, FALSE), FILE);		\
+    assemble_name (FILE, LABEL);			\
+    fputs (SIZE == 8 ? "@rel64" : "@rel", FILE);	\
+  } while (0)

More information about the Gcc-patches mailing list