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: add sym_add_unresolved() helper

Add a small helper, sym_add_unresolved() to ease the further
refactoring.

Remove the 'weak' argument from alloc_symbol() because it is sensible
only for unresolved symbols.

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

+11 -8
+11 -8
scripts/mod/modpost.c
··· 236 236 * Allocate a new symbols for use in the hash of exported symbols or 237 237 * the list of unresolved symbols per module 238 238 **/ 239 - static struct symbol *alloc_symbol(const char *name, bool weak, 240 - struct symbol *next) 239 + static struct symbol *alloc_symbol(const char *name, struct symbol *next) 241 240 { 242 241 struct symbol *s = NOFAIL(malloc(sizeof(*s) + strlen(name) + 1)); 243 242 244 243 memset(s, 0, sizeof(*s)); 245 244 strcpy(s->name, name); 246 - s->weak = weak; 247 245 s->next = next; 248 246 s->is_static = true; 249 247 return s; ··· 254 256 unsigned int hash; 255 257 256 258 hash = tdb_hash(name) % SYMBOL_HASH_SIZE; 257 - symbolhash[hash] = alloc_symbol(name, false, symbolhash[hash]); 259 + symbolhash[hash] = alloc_symbol(name, symbolhash[hash]); 258 260 259 261 return symbolhash[hash]; 262 + } 263 + 264 + static void sym_add_unresolved(const char *name, struct module *mod, bool weak) 265 + { 266 + mod->unres = alloc_symbol(name, mod->unres); 267 + mod->unres->weak = weak; 260 268 } 261 269 262 270 static struct symbol *find_symbol(const char *name) ··· 716 712 } 717 713 } 718 714 719 - mod->unres = alloc_symbol(symname, 720 - ELF_ST_BIND(sym->st_info) == STB_WEAK, 721 - mod->unres); 715 + sym_add_unresolved(symname, mod, 716 + ELF_ST_BIND(sym->st_info) == STB_WEAK); 722 717 break; 723 718 default: 724 719 /* All exported symbols */ ··· 2085 2082 * the automatic versioning doesn't pick it up, but it's really 2086 2083 * important anyhow */ 2087 2084 if (modversions) 2088 - mod->unres = alloc_symbol("module_layout", false, mod->unres); 2085 + sym_add_unresolved("module_layout", mod, false); 2089 2086 } 2090 2087 2091 2088 static void read_symbols_from_files(const char *filename)