Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

modpost: traverse unresolved symbols in order

Currently, modpost manages unresolved in a singly linked list; it adds
a new node to the head, and traverses the list from new to old.

Use a doubly linked list to keep the order in the symbol table in the
ELF file.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

+15 -7
+14 -6
scripts/mod/modpost.c
··· 185 185 mod = NOFAIL(malloc(sizeof(*mod) + strlen(modname) + 1)); 186 186 memset(mod, 0, sizeof(*mod)); 187 187 188 + INIT_LIST_HEAD(&mod->unresolved_symbols); 189 + 188 190 strcpy(mod->name, modname); 189 191 mod->is_vmlinux = (strcmp(modname, "vmlinux") == 0); 190 192 ··· 209 207 210 208 struct symbol { 211 209 struct symbol *next; 210 + struct list_head list; /* link to module::unresolved_symbols */ 212 211 struct module *module; 213 212 char *namespace; 214 213 unsigned int crc; ··· 264 261 265 262 static void sym_add_unresolved(const char *name, struct module *mod, bool weak) 266 263 { 267 - mod->unres = alloc_symbol(name, mod->unres); 268 - mod->unres->weak = weak; 264 + struct symbol *sym; 265 + 266 + sym = alloc_symbol(name, NULL); 267 + sym->weak = weak; 268 + 269 + list_add_tail(&sym->list, &mod->unresolved_symbols); 269 270 } 270 271 271 272 static struct symbol *find_symbol(const char *name) ··· 2163 2156 { 2164 2157 struct symbol *s, *exp; 2165 2158 2166 - for (s = mod->unres; s; s = s->next) { 2159 + list_for_each_entry(s, &mod->unresolved_symbols, list) { 2167 2160 const char *basename; 2168 2161 exp = find_symbol(s->name); 2169 2162 if (!exp) { ··· 2284 2277 buf_printf(b, "static const struct modversion_info ____versions[]\n"); 2285 2278 buf_printf(b, "__used __section(\"__versions\") = {\n"); 2286 2279 2287 - for (s = mod->unres; s; s = s->next) { 2280 + list_for_each_entry(s, &mod->unresolved_symbols, list) { 2288 2281 if (!s->module) 2289 2282 continue; 2290 2283 if (!s->crc_valid) { ··· 2310 2303 int first = 1; 2311 2304 2312 2305 /* Clear ->seen flag of modules that own symbols needed by this. */ 2313 - for (s = mod->unres; s; s = s->next) 2306 + list_for_each_entry(s, &mod->unresolved_symbols, list) { 2314 2307 if (s->module) 2315 2308 s->module->seen = s->module->is_vmlinux; 2309 + } 2316 2310 2317 2311 buf_printf(b, "\n"); 2318 2312 buf_printf(b, "MODULE_INFO(depends, \""); 2319 - for (s = mod->unres; s; s = s->next) { 2313 + list_for_each_entry(s, &mod->unresolved_symbols, list) { 2320 2314 const char *p; 2321 2315 if (!s->module) 2322 2316 continue;
+1 -1
scripts/mod/modpost.h
··· 113 113 114 114 struct module { 115 115 struct list_head list; 116 + struct list_head unresolved_symbols; 116 117 bool is_gpl_compatible; 117 - struct symbol *unres; 118 118 bool from_dump; /* true if module was loaded from *.symvers */ 119 119 bool is_vmlinux; 120 120 bool seen;