This is the mail archive of the
mailing list for the binutils project.
Re: Huge .eh_frame section with C++ exceptions, --gc-sections discards too much
- From: Alan Modra <amodra at gmail dot com>
- To: "R. Diez" <rdiezmail-binutils at yahoo dot de>
- Cc: "binutils at sourceware dot org" <binutils at sourceware dot org>
- Date: Wed, 23 Jan 2013 23:10:32 +1030
- Subject: Re: Huge .eh_frame section with C++ exceptions, --gc-sections discards too much
- References: <1358937417.5402.YahooMailNeo@web171201.mail.ir2.yahoo.com>
On Wed, Jan 23, 2013 at 10:36:57AM +0000, R. Diez wrote:
> Hi all:
> I have built a GCC 4.7.2 cross-compiler for an embedded PowerPC
> target with EABI and -msdata=sysv, I am using binutils 2.23.1.
> I would like to use C++ exceptions, but I have noticed that the code
> gets much bigger then. Section .gcc_except_table seems to have a
> reasonable size, but section .eh_frame is huge.
> If I mark .gcc_except_table as KEEP in the linker script file, C++
> exception seem to work. However, if I remove the KEEP, the linker
> throws most of it away, only 4 bytes remain, and afterwards C++
> exceptions do not work in the final executable (it crashes on
Sounds like a bug. You shouldn't need to mark .gcc_except_table with
> I suspect there is room for improvement in the way .gcc_except_table
> is managed, as most of it is probably unused and could be discarded
> or at least merged somehow.
> I found a long discussion about this in the context of eCos around 7
> years ago:
> ? http://sourceware.org/ml/binutils/2005-06/msg00209.html
> ? http://sourceware.org/ml/binutils/2005-06/msg00221.html
> I am not sure what the status nowadays is. Can anybody help? Is
> there any way to prevent such a big growth when turning C++
> exceptions on, especially in section .gcc_except_table ?
Thes hacks I added in 2005 to keep .gcc_except_table were superceded
when Richard Sandiford added support for marking .gcc_except_table
from kept .eh_frame FDEs 2007-12-15. This should result in
--gc-sections removing unused .gcc_except_table sections (and in used
ones being kept, hence my remark about not needing KEEP in a linker
Is the linker emitting any warnings? Can you provide a testcase for
us to look at?
Australia Development Lab, IBM