On Sat, Apr 28, 2012 at 10:13:11AM -0700, Paul Goyette wrote: > On Sat, 28 Apr 2012, Joerg Sonnenberger wrote: > > >On Sat, Apr 28, 2012 at 05:09:16PM +0100, David Laight wrote: > >>> > >>>This mechanism only works for modules that are "separate" from the > >>>kernel (loaded via "boot" or from "filesys"). "builtin" modules still > >>>need to use the link_set mechanism. > >> > >>Shouldn't be that hard to put the contructor list address into a > >>link_set - that would make it easy to get them called for 'built in' > >>modules. > > > >It's not even that complicated. Just provide symbols for start and end > >of the .ctor / .dtor section. That can be done either using linker > >scripts or by prepending / appending a small object like crt* does. > > But can you provide symbols for the start/end of each module's portion > of the .ctor / .dtor section? I don't think you can even guarantee that > all contributions for a module would be co-located. And I don't think > you would want to call all contructors for all (built-in) modules at the > same time, so you'd need a way to identify which entries belong to each > module. This is essentially what the link_set mechanism does today - > the net80211 module (and other stuff) each gets its own .ctor section.
You could rename (or maybe name) the modules section to .ctor.module, then you'd need to add a list of the .ctor.module names into the linker script to getthem called in the right order. I think the rename would be enough to get the symbols together. Other schemes that might work involve doing an initial 'ld -r' for the module, then processing the output of objdump/nm to generate an extra object file to link into the output. I'm not sure whether youcan use a linker script to control an 'ld -r'. David -- David Laight: da...@l8s.co.uk