diff mbox

Don't use DWARF 4 on Solaris

Message ID yddobq01cdj.fsf@manam.CeBiTec.Uni-Bielefeld.DE
State New
Headers show

Commit Message

Rainer Orth May 7, 2012, 11:03 a.m. UTC
Solaris bootstrap on mainline is currently broken with the native
linker: linking stage1 libgcc_s.so fails like this:

ld: fatal: unwind table: file _divdi3_s.o: section .eh_frame: bad cie version 0: offset 0x20

It turns out that ld cannot handle CIE version 3.  The wrong error message
nonwithstanding, it requires CIE version 1.

CR 7166576 (ld/elfdump need to support DWARF-4) has been filed for this
issue and adding proper DWARF-3/4 support is under investigation by the
linker maintainers.

For the time being, I work around this as on Darwin by defaulting to
DWARF-2 unless something else is specified explicitly.  For consistency,
I'm doing this always, even if using GNU ld, which could be
reconsidered.

Bootstrapped on i386-pc-solaris2.{9, 10, 11} and sparc-sun-solaris2.{9,
10, 11} with as/ld, gas/ld, gas/gld, installed on mainline.

	Rainer


2012-05-04  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	* config/sol2.c (solaris_override_options): New function.
	* config/sol2-protos.h (solaris_override_options): Declare.
	* config/sol2.h (SUBTARGET_OVERRIDE_OPTIONS): Define.
diff mbox

Patch

# HG changeset patch
# Parent 9ee70e3b93194a9a802f878a7502ae5e5519c180
Don't use DWARF 4 on Solaris

diff --git a/gcc/config/sol2-protos.h b/gcc/config/sol2-protos.h
--- a/gcc/config/sol2-protos.h
+++ b/gcc/config/sol2-protos.h
@@ -1,6 +1,6 @@ 
 /* Operating system specific prototypes to be used when targeting GCC for any
    Solaris 2 system.
-   Copyright 2004, 2007, 2010, 2011 Free Software Foundation, Inc.
+   Copyright 2004, 2007, 2010, 2011, 2012 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -24,6 +24,7 @@  extern void solaris_elf_asm_comdat_secti
 extern void solaris_file_end (void);
 extern void solaris_insert_attributes (tree, tree *);
 extern void solaris_output_init_fini (FILE *, tree);
+extern void solaris_override_options (void);
 
 /* In sol2-c.c.  */
 extern void solaris_register_pragmas (void);
diff --git a/gcc/config/sol2.c b/gcc/config/sol2.c
--- a/gcc/config/sol2.c
+++ b/gcc/config/sol2.c
@@ -1,5 +1,6 @@ 
 /* General Solaris system support.
-   Copyright (C) 2004, 2005 , 2007, 2010, 2011 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2005 , 2007, 2010, 2011, 2012
+   Free Software Foundation, Inc.
    Contributed by CodeSourcery, LLC.
 
 This file is part of GCC.
@@ -282,3 +283,12 @@  solaris_file_end (void)
 
   htab_traverse (solaris_comdat_htab, solaris_define_comdat_signature, NULL);
 }
+
+void
+solaris_override_options (void)
+{
+  /* Don't emit DWARF3/4 unless specifically selected.  Solaris ld cannot
+     handle CIE version 3 in .eh_frame.  */
+  if (!global_options_set.x_dwarf_version)
+    dwarf_version = 2;
+}
diff --git a/gcc/config/sol2.h b/gcc/config/sol2.h
--- a/gcc/config/sol2.h
+++ b/gcc/config/sol2.h
@@ -99,6 +99,12 @@  along with GCC; see the file COPYING3.  
 	TARGET_SUB_OS_CPP_BUILTINS();			\
     } while (0)
 
+#define SUBTARGET_OVERRIDE_OPTIONS			\
+  do {							\
+    solaris_override_options ();			\
+  } while (0)
+
+
 /* It's safe to pass -s always, even if -g is not used.  Those options are
    handled by both Sun as and GNU as.  */
 #define ASM_SPEC_BASE \