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

doubts regarding System Initialization working (SYSINIT)

Hello all,
                I have been browsing through the FreeBSD kernel's
source code trying to understand its working .

In the mi_startup() in /sys/kern/init_main.c all the SYSINIT objects
are sorted using bubble sort and then they are executed in order.

My doubt is that we have declared the pointer to the struct sysinit as
const pointer to a const in the macro definition of SYSINIT ie  when
the macro

expanded  completely we get the following

static struct sysinit kmem_sys_init = { SI_SUB_KMEM, SI_ORDER_FIRST,
nfunc_t)kmeminit, ((void *)(((void *)0))) }; static void const * const
__set_sysinit_set_sym_kmem_sys_init __attribute__((__section__("set_"
"sysinit_set"))) __attribute__((__used__)) = &kmem_sys_init;

Here we see that the pointer is of type const and to a const but when we sort
and swap using

We are trying to change the address of const pointer to a new address
in which case it should segfault but it works fine.

Why does it not segfault it seems I have not understood the concept
behind using const *const... I will be very thankful if you can help
me with it.

freebsd-ia32_(_at_)_freebsd_(_dot_)_org mailing list
To unsubscribe, send any mail to "freebsd-ia32-unsubscribe_(_at_)_freebsd_(_dot_)_org"