This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


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

Re: initializing eh


Hello,

> Try and code
> 
> int b;
> 
> class A {
> public:
> 	A() { b = 1; }
> } a;
> 
> in the kernel and see if b is 1 after you are running.  If it is,
> there isn't much to initialize, merely only the ordering could be
> wrong.  If it is 0, then make it work.  

Well, it gives 0, see comments on source below:

// compile with rtlinux-3
// g++ `rtl-config --cppflags --include` -O0 -c eh_mail.cc
// insmod eh_mail.o ## gives b = 0
//
// using __do_global_Xtors_aux() gives b = 1
// g++ `rtl-config --cppflags --include` -O0 -c eh_mail.cc
// ld -m elf_i386 -static -r -o k_eh.o `g++ -print-file-name=crtbegin.o` eh_mail.o `g++ -print-file-name=crtend.o`
// insmod k_eh.o
#include <rtlinux/rtl_cpp.h>
// [snipp] 
int init_module(void) { // similar to main()
    //__do_global_ctors_aux();
    printk("b = %d\n", b);
    return 0;
}
 
void cleanup_module(void) { // similar to atexit()
    //__do_global_dtors_aux();
}                                                                                                            

> If you add .init support to
> the kernel, things should start working.  Issues will be, when do you
> run ctors.  That, you will have to discusss on the kernel list, not
> here.

As I see, no elf sections will be executed on linux kernel modules, so all
initializing from the .init section I have to do by hand, like
__do_global_Xtors_aux() for global ctors/dtors. This does initialize some
parts of eh?, but not all, since I can't catch the exceptions - It goes directly
to abort() - which is a kernel specif abort (at moment doing nothings, since I
have no idea how to abort a linux kernel module). But this ist kernel mailing
list related.

> After that is working, then you should switch the kernel over to using
> init_priority and have them define all the numbers...  again,
> something for the kernel list.
init_priotity is part of collect2. What does it do ?

Thanks
Olaf


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