From 51601538b89a6ff580a04fa26cb47c1822a74629 Mon Sep 17 00:00:00 2001 From: jsm28 Date: Wed, 24 Nov 2004 14:35:31 +0000 Subject: [PATCH] 2004-11-24 Mark Mitchell Joseph Myers * 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@91160 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 13 +++++++++++++ gcc/config/i386/sol2.h | 9 +++++++++ gcc/crtstuff.c | 4 +++- gcc/defaults.h | 20 ++++++++++++++++++++ gcc/doc/tm.texi | 7 +++++++ gcc/dwarf2out.c | 35 ++++++++++++++++++++--------------- gcc/except.c | 20 +++++++++++--------- 7 files changed, 83 insertions(+), 25 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9afd037..4a392a5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,16 @@ +2004-11-24 Mark Mitchell + Joseph Myers + + * 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 * tree-ssa-pre.c (phi_translate): Use find_edge to find the diff --git a/gcc/config/i386/sol2.h b/gcc/config/i386/sol2.h index dd82d76..c4a8f82 100644 --- a/gcc/config/i386/sol2.h +++ b/gcc/config/i386/sol2.h @@ -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)" diff --git a/gcc/crtstuff.c b/gcc/crtstuff.c index 22f221b..0e362f3 100644 --- a/gcc/crtstuff.c +++ b/gcc/crtstuff.c @@ -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 diff --git a/gcc/defaults.h b/gcc/defaults.h index 1e1bdc8..daa584a 100644 --- a/gcc/defaults.h +++ b/gcc/defaults.h @@ -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. */ diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index 339a41d..5efac06 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -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. diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 63a4614..044a65c 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -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 } diff --git a/gcc/except.c b/gcc/except.c index b906cf0..56bc2d7 100644 --- a/gcc/except.c +++ b/gcc/except.c @@ -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) -- 2.7.4