Libsupcxx: Difference between revisions

m
Move to higher section level
[unchecked revision][unchecked revision]
(Move linking with kernel information here from OS Specific Toolchain)
m (Move to higher section level)
Line 70:
Please note that you still have to call the constructors/destructors by yourself as documented in [[Calling Global Constructors]].
 
=== Linking a kernel with libsupc++ ===
 
You can use your libsupc++ to get exception handling and RTTI in a C++ kernel (no more passing -fno-exceptions -fno-rtti to g++!) so you can use things like throw and dynamic_cast<>. Libsupc++ depends upon [[libgcc]] for stack unwinding support. Passing the -nostdlib option to gcc when linking caused libgcc.a and libsupc++.a to not be included, so you need to specify -lgcc -lsupc++ on the command line (no need to specify the directories; gcc knows where it installed them to). In addition, you need to include a .eh_frame section in your linker script and terminate it with 32 bits of zeros (QUAD(0) is a useful linker script command). The symbol start_eh_frame should point to the start of the eh_frame section, and it should be aligned by 4. In addition you need to include your constructors and destructors in the link (see [[C++]] for details). You also need to provide __register_frame() (or call the function provided by libgcc with the start of your .eh_frame section), void *__dso_handle;, __cxa_atexit() and __cxa_finalize (again see [[C++]]). Something along the lines of
Anonymous user