提交 8e60785f 创建 作者: Austin Clements's avatar Austin Clements 提交者: Silas Boyd-Wickizer

Call global constructors during initialization

This might be a mistake because we can't control the order of global construction, but we already have several global constructors that were simply not being called before. As long as we keep all global constructors simple, this should be okay.
上级 28ead2d3
......@@ -18,6 +18,14 @@ SECTIONS
*(.prof)
}
PROVIDE(eprof = .);
PROVIDE(sctors = .);
.ctors : {
KEEP(*(SORT(.ctors.*)));
KEEP(*(.ctors));
}
PROVIDE(ectors = .);
. = ALIGN(0x1000);
.data : {
*(.data .data.* .gnu.linkonce.d.*)
......
......@@ -133,6 +133,11 @@ cmain(u64 mbmagic, u64 mbaddr)
{
extern u64 cpuhz;
// Call global constructors
extern const uptr sctors[], ectors[];
for (const uptr *ctorva = ectors; ctorva > sctors; )
((void(*)()) *--ctorva)();
initpg();
inithz(); // CPU Hz, microdelay
initpic(); // interrupt controller
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论