PATCH: Make .eh_frame sections read-only on 64-bit Solaris/x86

Rainer Orth ro@CeBiTec.Uni-Bielefeld.DE
Mon Jan 18 18:44:00 GMT 2010


During a recent bootstrap of GCC mainline on Solaris 11/x86 with the
bundled /usr/sfw/bin/gas (gas 2.19), I noticed that all C++ EH tests
failed.  The problem is that while gcc uses read-only .eh_frame sections
for 64-bit (cf. gcc/config/sol2.h), gas always emits read-write
.eh_frame section.  Since the Sun ld doesn't support merging read-only
and read-write sections, we end up with two .eh_frame sections in every
binary and shared library:

The .eh_frame sections in regular object files are now created by gas
and made read-write, those in crt{begin, end}.o are created by gcc
directly, contain just the zero-terminator that causes gcc's unwind
routines to skip them, and are made read-only.

This wasn't a problem on Solaris 10, even with gas 2.19, since the
linker there didn't support the zero-terminator .eh_frame sections, and
thus the crt* files were compiled *without*
-fno-asynchronous-unwind-tables, got both the manually coded read-only
.eh_frame section and the read-write one emitted by gas due to .cfi*
directives, which gas merged, so everything was read-write and consistent.

I'll probably add a check to gcc's gcc/configure.ac to guard against
this, but the proper fix seems to make gcc and gas consistent.

This is what this patch does, and it allowed me to get reasonable gcc
testresults on both Solaris 10 and 11/x86.

It would be good to get this both into binutils mainline and the 2.20
branch so we can point people at the gas 2.20.1 release that works in
time for the gcc 4.5 release.

Ok for both?

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University


2010-01-18  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	* config/te-solaris.h (DWARF2_EH_FRAME_READ_ONLY): Make read-only
	on 64-bit Solaris/x86.

--- te-solaris.h~	2010-01-13 22:52:19.567703000 +0100
+++ te-solaris.h	2010-01-14 15:16:09.035801000 +0100
@@ -26,9 +26,10 @@
    a single read-write section so we must force all EH frame sections
    to be read-write on SPARC and 32-bit i386.  */
 #ifdef TC_SPARC
-#define DWARF2_EH_FRAME_READ_ONLY 0
+#define DWARF2_EH_FRAME_READ_ONLY SEC_NO_FLAGS
 #else
-#define DWARF2_EH_FRAME_READ_ONLY (bfd_get_arch_size (stdoutput) == 64)
+#define DWARF2_EH_FRAME_READ_ONLY \
+  (bfd_get_arch_size (stdoutput) == 64 ? SEC_READONLY : SEC_NO_FLAGS)
 #endif
 
 #include "obj-format.h"



More information about the Binutils mailing list