This is the mail archive of the binutils@sourceware.org mailing list for the binutils 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]

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


Hi Nick,

>> 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.
>
> Approved - please apply - but, please could you extend the comment slightly:
>
>   /* The Sun linker doesn't merge read-only and read-write sections into
>      a single read-write section so we must force all EH frame sections
>      to be read-write on SPARC and 32-bit i386.  */
>
> to:
>
>   /* The Sun linker doesn't merge read-only and read-write sections into
>      a single section so we must force all EH frame sections to use the
>      same flags.  For SPARC and 32-bit i386 this is read-write, whilst
>      for x86_64 this is read-only (because that is how gcc does it).  */
>
> Or something similar.  (Ideally it would be nice to include the URL for the
> start of this thread as well, so that interested readers could find out why
> the flags are different for 32-bit and 64-bit sparcs.  But you
> might think that this is overkill.  Your call).

Not at all: I think it's best to document such weird stuff as fully as
possible so the next guy doesn't have to rediscover all this on his own.

In this case, it was especially beneficial you made me change the file,
since I discovered an error: TC_SPARC is only defined in
config/tc-sparc.h and included (via targ-cpu.h) in obj-format.h.  So I
needed to move the obj-format.h inclusion further up, otherwise 64-bit
SPARC objects would have ended up with read-only .eh_frame sections.
Still, the file must be included after the LOCAL_LABELS_* definitions,
otherwise the build dies with redefinition errors.

To be extra sure, I've built both the 2.20 branch and mainline on
Solaris 10/SPARC and x86 and verified that the only change is the lack
of write permissions on the 64-bit x86 .eh_frame section.

Below is the patch I've checked in.

Thanks.
        Rainer

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


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

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

Index: gas/config/te-solaris.h
===================================================================
RCS file: /cvs/src/src/gas/config/te-solaris.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -p -r1.1 -r1.2
--- gas/config/te-solaris.h	26 Sep 2008 07:02:44 -0000	1.1
+++ gas/config/te-solaris.h	21 Jan 2010 20:58:34 -0000	1.2
@@ -1,4 +1,4 @@
-/* Copyright 2008 Free Software Foundation, Inc.
+/* Copyright 2008, 2010 Free Software Foundation, Inc.
 
    This file is part of GAS, the GNU Assembler.
 
@@ -22,9 +22,19 @@
 #define LOCAL_LABELS_DOLLAR 1
 #define LOCAL_LABELS_FB 1
 
-/* The Sun linker doesn't merge read-only and read-write sections into
-   a single read-write section so we must force all EH frame sections
-   to be read-write.  */
-#define DWARF2_EH_FRAME_READ_ONLY 0
-
 #include "obj-format.h"
+
+/* The Sun linker doesn't merge read-only and read-write sections into
+   a single section so we must force all EH frame sections to use the
+   same flags.  For SPARC and 32-bit i386 this is read-write, whilst
+   for x86_64 this is read-only, matching GCC behavior.
+
+   See the definition of EH_TABLES_CAN_BE_READ_ONLY in
+   gcc/config/i386/sol2.h in the GCC sources and the thread starting at
+   http://sourceware.org/ml/binutils/2010-01/msg00401.html.  */
+#ifdef TC_SPARC
+#define DWARF2_EH_FRAME_READ_ONLY SEC_NO_FLAGS
+#else
+#define DWARF2_EH_FRAME_READ_ONLY \
+  (bfd_get_arch_size (stdoutput) == 64 ? SEC_READONLY : SEC_NO_FLAGS)
+#endif


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