This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Huge .eh_frame section with C++ exceptions, --gc-sections discards too much


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
> throw/catch).

Sounds like a bug.  You shouldn't need to mark .gcc_except_table with
KEEP.

> 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
script).

Is the linker emitting any warnings?  Can you provide a testcase for
us to look at?

-- 
Alan Modra
Australia Development Lab, IBM


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]