This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Make .eh_frame and .gcc_except_table read-only if possible
- From: Jakub Jelinek <jakub at redhat dot com>
- To: rth at redhat dot com
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Sat, 23 Nov 2002 21:46:07 +0100
- Subject: [PATCH] Make .eh_frame and .gcc_except_table read-only if possible
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
This is the GCC part of moving .eh_frame and .gcc_except_table sections
into read-only (ie. shareable) segment on targets which are using solely
encodings which will not require any dynamic relocations in those sections.
Ok to commit (3.4-BIB)?
2002-11-23 Jakub Jelinek <jakub@redhat.com>
* varasm.c (default_exception_section): Move to...
* except.c (default_exception_section): ... here. Make
.gcc_except_table read-only if it is not expected to have any
dynamic relocations.
* dwarf2out.c (default_eh_frame_section): Make .eh_frame read-only
if it is not expected to have any dynamic relocations.
* crtstuff.c (__EH_FRAME_BEGIN__, __FRAME_END__): Add const.
--- gcc/except.c.jj 2002-09-27 14:21:54.000000000 +0200
+++ gcc/except.c 2002-11-23 19:07:32.000000000 +0100
@@ -3589,6 +3589,29 @@ sjlj_output_call_site_table ()
call_site_base += n;
}
+/* Tell assembler to switch to the section for the exception handling
+ table. */
+
+void
+default_exception_section ()
+{
+ if (targetm.have_named_sections)
+ {
+ int tt_format = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/0, /*global=*/1);
+ int flags;
+
+ flags = (! flag_pic
+ || ((tt_format & 0x70) != DW_EH_PE_absptr
+ && (tt_format & 0x70) != DW_EH_PE_aligned))
+ ? 0 : SECTION_WRITE;
+ named_section_flags (".gcc_except_table", flags);
+ }
+ else if (flag_pic)
+ data_section ();
+ else
+ readonly_data_section ();
+}
+
void
output_function_exception_table ()
{
--- gcc/varasm.c.jj 2002-11-14 01:12:10.000000000 +0100
+++ gcc/varasm.c 2002-11-23 19:04:35.000000000 +0100
@@ -582,20 +582,6 @@ variable_section (decl, reloc)
(*targetm.asm_out.select_section) (decl, reloc, DECL_ALIGN (decl));
}
-/* Tell assembler to switch to the section for the exception handling
- table. */
-
-void
-default_exception_section ()
-{
- if (targetm.have_named_sections)
- named_section (NULL_TREE, ".gcc_except_table", 0);
- else if (flag_pic)
- data_section ();
- else
- readonly_data_section ();
-}
-
/* Tell assembler to switch to the section for string merging. */
void
--- gcc/crtstuff.c.jj 2002-11-14 00:54:14.000000000 +0100
+++ gcc/crtstuff.c 2002-11-23 14:11:14.000000000 +0100
@@ -188,7 +188,7 @@ STATIC func_ptr __DTOR_LIST__[1]
#ifdef USE_EH_FRAME_REGISTRY
/* Stick a label at the beginning of the frame unwind info so we can register
and deregister it with the exception handling library code. */
-STATIC char __EH_FRAME_BEGIN__[]
+STATIC const char __EH_FRAME_BEGIN__[]
__attribute__((section(EH_FRAME_SECTION_NAME), aligned(4)))
= { };
#endif /* USE_EH_FRAME_REGISTRY */
@@ -453,7 +453,7 @@ STATIC func_ptr __DTOR_END__[1]
#ifdef EH_FRAME_SECTION_NAME
/* Terminate the frame unwind info section with a 4byte 0 as a sentinel;
this would be the 'length' field in a real FDE. */
-STATIC int __FRAME_END__[]
+STATIC const int __FRAME_END__[]
__attribute__ ((unused, mode(SI), section(EH_FRAME_SECTION_NAME),
aligned(4)))
= { 0 };
--- gcc/dwarf2out.c.jj 2002-10-29 16:30:44.000000000 +0100
+++ gcc/dwarf2out.c 2002-11-23 19:02:13.000000000 +0100
@@ -117,7 +117,20 @@ void
default_eh_frame_section ()
{
#ifdef EH_FRAME_SECTION_NAME
- named_section_flags (EH_FRAME_SECTION_NAME, SECTION_WRITE);
+ 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;
+ named_section_flags (EH_FRAME_SECTION_NAME, flags);
#else
tree label = get_file_function_name ('F');
Jakub