From: Bruno Haible <haible@ilog.fr>
To: Jason Merrill <jason@cygnus.com>
Subject: .eh_frame section
Date: Tue, 07 Oct 1997 23:14:00 -0000 [thread overview]
Message-ID: <199710061406.QAA27126@halles.ilog.fr> (raw)
Hi,
Currently the ".eh_frame" section (containing DWARF2 unwind info) is
a read-write section. This poses two problems:
1. Accidental write accesses to this area by buggy programs won't be
caught. Instead such a program is likely to go to nirvana when the
next __throw occurs.
Please find below a patch which makes the ".eh_frame" section read-only
when compiling non-PIC (on those systems for which I could guess how to
implement it).
2. The ".eh_frame" section takes up about 25% of an executable. For
an executable, this is nothing to worry about. But for a shared
library, "objdump --section-headers" shows that the .eh_frame
section has the attributes CONTENTS, ALLOC, LOAD, RELOC, DATA.
The combination LOAD, RELOC means that, on most Unix systems,
this section will be completely read in and relocated when
the shared library is mapped into the process memory, i.e. usually
at program startup. Here at ILOG, we are routinely using executables
which are linked to a total of 20 MB of shared libraries. If 25%
of this must be read from disk each time the program starts up,
that will certainly be noticeable...
Would it be possible to replace the `pc_begin' pointer and the
`CIE_pointer' in `struct dwarf_fde' by position-independent entities?
Best regards,
Bruno
Sun Oct 5 03:07:30 1997 Bruno Haible <bruno@linuix.mathematik.uni-karlsruhe.de>
* sysv4.h (EH_FRAME_SECTION_ASM_OP, READONLY_EH_FRAME_SECTION_ASM_OP):
New macros.
* sparc/sysv4.h (READONLY_EH_FRAME_SECTION_ASM_OP): Likewise.
* mips/iris6.h (READONLY_EH_FRAME_SECTION_ASM_OP): Likewise.
* varasm.c (eh_frame_section): Use READONLY_EH_FRAME_SECTION_ASM_OP
unless compiling in PIC mode.
* crtstuff.c: Likewise.
*** config/mips/iris6.h.bak Sat Sep 27 01:33:40 1997
--- config/mips/iris6.h Sun Oct 5 00:03:12 1997
***************
*** 251,256 ****
--- 251,257 ----
/* dwarf2out will handle padding this data properly. We definitely don't
want it 8-byte aligned on n32. */
#define EH_FRAME_SECTION_ASM_OP ".section\t.eh_frame,1,2,0,1"
+ #define READONLY_EH_FRAME_SECTION_ASM_OP ".section\t.eh_frame,1,2,0,1"
/* A default list of other sections which we might be "in" at any given
time. For targets that use additional sections (e.g. .tdesc) you
*** config/sparc/sysv4.h.bak Sat Sep 27 01:35:49 1997
--- config/sparc/sysv4.h Sat Oct 4 23:59:59 1997
***************
*** 177,182 ****
--- 177,184 ----
#define DTORS_SECTION_ASM_OP ".section\t\".dtors\",#alloc,#write"
#undef EH_FRAME_SECTION_ASM_OP
#define EH_FRAME_SECTION_ASM_OP ".section\t\".eh_frame\",#alloc,#write"
+ #undef READONLY_EH_FRAME_SECTION_ASM_OP
+ #define READONLY_EH_FRAME_SECTION_ASM_OP ".section\t\".eh_frame\",#alloc"
/* A C statement to output something to the assembler file to switch to section
NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or
*** config/svr4.h.bak Wed Apr 30 19:59:24 1997
--- config/svr4.h Sun Oct 5 01:49:55 1997
***************
*** 527,532 ****
--- 527,539 ----
#define CTORS_SECTION_ASM_OP ".section\t.ctors,\"aw\""
#define DTORS_SECTION_ASM_OP ".section\t.dtors,\"aw\""
+ /* Put DWARF2 unwind info into a section with SHF_WRITE attribute set if
+ we are compiling for a shared library, but in a read-only section if we
+ are compiling code for an executable. */
+
+ #define EH_FRAME_SECTION_ASM_OP ".section\t.eh_frame,\"aw\""
+ #define READONLY_EH_FRAME_SECTION_ASM_OP ".section\t.eh_frame,\"a\""
+
/* On svr4, we *do* have support for the .init and .fini sections, and we
can put stuff in there to be executed before and after `main'. We let
crtstuff.c and other files know this by defining the following symbols.
*** crtstuff.c.bak Sat Sep 27 01:33:59 1997
--- crtstuff.c Sun Oct 5 01:10:57 1997
***************
*** 79,84 ****
--- 79,87 ----
#if !defined (EH_FRAME_SECTION_ASM_OP) && defined (DWARF2_UNWIND_INFO) && defined(ASM_OUTPUT_SECTION_NAME)
#define EH_FRAME_SECTION_ASM_OP ".section\t.eh_frame,\"aw\""
#endif
+ #if !defined (READONLY_EH_FRAME_SECTION_ASM_OP) && defined (DWARF2_UNWIND_INFO) && defined(ASM_OUTPUT_SECTION_NAME)
+ #define READONLY_EH_FRAME_SECTION_ASM_OP ".section\t.eh_frame,\"a\""
+ #endif
#ifdef OBJECT_FORMAT_ELF
***************
*** 286,292 ****
--- 289,300 ----
/* Stick a label at the beginning of the frame unwind info so we can register
and deregister it with the exception handling library code. */
+ #ifdef __PIC__
asm (EH_FRAME_SECTION_ASM_OP);
+ #else
+ asm (READONLY_EH_FRAME_SECTION_ASM_OP);
+ #endif
+
#ifdef INIT_SECTION_ASM_OP
STATIC
#endif
***************
*** 421,427 ****
--- 429,440 ----
this would be the 'length' field in a real FDE. */
typedef unsigned int ui32 __attribute__ ((mode (SI)));
+ #ifdef __PIC__
asm (EH_FRAME_SECTION_ASM_OP);
+ #else
+ asm (READONLY_EH_FRAME_SECTION_ASM_OP);
+ #endif
+
STATIC ui32 __FRAME_END__[] = { 0 };
#endif /* EH_FRAME_SECTION */
*** varasm.c.bak Sat Sep 27 01:36:58 1997
--- varasm.c Sun Oct 5 01:58:21 1997
***************
*** 410,416 ****
{
if (in_section != in_eh_frame)
{
! fprintf (asm_out_file, "%s\n", EH_FRAME_SECTION_ASM_OP);
in_section = in_eh_frame;
}
}
--- 410,419 ----
{
if (in_section != in_eh_frame)
{
! if (flag_pic)
! fprintf (asm_out_file, "%s\n", EH_FRAME_SECTION_ASM_OP);
! else
! fprintf (asm_out_file, "%s\n", READONLY_EH_FRAME_SECTION_ASM_OP);
in_section = in_eh_frame;
}
}
*** output.h.bak Sat Sep 27 01:30:36 1997
--- output.h Sat Oct 4 23:54:39 1997
***************
*** 150,155 ****
--- 150,158 ----
/* Tell assembler to switch to the section for the exception table. */
extern void exception_section PROTO((void));
+ /* Tell assembler to switch to the section for the eh_frame info table. */
+ extern void eh_frame_section PROTO((void));
+
/* Create the rtl to represent a function, for a function definition.
DECL is a FUNCTION_DECL node which describes which function.
The rtl is stored into DECL. */
next reply other threads:[~1997-10-07 23:14 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
1997-10-07 23:14 Bruno Haible [this message]
1997-10-07 23:14 ` Jason Merrill
1997-10-08 9:24 ` Richard Henderson
1997-10-08 15:38 meissner
1997-10-08 21:19 ` Richard Henderson
1997-10-09 9:26 ` Ian Lance Taylor
1997-10-09 9:26 ` Jason Merrill
1997-10-10 17:21 ` Bruno Haible
1997-10-13 9:44 ` Joern Rennecke
1997-10-13 13:41 ` Richard Henderson
2007-05-29 21:33 sfora dim
2007-05-29 23:13 ` Ian Lance Taylor
2007-05-30 7:41 ` sfora dim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=199710061406.QAA27126@halles.ilog.fr \
--to=haible@ilog.fr \
--cc=jason@cygnus.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).