comp.lang.ada
 help / color / mirror / Atom feed
* -dead_strip and exception handling
@ 2011-08-20 19:07 ytomino
  2011-08-20 21:48 ` Simon Wright
  0 siblings, 1 reply; 4+ messages in thread
From: ytomino @ 2011-08-20 19:07 UTC (permalink / raw)


Hello.

I'm using Mac (Leopard), and found -dead_strip option of Apple's ld.
(instead of --gc-sections)
It's good, The size of my executable file has been reduced to half.

But I found it causes an exception handler is ignored.

with Ada.Text_IO;
procedure test1 is
begin
   raise Constraint_Error;
exception
   when Constraint_Error => Ada.Text_IO.Put_Line ("OK");
end test1;

$ gnatmake test1.adb -largs -dead_strip
gcc -c test1.adb
gnatbind -x test1.ali
gnatlink test1.ali -dead_strip
~/projects/exam/ada/compiler/dead_strip_and_eh
$ ./test1

raised CONSTRAINT_ERROR : test1.adb:4 explicit raise
~/projects/exam/ada/compiler/dead_strip_and_eh
$ gnatclean test1
"./test1.ali" has been deleted
"./test1.o" has been deleted
"test1" has been deleted
~/projects/exam/ada/compiler/dead_strip_and_eh
$ gnatmake test1.adb
gcc -c test1.adb
gnatbind -x test1.ali
gnatlink test1.ali
~/projects/exam/ada/compiler/dead_strip_and_eh
$ ./test1
OK

And I tried g++ with -dead_strip, it's ok. It could catch the
exception I threw.
Could you try it if you are Mac user ?

Thank you.



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

* Re: -dead_strip and exception handling
  2011-08-20 19:07 -dead_strip and exception handling ytomino
@ 2011-08-20 21:48 ` Simon Wright
  2011-08-20 22:29   ` ytomino
  2011-08-25 19:46   ` ytomino
  0 siblings, 2 replies; 4+ messages in thread
From: Simon Wright @ 2011-08-20 21:48 UTC (permalink / raw)


The exception is caught OK here: Lion 11.1, Xcode 4.1, GNAT GPL 2011 and
GCC 4.6.0.



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

* Re: -dead_strip and exception handling
  2011-08-20 21:48 ` Simon Wright
@ 2011-08-20 22:29   ` ytomino
  2011-08-25 19:46   ` ytomino
  1 sibling, 0 replies; 4+ messages in thread
From: ytomino @ 2011-08-20 22:29 UTC (permalink / raw)


On Aug 21, 6:48 am, Simon Wright <si...@pushface.org> wrote:
> The exception is caught OK here: Lion 11.1, Xcode 4.1, GNAT GPL 2011 and
> GCC 4.6.0.

I used gcc 4.6.1 in previous test. At first, I thought that it's a
problem of ld.
But I saw your result and tried again with gcc 4.5.1, it's ok...
Apparently, my gcc 4.6.1 may be broken...I've to rebuild it.

Thank you, Simon.



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

* Re: -dead_strip and exception handling
  2011-08-20 21:48 ` Simon Wright
  2011-08-20 22:29   ` ytomino
@ 2011-08-25 19:46   ` ytomino
  1 sibling, 0 replies; 4+ messages in thread
From: ytomino @ 2011-08-25 19:46 UTC (permalink / raw)


I found something.

gcc-4.5 outputs labels of error frames (_funcname.eh).

gcc-4.6 does not output labels of error frames.

ld of leopard use labels of error frames to link __eh_frame section.
However, if without -dead_strip, ld links all contents of *.o. So it
works fine.

ld of snow leopard (or lion) is upgraded. it has been linked with
libunwind.
Probably it can find error frames without labels and output right
__eh_frame section.

As a result, only in case of combination "ld of leopard", "-
dead_strip" and "*.o output by gcc-4.6", exception handlers are
ignored.

Thank you.



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

end of thread, other threads:[~2011-08-25 19:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-20 19:07 -dead_strip and exception handling ytomino
2011-08-20 21:48 ` Simon Wright
2011-08-20 22:29   ` ytomino
2011-08-25 19:46   ` ytomino

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox