tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kernel constructor



On Wed, Nov 12, 2014 at 2:42 AM, Antti Kantee <pooka%iki.fi@localhost> wrote:
> There are two separate issues here:
>
>         1: link sets vs. ctors
>
> They are exactly the same thing in slightly different clothing.  Mental
> exercise: define link_set_ctor and run those in kernel bootstrap when you'd
> run __attribute__((constructor)).  As David cautions, I don't think ctors
> should do anything apart from note that X is present in the image so that
> initializing X can be done later.  With link sets you don't need the extra
> step of noting since you can just iterate when you want to.

Thanks.  I'll try to write up a summary of link-set and
attribute-constructor-in-kernel reflecting your comments later.

>         2: init_main ordering
>
> I think that "code reading" is an absolute requirement there, i.e. we should
> be able to know offline what will happen at runtime.  Maybe that problem is
> better addressed with an offline preprocessor which figures out the correct
> order?

I'll generate init_main_kctors.c, which has a single function
init_main_kcotrs(), which has a generated sequence of constructors
from the amd64 ALL kernel.  This init_main_kctors.c is purely for
referencial purpose (e.g. nxr.netbsd.org and code readers), and not
built into kernels.


Home | Main Index | Thread Index | Old Index