C++: Difference between revisions

Jump to navigation Jump to search
1,440 bytes removed ,  10 years ago
Move section to the libsupcxx article (as it is just as bitrotted as that article)
[unchecked revision][unchecked revision]
m (Fix long empty space between code)
(Move section to the libsupcxx article (as it is just as bitrotted as that article))
Line 489:
 
== Full C++ Runtime Support Using libgcc And libsupc++ ==
{{Main|Libsupcxx#Full C++ Runtime Support Using libgcc And libsupc++}}
The following description is valid for i386, GCC 3.2 and libgcc/libsupc++ compiled for Linux/glibc (you can use the static gcc/supc++ libraries compiled for your Linux for your kernel).
 
If you want Exceptions, RTTI, new and delete altogether, you also couldshould use libgcc and libsupc++. libgcc contains the unwinder (for exceptions), while libsupc++ contains the C++ support. These functions look very complex (gcc_sources/gcc/unwind*, gcc_sources/libstdc++-v3/libsupc++/*), so it might be better to port them instead of trying to write them yourself.
 
To get full C++ support, you only have to do the following:
 
* Provide some libc functions (e.g. abort, malloc, free, ...) because libsupc++ needs them. There are even more functions you could support, like pthread_*, but since these are weak symbols, you don't need to define them.
* There's also a strange function dl_iterate_phdrs. You don't need this so let it simply return -1. It's usually used to find exception frames for dynamically linked objects. You could also remove calls to this function from the library.
* To make use of exception handling, you also have to tell libsupc++ where the '''.eh_frame''' section begins. Before you throw any exception: <verbatim>__register_frame(address_of_eh_frames); </verbatim>.
* Terminate the '''.eh_frame''' section with 4 bytes of zeros (somehow). If you forget this, libsupc++ will never find the end of '''.eh_frame''' and generate stupid page faults.
 
Please note that you still have to call the constructors/destructors by yourself. Additionally, this sadly enlarges your kernel by approximately 50 kB (or even more). You could also cross-compile [[libsupcxx|libsupc++]] for your kernel.
 
== Optimizations ==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu