g++ kernel

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
prabu

g++ kernel

Post by prabu »

I'm using the g++ that came with RH linux 8.

I had wrote my runtime support for constructors.
My Problem is with the Desctructors.

I can't add the Destructor for the Global Object classes.
If i put a destructor. I get some error in linking.

" undefined symbols. __dso_handle and __cxa_atexit "
__dso_handle is in data section.
__cxa_atexit may be a function.

I found this after doing some search in the "libc" with "objdump"

when I dump my kernel i cant found any .dtors section.

I just defined a variable and a dummy function as
extern "C" {
void *__dso_handle;
void __cxa_atexit() {

}
}

Now my linker is cheated by me.

BUT BUT BUT. HOW can I handle it properly.

When and how my destructors can be called without a .dtors section.

help me please...
thank you.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:g++ kernel

Post by Solar »

__cxa_atexit hints at an error in your compiler flags. I'd daresay you forgot to add -ffreestanding, --no-startup or a similar necessary option. (Can't test ATM which one results in said error message when omitted.)

__cxa_atexit is a runtime support function, which should not be linked into your binary at all since in kernel space you have to runtime support save your own.

Just a very humble IMHO in the earliest morning and without having tested this...

PS: Erm... which "libc" did you objdump? I'm smelling something here. You are aware you mustn't just link the RH libc into your kernel image, are you?
Every good solution is obvious once you've found it.
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:g++ kernel

Post by Candy »

Solar wrote: __cxa_atexit hints at an error in your compiler flags. I'd daresay you forgot to add -ffreestanding, --no-startup or a similar necessary option. (Can't test ATM which one results in said error message when omitted.)

__cxa_atexit is a runtime support function, which should not be linked into your binary at all since in kernel space you have to runtime support save your own.
for a guess, -fno-cxa-atexit or something similar. Man gcc.
Post Reply