Re: [RFC PATCH 1/6] kernel: call constructors

From: Peter Oberparleiter
Date: Tue May 06 2008 - 07:51:19 EST


Sam Ravnborg wrote:
> On Mon, May 05, 2008 at 05:24:04PM +0200, Peter Oberparleiter wrote:
>> From: Peter Oberparleiter <peter.oberparleiter@xxxxxxxxxx>
>> +#define CONSTRUCTORS \
>> + __CTOR_LIST__ = .; \
>> + *(.ctors) \
>> + __CTOR_END__ = .; \
>> + __DTOR_LIST__ = .; \
>> + *(.dtors) \
>> + __DTOR_END__ = .;
>
> You shall use: VMLINUX_SYMBOL() here.

Ok, will do.

> And why those SHOUTING names?
> All other linker symbols are lowercase.

Here's the background for that: currently, almost all
arch/*/vmlinux.lds.S scripts contain reference to a CONSTRUCTORS
sections which is (as of yet) empty. The info pages for ld contain
a description of the contents of this section (section 3.6.6 Output
Section Keywords), including the following sample linker script:

__CTOR_LIST__ = .;
LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)
*(.ctors)
LONG(0)
__CTOR_END__ = .;
__DTOR_LIST__ = .;
LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2)
*(.dtors)
LONG(0)
__DTOR_END__ = .;

Apparently this sample script is buggy (namely the divide by 4 bit on
64 bit systems) so I changed it into the version found in the patch.
This is somewhat of a trade-off between the information which
should be present in a CONSTRUCTORS section according to the info
page and what really is needed to implement constructor support.

I guess changing the names would be an option if required, as well
as dropping the (unused) destructor bit of the linker script.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/