Commit 70b1e9161e903a9e1682aca3a832ed29ef876a4d

Authored by Kevin Cernekee
Committed by Rusty Russell
1 parent 2485a4b610

module: Add comments describing how the "strmap" logic works

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

Showing 1 changed file with 9 additions and 0 deletions Side-by-side Diff

... ... @@ -2193,6 +2193,13 @@
2193 2193  
2194 2194 src = (void *)info->hdr + symsect->sh_offset;
2195 2195 nsrc = symsect->sh_size / sizeof(*src);
  2196 +
  2197 + /*
  2198 + * info->strmap has a '1' bit for each byte of .strtab we want to
  2199 + * keep resident in mod->core_strtab. Everything else in .strtab
  2200 + * is unreferenced by the symbols in mod->core_symtab, and will be
  2201 + * discarded when add_kallsyms() compacts the string table.
  2202 + */
2196 2203 for (ndst = i = 1; i < nsrc; ++i, ++src)
2197 2204 if (is_core_symbol(src, info->sechdrs, info->hdr->e_shnum)) {
2198 2205 unsigned int j = src->st_name;
... ... @@ -2215,6 +2222,8 @@
2215 2222  
2216 2223 /* Append room for core symbols' strings at end of core part. */
2217 2224 info->stroffs = mod->core_size;
  2225 +
  2226 + /* First strtab byte (and first symtab entry) are zeroes. */
2218 2227 __set_bit(0, info->strmap);
2219 2228 mod->core_size += bitmap_weight(info->strmap, strsect->sh_size);
2220 2229 }