skift-org / skift

🥑 A modern delightful operating system
https://skiftos.org/
GNU Lesser General Public License v3.0
2.32k stars 128 forks source link

Question about global constructors #43

Closed cristian-programmer closed 4 years ago

cristian-programmer commented 4 years ago

Hello colleagues, why do you need to call global constructors before starting the kernel? I understand that in a user space program it is called before the main function, to do something, But what should the core call before starting?

sleepy-monax commented 4 years ago

If I recall correctly, the global constructor isn't getting called in the kernel

RossComputerGuy commented 4 years ago

If constructors aren't getting called then I think they shouldn't be added in, it'll save up binary space.

sleepy-monax commented 4 years ago

It's C so there is no constructor to call, at least in the kernel, I know there is one in libposix to initialize stdio

cristian-programmer commented 4 years ago

aa ok, here the link: https://wiki.osdev.org/Calling_Global_Constructors#Using_crti.o.2C_crtbegin.o.2C_crtend.o.2C_and_crtn.o_in_a_Kerne I have been reading about this article on osdev.org, in skifos I thought I saw the call to these constructors @RossComputerGuy That means that I don't necessarily need to call the builders, isn't it an obligation for the kernel?

sleepy-monax commented 4 years ago

Yes there is one call to init in the userspace side of libsystem

cristian-programmer commented 4 years ago

@NicolasVanBossuyt good thank you, crt0.o crti.o, crtn.o Isn't it really necessary to call these files objects? that is mentioned in the osdev article

sleepy-monax commented 4 years ago

Yes you have to have them or gcc will complain '^^

cristian-programmer commented 4 years ago

Very Thanks!