public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Huge .eh_frame section with C++ exceptions, --gc-sections discards too much
@ 2013-01-23 10:37 R. Diez
  2013-01-23 12:40 ` Alan Modra
  0 siblings, 1 reply; 3+ messages in thread
From: R. Diez @ 2013-01-23 10:37 UTC (permalink / raw)
  To: binutils

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

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 ?

Please copy me on the answer, as I'm not subscribed to this mailing list.

Thanks in advance,
  R. Diez

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Huge .eh_frame section with C++ exceptions, --gc-sections discards too much
  2013-01-23 10:37 Huge .eh_frame section with C++ exceptions, --gc-sections discards too much R. Diez
@ 2013-01-23 12:40 ` Alan Modra
  2013-01-23 13:57   ` R. Diez
  0 siblings, 1 reply; 3+ messages in thread
From: Alan Modra @ 2013-01-23 12:40 UTC (permalink / raw)
  To: R. Diez; +Cc: binutils

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Huge .eh_frame section with C++ exceptions, --gc-sections discards too much
  2013-01-23 12:40 ` Alan Modra
@ 2013-01-23 13:57   ` R. Diez
  0 siblings, 0 replies; 3+ messages in thread
From: R. Diez @ 2013-01-23 13:57 UTC (permalink / raw)
  To: Alan Modra; +Cc: binutils

Hallo Alan:



> 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?


I'm afraid this is a proprietary app integrated in a complex build system and with a custom operating system, so it would take a long time to extract a short demo project. I'll keep it in mind, maybe when I'm more familiar with PowerPC cross-compilers and so on I'll try to provide a test case from scratch. For the time being, I'm just refraining from using C++ exceptions.

But this is something that no doubt other people with more experience can confirm, may the same eCos developer that was involved back then?

I am getting no linker warnings whatsoever. In case it helps, I have also observed this behaviour with an older GCC 4.5.3 / binutils 2.21. As long as I am aware, GCC/binutils can use 2 types of exception information, a newer one with "--eh-frame-hdr" (which I am not using), and the older type I am using (which sorts the exception tables on first touch, when the first exception is thrown).

Thanks,
  R. Diez

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-01-23 13:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-23 10:37 Huge .eh_frame section with C++ exceptions, --gc-sections discards too much R. Diez
2013-01-23 12:40 ` Alan Modra
2013-01-23 13:57   ` R. Diez

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