tech-kern archive

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

Re: link-sets in modules



On Mon, 28 May 2012, David Laight wrote:

On Mon, May 28, 2012 at 11:38:09AM -0700, Paul Goyette wrote:

How would __link_set_process() know how many entries to process?  What
would indicate the end of the data?

It has the program headers eg (from a random module):

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
 0 .text         0000160e  00000000  00000000  00000040  2**4
                 CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
 1 .rodata.str1.1 00000105  00000000  00000000  0000164e  2**0
                 CONTENTS, ALLOC, LOAD, READONLY, DATA
 2 .rodata.str1.4 000001bc  00000000  00000000  00001754  2**2
                 CONTENTS, ALLOC, LOAD, READONLY, DATA
 3 .rodata       00000099  00000000  00000000  00001920  2**5
                 CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
 4 link_set_modules 00000004  00000000  00000000  000019bc  2**2
                 CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
 5 link_set_sysctl_funcs 00000004  00000000  00000000  000019c0  2**2
                 CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
 6 .data         000000a4  00000000  00000000  000019e0  2**5
                 CONTENTS, ALLOC, LOAD, RELOC, DATA
 7 .ident        00000071  00000000  00000000  00001a84  2**0
                 CONTENTS, READONLY

Unless I've missed something in my explorations, this data is not available for the "monolithic kernel". So a built-in module needs the {start,end} symbols to learn where the program sections are loaded.

Modules that are loaded by the run-time linker _do_ have the above info, but do not have the symbols.


When it processes section 5 it allocates 4 bytes somewhere ...
Since the entries are all pointers (actually it ought to be possible
to use any fixes size structure) it known where the end is.

Section 5 deals with the SYSCTL_SETUP() stuff. When modules create a sysctl(9) sub-tree, they have to explicitly call sysctl_createv() since the initializer(s) defined by SYSCTL_SETUP doesn't get called.

(The code that does call the SYSCTL_SETUP() initializers uses the __link_set_foreach() macro which depends on the {start,end} symbols - see sysctl_init() in src/sys/kern_sysctl.c)



So, I'm still hoping to see a prototype the works for both built-in and independantly-linked modules ...


:)



-------------------------------------------------------------------------
| Paul Goyette     | PGP Key fingerprint:     | E-mail addresses:       |
| Customer Service | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com    |
| Network Engineer | 0786 F758 55DE 53BA 7731 | pgoyette at juniper.net |
| Kernel Developer |                          | pgoyette at netbsd.org  |
-------------------------------------------------------------------------


Home | Main Index | Thread Index | Old Index