This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC 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]

[Bug libgcc/60939] AIX: exceptions not caught when calling function via pointer


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60939

--- Comment #6 from Zoltan Hidvegi <zoltan at hidvegi dot com> ---
gcc collect2 links the programs twice, first it links just all the object and
archive files passed, then it parses the output and if necessary creates a
source file that contains information about static constructors and destructors
and some tables for exception unwinding, and compiles and relinks with that
additional object file. The problem is that the AIX linker by default does
garbage collection, and removes stuff that is unreachable. In the example b.cc
which contains main has no reference at all to anything in a.cc, so the garbage
collector thinks it can throw it away. If I use -bkeepfile:a.o for the first ld
call from collect2, then garbage collection is skipped for a.o, and this allows
the correct generation of frame_table and the example works. Unfortunately,
using -bnogc does not work, it leads to lots of undefined symbols. However
using -bexpfull for the first link does work (without keepfile), maybe that's a
proper fix? The only problem with that is that gcc does not call the second
link if it's not necessary, however keeping the executable created with
-bexpfull is not a good idea, so gcc would always have to relink.

Btw. a workaround is to refer to any symbol from a.cc from b.cc, e.g. adding a
dummy void bar() {} to a.cc and void junk() { bar(); } into b.cc would make the
example work.


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