crtstuff.c (IN_LIBGCC2): Define it.
authorMark Mitchell <mark@codesourcery.com>
Wed, 24 Nov 2004 14:35:31 +0000 (14:35 +0000)
committerJoseph Myers <jsm28@gcc.gnu.org>
Wed, 24 Nov 2004 14:35:31 +0000 (14:35 +0000)
2004-11-24  Mark Mitchell  <mark@codesourcery.com>
            Joseph Myers  <joseph@codesourcery.com>

* crtstuff.c (IN_LIBGCC2): Define it.
(EH_FRAME_SECTION_CONST): Check EH_TABLES_CAN_BE_READ_ONLY
instead of HAVE_LD_RO_RW_SECTION_MIXING.
* defaults.h (EH_TABLES_CAN_BE_READ_ONLY): New macro.
* dwarf2out.c (named_section_eh_frame_section): Check
EH_TABLES_CAN_BE_READ_ONLY.
* except.c (default_exception_section): Likewise.
* config/i386/sol2.h (EH_TABLES_CAN_BE_READ_ONLY): Define.
* doc/tm.texi (EH_TABLES_CAN_BE_READ_ONLY): Document.

Co-Authored-By: Joseph Myers <joseph@codesourcery.com>
From-SVN: r91160

gcc/ChangeLog
gcc/config/i386/sol2.h
gcc/crtstuff.c
gcc/defaults.h
gcc/doc/tm.texi
gcc/dwarf2out.c
gcc/except.c

index 9afd037..4a392a5 100644 (file)
@@ -1,3 +1,16 @@
+2004-11-24  Mark Mitchell  <mark@codesourcery.com>
+            Joseph Myers  <joseph@codesourcery.com>
+
+       * crtstuff.c (IN_LIBGCC2): Define it.
+       (EH_FRAME_SECTION_CONST): Check EH_TABLES_CAN_BE_READ_ONLY
+       instead of HAVE_LD_RO_RW_SECTION_MIXING.
+       * defaults.h (EH_TABLES_CAN_BE_READ_ONLY): New macro.
+       * dwarf2out.c (named_section_eh_frame_section): Check
+       EH_TABLES_CAN_BE_READ_ONLY.
+       * except.c (default_exception_section): Likewise.
+       * config/i386/sol2.h (EH_TABLES_CAN_BE_READ_ONLY): Define.
+       * doc/tm.texi (EH_TABLES_CAN_BE_READ_ONLY): Document.
+
 2004-11-24  Kazu Hirata  <kazu@cs.umass.edu>
 
        * tree-ssa-pre.c (phi_translate): Use find_edge to find the
index dd82d76..c4a8f82 100644 (file)
@@ -40,6 +40,15 @@ Boston, MA 02111-1307, USA.  */
                  : DW_EH_PE_datarel))                                  \
    : DW_EH_PE_absptr)
 
+/* The Solaris linker will not merge a read-only .eh_frame section
+   with a read-write .eh_frame section.  None of the encodings used
+   with non-PIC code require runtime relocations.  In 64-bit mode,
+   since there is no backwards compatibility issue, we use a read-only
+   section for .eh_frame.  In 32-bit mode, we use a writable .eh_frame
+   section in order to be compatible with G++ for Solaris x86.  */
+#undef EH_TABLES_CAN_BE_READ_ONLY
+#define EH_TABLES_CAN_BE_READ_ONLY (TARGET_64BIT)
+
 /* Solaris 2/Intel as chokes on #line directives.  */
 #undef CPP_SPEC
 #define CPP_SPEC "%{.S:-P} %(cpp_subtarget)"
index 22f221b..0e362f3 100644 (file)
@@ -55,6 +55,8 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
    compiled for the target, and hence definitions concerning only the host
    do not apply.  */
 
+#define IN_LIBGCC2
+
 /* We include auto-host.h here to get HAVE_GAS_HIDDEN.  This is
    supposedly valid even though this is a "target" file.  */
 #include "auto-host.h"
@@ -92,7 +94,7 @@ call_ ## FUNC (void)                                  \
 #if defined(EH_FRAME_SECTION_NAME) && !defined(USE_PT_GNU_EH_FRAME)
 # define USE_EH_FRAME_REGISTRY
 #endif
-#if defined(EH_FRAME_SECTION_NAME) && defined(HAVE_LD_RO_RW_SECTION_MIXING)
+#if defined(EH_FRAME_SECTION_NAME) && EH_TABLES_CAN_BE_READ_ONLY
 # define EH_FRAME_SECTION_CONST const
 #else
 # define EH_FRAME_SECTION_CONST
