I’m studying the mechanism of module loading inside the linux kernel, and I’m stuck at the meaning of the field strmap inside the struct load_info.
The struct is defined in kernel/module.c and the field is filled in kernel/module.c. I know it is a bitmap, but I can’t figure out the meaning of the individual bits.
(I couldn’t find anything on LWN. This is a partial analysis of the code. Note that
strmapexisted as a separate variable beforestruct load_infowas introduced.)strtabcontains a bunch of null-terminated strings concatenated together. E.g. it might contain this, where.stands for a null character:In
layout_symtab,strmapis used to determine which chunks ofstrtabcorrespond to core symbols. The loop sets the jth bit ofstrtabwhenever the jth character is part of the name of a core symbol. For example, given the table above, ifbarandcorgeare core symbols then bits 4–7 and 13–18 are set to 1.In
add_kallsyms, the second loop computes the total length of the names of the core symbols, and the third loop copies the core symbols into a new tablemod->symtabby copying only the bytes ofstrtabfor which the corresponding bit instrmapis set. In the example above, the new table would containbar.corge..