This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] native as support on Solaris/x86 (take 2)

My apologies for taking so long to get around to this...

On Fri, 21 Jul 2006, Mark Mitchell wrote:
> > Using "cc -xO2 -xarch=amd64 -Kpic -S switch.c", it appears that the
> > native C compiler on Solaris avoids this problem by placing its
> > jump table in the .text section, so it can take the difference of
> > labels in the same section.
> I think that you should define a general configuration macro that
> indicates whether or not the assembler has the capability GCC is
> depending upon.  Then, JUMP_TABLE_IN_TEXT_SECTION should be defined by
> default if that macro indicates a less-capable assembler.

This is a revised version of the patch originally posted at:

Mark's suggestion was that rather than using the macro USE_GAS to
control whether JUMP_TABLES_IN_TEXT_SECTION was defined, we add a
new configure check to probe the assembler directly.  This is done
below with a new HAVE_AS_IX86_DIFF_SECT_DELTA macro.  My apologies
for the cryptic name, but the feature we're testing for is the
ability to determine the delta or difference between labels/symbols
in different sections (hence DIFF_SECT_DELTA).  The configure test
simply tries to assemble the following fragment:

.section .rodata
        .long .L2-.L1
        .long .L3-.L1
.L3:    nop
.L2:    nop

This mirrors the idiom used by GCC when generating -fPIC code on
64-bit x86/Solaris.  This fails using the native /usr/ccs/bin/as
but works fine with gas v2.16.  The fix below of placing switch
tables in the .text section is the same approach taken by the
native compiler on Solaris.

The following patch has been tested with a full bootstrap of just
the C front-end on i386-pc-solaris2.10, both with and/without using
"--with-gnu-as --with-as=/usr/local/bin/gas".  I've confirmed that
the configure check passes for GNU as, and fails for the native
assembler.  And that a bootstrap of mainline GCC with the native
assembler now completes, where currently it fails during stage 1
whilst attempting to build libgcc/amd64/unwind-dw2.o.

Ok for mainline?

2006-10-31  Roger Sayle  <>

	* (HAVE_AS_IX86_DIFF_SECT_DELTA): New test to determine
	whether the assembler supports taking the difference of symbols in
	different sections.  On x86/Solaris, GAS does but Solaris as doesn't.
	* Regenerate.
	* Regenerate.
	* config/i386/sol2-10.h (JUMP_TABLES_IN_TEXT_SECTION): Define if
	the assembler doesn't support taking the difference of symbols in
	different sections, i.e. we're using the native solaris assembler.

***	(revision 118188)
---	(working copy)
*************** foo:	nop
*** 2841,2846 ****
--- 2841,2858 ----
          [Define if your assembler supports the ffreep mnemonic.])])

+     gcc_GAS_CHECK_FEATURE([different section symbol subtraction],
+       gcc_cv_as_ix86_diff_sect_delta,,,
+       [.section .rodata
+ .L1:
+         .long .L2-.L1
+         .long .L3-.L1
+         .text
+ .L3:    nop
+ .L2:    nop],,
+         [Define if your assembler supports the subtraction of symbols in different sections.])])
      # This one is used unconditionally by i386.[ch]; it is to be defined
      # to 1 if the feature is present, 0 otherwise.
      gcc_GAS_CHECK_FEATURE([GOTOFF in data],
Index: config/i386/sol2-10.h
*** config/i386/sol2-10.h	(revision 118188)
--- config/i386/sol2-10.h	(working copy)
*** 1,5 ****
  /* Solaris 10 configuration.
!    Copyright (C) 2004 Free Software Foundation, Inc.
     Contributed by CodeSourcery, LLC.

  This file is part of GCC.
--- 1,5 ----
  /* Solaris 10 configuration.
!    Copyright (C) 2004, 2006 Free Software Foundation, Inc.
     Contributed by CodeSourcery, LLC.

  This file is part of GCC.
*************** Boston, MA 02110-1301, USA.  */
*** 34,39 ****
--- 34,47 ----
  		 "-s %(asm_cpu)"

+ /* The native Solaris assembler can't calculate the difference between
+    symbols in different sections, which causes problems for -fPIC jump
+    tables in .rodata.  */
+ #endif

  #undef MCOUNT_NAME


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]