index 1e1bdc8..daa584a 100644 (file)
@@ -310,6 +310,26 @@ do { fputs (integer_asm_op (POINTER_SIZE / BITS_PER_UNIT, TRUE), FILE); \
 #endif
 #endif
 
+/* On many systems, different EH table encodings are used under
+   difference circumstances.  Some will require runtime relocations;
+   some will not.  For those that do not require runtime relocations,
+   we would like to make the table read-only.  However, since the
+   read-only tables may need to be combined with read-write tables
+   that do require runtime relocation, it is not safe to make the
+   tables read-only unless the linker will merge read-only and
+   read-write sections into a single read-write section.  If your
+   linker does not have this ability, but your system is such that no
+   encoding used with non-PIC code will ever require a runtime
+   relocation, then you can define EH_TABLES_CAN_BE_READ_ONLY to 1 in
+   your target configuration file.  */
+#ifndef EH_TABLES_CAN_BE_READ_ONLY
+#ifdef HAVE_LD_RO_RW_SECTION_MIXING
+#define EH_TABLES_CAN_BE_READ_ONLY 1
+#else
+#define EH_TABLES_CAN_BE_READ_ONLY 0
+#endif
+#endif
+
 /* If we have named section and we support weak symbols, then use the
    .jcr section for recording java classes which need to be registered
    at program start-up time.  */
index 339a41d..5efac06 100644 (file)
@@ -7588,6 +7588,13 @@ Do not define this macro unless @code{TARGET_ASM_NAMED_SECTION} is
 also defined.
 @end defmac
 
+@defmac EH_TABLES_CAN_BE_READ_ONLY
+Define this macro to 1 if your target is such that no frame unwind
+information encoding used with non-PIC code will ever require a
+runtime relocation, but the linker may not support merging read-only
+and read-write sections into a single read-write section.
+@end defmac
+
 @defmac MASK_RETURN_ADDR
 An rtx used to mask the return address found via @code{RETURN_ADDR_RTX}, so
 that it does not contain any extraneous set bits in it.
index 63a4614..044a65c 100644 (file)
@@ -121,24 +121,29 @@ void
 named_section_eh_frame_section (void)
 {
 #ifdef EH_FRAME_SECTION_NAME
-#ifdef HAVE_LD_RO_RW_SECTION_MIXING
-  int fde_encoding = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/1, /*global=*/0);
-  int per_encoding = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/2, /*global=*/1);
-  int lsda_encoding = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/0, /*global=*/0);
   int flags;
 
-  flags = (! flag_pic
-          || ((fde_encoding & 0x70) != DW_EH_PE_absptr
-              && (fde_encoding & 0x70) != DW_EH_PE_aligned
-              && (per_encoding & 0x70) != DW_EH_PE_absptr
-              && (per_encoding & 0x70) != DW_EH_PE_aligned
-              && (lsda_encoding & 0x70) != DW_EH_PE_absptr
-              && (lsda_encoding & 0x70) != DW_EH_PE_aligned))
-         ? 0 : SECTION_WRITE;
+  if (EH_TABLES_CAN_BE_READ_ONLY)
+    {
+      int fde_encoding;
+      int per_encoding;
+      int lsda_encoding;
+
+      fde_encoding = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/1, /*global=*/0);
+      per_encoding = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/2, /*global=*/1);
+      lsda_encoding = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/0, /*global=*/0);
+      flags = (! flag_pic
+              || ((fde_encoding & 0x70) != DW_EH_PE_absptr
+                  && (fde_encoding & 0x70) != DW_EH_PE_aligned
+                  && (per_encoding & 0x70) != DW_EH_PE_absptr
+                  && (per_encoding & 0x70) != DW_EH_PE_aligned
+                  && (lsda_encoding & 0x70) != DW_EH_PE_absptr
+                  && (lsda_encoding & 0x70) != DW_EH_PE_aligned))
+             ? 0 : SECTION_WRITE;
+    }
+  else
+    flags = SECTION_WRITE;
   named_section_flags (EH_FRAME_SECTION_NAME, flags);
-#else
-  named_section_flags (EH_FRAME_SECTION_NAME, SECTION_WRITE);
-#endif
 #endif
 }
 
index b906cf0..56bc2d7 100644 (file)
@@ -3208,16 +3208,18 @@ default_exception_section (void)
   if (targetm.have_named_sections)
     {
       int flags;
-#ifdef HAVE_LD_RO_RW_SECTION_MIXING
-      int tt_format = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/0, /*global=*/1);
 
-      flags = (! flag_pic
-              || ((tt_format & 0x70) != DW_EH_PE_absptr
-                  && (tt_format & 0x70) != DW_EH_PE_aligned))
-             ? 0 : SECTION_WRITE;
-#else
-      flags = SECTION_WRITE;
-#endif
+      if (EH_TABLES_CAN_BE_READ_ONLY)
+       {
+         int tt_format = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/0, /*global=*/1);
+         
+         flags = (! flag_pic
+                  || ((tt_format & 0x70) != DW_EH_PE_absptr
+                      && (tt_format & 0x70) != DW_EH_PE_aligned))
+           ? 0 : SECTION_WRITE;
+       }
+      else
+       flags = SECTION_WRITE;
       named_section_flags (".gcc_except_table", flags);
     }
   else if (flag_pic)