Bernhard Reutner-Fischer | 55e547e | 2008-05-26 12:01:49 +0000 | [diff] [blame] | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | /* |
| 3 | * depmod - generate modules.dep |
Bernhard Reutner-Fischer | 6c4dade | 2008-09-25 12:13:34 +0000 | [diff] [blame] | 4 | * Copyright (c) 2008 Bernhard Reutner-Fischer |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 5 | * Copyrihgt (c) 2008 Timo Teras <timo.teras@iki.fi> |
| 6 | * Copyright (c) 2008 Vladimir Dronnikov |
Bernhard Reutner-Fischer | 55e547e | 2008-05-26 12:01:49 +0000 | [diff] [blame] | 7 | * |
Denys Vlasenko | 0ef64bd | 2010-08-16 20:14:46 +0200 | [diff] [blame] | 8 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
Bernhard Reutner-Fischer | 55e547e | 2008-05-26 12:01:49 +0000 | [diff] [blame] | 9 | */ |
| 10 | |
Denys Vlasenko | b9f2d9f | 2011-01-18 13:58:01 +0100 | [diff] [blame] | 11 | //applet:IF_DEPMOD(APPLET(depmod, BB_DIR_SBIN, BB_SUID_DROP)) |
Denys Vlasenko | c15613c | 2010-10-15 11:29:02 +0200 | [diff] [blame] | 12 | |
Denys Vlasenko | 043b1e5 | 2009-09-06 12:47:55 +0200 | [diff] [blame] | 13 | #include "libbb.h" |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 14 | #include "modutils.h" |
Denys Vlasenko | 043b1e5 | 2009-09-06 12:47:55 +0200 | [diff] [blame] | 15 | #include <sys/utsname.h> /* uname() */ |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 16 | |
Bernhard Reutner-Fischer | cf18010 | 2008-05-26 15:12:01 +0000 | [diff] [blame] | 17 | /* |
| 18 | * Theory of operation: |
| 19 | * - iterate over all modules and record their full path |
| 20 | * - iterate over all modules looking for "depends=" entries |
| 21 | * for each depends, look through our list of full paths and emit if found |
| 22 | */ |
Bernhard Reutner-Fischer | beac1bd | 2008-06-02 13:28:47 +0000 | [diff] [blame] | 23 | |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 24 | typedef struct module_info { |
| 25 | struct module_info *next; |
| 26 | char *name, *modname; |
Bernhard Reutner-Fischer | beac1bd | 2008-06-02 13:28:47 +0000 | [diff] [blame] | 27 | llist_t *dependencies; |
Bernhard Reutner-Fischer | c2741e1 | 2008-06-02 18:59:16 +0000 | [diff] [blame] | 28 | llist_t *aliases; |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 29 | llist_t *symbols; |
| 30 | struct module_info *dnext, *dprev; |
| 31 | } module_info; |
Bernhard Reutner-Fischer | beac1bd | 2008-06-02 13:28:47 +0000 | [diff] [blame] | 32 | |
Denys Vlasenko | 16bda3b | 2009-05-18 13:08:04 +0200 | [diff] [blame] | 33 | static int FAST_FUNC parse_module(const char *fname, struct stat *sb UNUSED_PARAM, |
Denys Vlasenko | 6967578 | 2013-01-14 01:34:48 +0100 | [diff] [blame] | 34 | void *data, int depth UNUSED_PARAM) |
Bernhard Reutner-Fischer | 55e547e | 2008-05-26 12:01:49 +0000 | [diff] [blame] | 35 | { |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 36 | module_info **first = (module_info **) data; |
| 37 | char *image, *ptr; |
| 38 | module_info *info; |
Denys Vlasenko | 16bda3b | 2009-05-18 13:08:04 +0200 | [diff] [blame] | 39 | /* Arbitrary. Was sb->st_size, but that breaks .gz etc */ |
| 40 | size_t len = (64*1024*1024 - 4096); |
Bernhard Reutner-Fischer | 55e547e | 2008-05-26 12:01:49 +0000 | [diff] [blame] | 41 | |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 42 | if (strrstr(fname, ".ko") == NULL) |
| 43 | return TRUE; |
Bernhard Reutner-Fischer | 634b022 | 2008-05-28 14:20:20 +0000 | [diff] [blame] | 44 | |
Denis Vlasenko | fc66892 | 2008-11-06 02:32:31 +0000 | [diff] [blame] | 45 | image = xmalloc_open_zipped_read_close(fname, &len); |
Denys Vlasenko | 16bda3b | 2009-05-18 13:08:04 +0200 | [diff] [blame] | 46 | info = xzalloc(sizeof(*info)); |
Bernhard Reutner-Fischer | c2741e1 | 2008-06-02 18:59:16 +0000 | [diff] [blame] | 47 | |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 48 | info->next = *first; |
| 49 | *first = info; |
| 50 | |
| 51 | info->dnext = info->dprev = info; |
Denys Vlasenko | 4cab7f3 | 2010-07-18 17:41:17 +0200 | [diff] [blame] | 52 | info->name = xstrdup(fname + 2); /* skip "./" */ |
Denys Vlasenko | cc70b6f | 2015-01-24 22:30:30 +0100 | [diff] [blame] | 53 | info->modname = filename2modname( |
Denys Vlasenko | 08364da | 2015-01-07 14:39:01 +0100 | [diff] [blame] | 54 | bb_get_last_path_component_nostrip(fname), |
Denys Vlasenko | cc70b6f | 2015-01-24 22:30:30 +0100 | [diff] [blame] | 55 | NULL |
| 56 | ); |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 57 | for (ptr = image; ptr < image + len - 10; ptr++) { |
Denys Vlasenko | 8dff01d | 2015-03-12 17:48:34 +0100 | [diff] [blame] | 58 | if (is_prefixed_with(ptr, "depends=")) { |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 59 | char *u; |
| 60 | |
| 61 | ptr += 8; |
| 62 | for (u = ptr; *u; u++) |
| 63 | if (*u == '-') |
| 64 | *u = '_'; |
| 65 | ptr += string_to_llist(ptr, &info->dependencies, ","); |
Denys Vlasenko | 16bda3b | 2009-05-18 13:08:04 +0200 | [diff] [blame] | 66 | } else if (ENABLE_FEATURE_MODUTILS_ALIAS |
Denys Vlasenko | 8dff01d | 2015-03-12 17:48:34 +0100 | [diff] [blame] | 67 | && is_prefixed_with(ptr, "alias=") |
Denys Vlasenko | 16bda3b | 2009-05-18 13:08:04 +0200 | [diff] [blame] | 68 | ) { |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 69 | llist_add_to(&info->aliases, xstrdup(ptr + 6)); |
| 70 | ptr += strlen(ptr); |
Denys Vlasenko | 16bda3b | 2009-05-18 13:08:04 +0200 | [diff] [blame] | 71 | } else if (ENABLE_FEATURE_MODUTILS_SYMBOLS |
Denys Vlasenko | 8dff01d | 2015-03-12 17:48:34 +0100 | [diff] [blame] | 72 | && is_prefixed_with(ptr, "__ksymtab_") |
Denys Vlasenko | 16bda3b | 2009-05-18 13:08:04 +0200 | [diff] [blame] | 73 | ) { |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 74 | ptr += 10; |
Denys Vlasenko | 8dff01d | 2015-03-12 17:48:34 +0100 | [diff] [blame] | 75 | if (is_prefixed_with(ptr, "gpl") |
Denys Vlasenko | 6b9f163 | 2010-01-28 02:24:24 +0100 | [diff] [blame] | 76 | || strcmp(ptr, "strings") == 0 |
| 77 | ) { |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 78 | continue; |
Denys Vlasenko | 6b9f163 | 2010-01-28 02:24:24 +0100 | [diff] [blame] | 79 | } |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 80 | llist_add_to(&info->symbols, xstrdup(ptr)); |
| 81 | ptr += strlen(ptr); |
| 82 | } |
Bernhard Reutner-Fischer | 55e547e | 2008-05-26 12:01:49 +0000 | [diff] [blame] | 83 | } |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 84 | free(image); |
| 85 | |
Bernhard Reutner-Fischer | 55e547e | 2008-05-26 12:01:49 +0000 | [diff] [blame] | 86 | return TRUE; |
| 87 | } |
| 88 | |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 89 | static module_info *find_module(module_info *modules, const char *modname) |
| 90 | { |
| 91 | module_info *m; |
| 92 | |
| 93 | for (m = modules; m != NULL; m = m->next) |
| 94 | if (strcmp(m->modname, modname) == 0) |
| 95 | return m; |
| 96 | return NULL; |
| 97 | } |
| 98 | |
| 99 | static void order_dep_list(module_info *modules, module_info *start, |
Denys Vlasenko | 6967578 | 2013-01-14 01:34:48 +0100 | [diff] [blame] | 100 | llist_t *add) |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 101 | { |
| 102 | module_info *m; |
| 103 | llist_t *n; |
| 104 | |
| 105 | for (n = add; n != NULL; n = n->link) { |
| 106 | m = find_module(modules, n->data); |
| 107 | if (m == NULL) |
| 108 | continue; |
| 109 | |
| 110 | /* unlink current entry */ |
| 111 | m->dnext->dprev = m->dprev; |
| 112 | m->dprev->dnext = m->dnext; |
| 113 | |
| 114 | /* and add it to tail */ |
| 115 | m->dnext = start; |
| 116 | m->dprev = start->dprev; |
| 117 | start->dprev->dnext = m; |
| 118 | start->dprev = m; |
| 119 | |
| 120 | /* recurse */ |
| 121 | order_dep_list(modules, start, m->dependencies); |
| 122 | } |
| 123 | } |
| 124 | |
Denis Vlasenko | 3526115 | 2009-01-12 22:12:22 +0000 | [diff] [blame] | 125 | static void xfreopen_write(const char *file, FILE *f) |
| 126 | { |
| 127 | if (freopen(file, "w", f) == NULL) |
| 128 | bb_perror_msg_and_die("can't open '%s'", file); |
| 129 | } |
| 130 | |
Lauri Kasanen | 5a5db93 | 2012-02-19 16:33:37 +0100 | [diff] [blame] | 131 | //usage:#if !ENABLE_MODPROBE_SMALL |
| 132 | //usage:#define depmod_trivial_usage "[-n] [-b BASE] [VERSION] [MODFILES]..." |
| 133 | //usage:#define depmod_full_usage "\n\n" |
| 134 | //usage: "Generate modules.dep, alias, and symbols files" |
| 135 | //usage: "\n" |
| 136 | //usage: "\n -b BASE Use BASE/lib/modules/VERSION" |
| 137 | //usage: "\n -n Dry run: print files to stdout" |
| 138 | //usage:#endif |
| 139 | |
| 140 | /* Upstream usage: |
Denys Vlasenko | 4cab7f3 | 2010-07-18 17:41:17 +0200 | [diff] [blame] | 141 | * [-aAenv] [-C FILE or DIR] [-b BASE] [-F System.map] [VERSION] [MODFILES]... |
| 142 | * -a --all |
| 143 | * Probe all modules. Default if no MODFILES. |
| 144 | * -A --quick |
| 145 | * Check modules.dep's mtime against module files' mtimes. |
| 146 | * -b --basedir BASE |
| 147 | * Use $BASE/lib/modules/VERSION |
| 148 | * -C --config FILE or DIR |
| 149 | * Path to /etc/depmod.conf or /etc/depmod.d/ |
| 150 | * -e --errsyms |
Lauri Kasanen | 5a5db93 | 2012-02-19 16:33:37 +0100 | [diff] [blame] | 151 | * When combined with the -F option, this reports any symbols |
Denys Vlasenko | 4cab7f3 | 2010-07-18 17:41:17 +0200 | [diff] [blame] | 152 | * which are not supplied by other modules or kernel. |
| 153 | * -F --filesyms System.map |
| 154 | * -n --dry-run |
| 155 | * Print modules.dep etc to standard output |
| 156 | * -v --verbose |
| 157 | * Print to stdout all the symbols each module depends on |
| 158 | * and the module's file name which provides that symbol. |
| 159 | * -r No-op |
Pascal Bellard | cadf901 | 2010-10-18 00:51:16 +0200 | [diff] [blame] | 160 | * -u No-op |
| 161 | * -q No-op |
Denys Vlasenko | 4cab7f3 | 2010-07-18 17:41:17 +0200 | [diff] [blame] | 162 | * |
Lauri Kasanen | 5a5db93 | 2012-02-19 16:33:37 +0100 | [diff] [blame] | 163 | * So far we only support: [-n] [-b BASE] [VERSION] [MODFILES]... |
| 164 | * Accepted but ignored: |
| 165 | * -aAe |
| 166 | * -F System.map |
| 167 | * -C FILE/DIR |
| 168 | * |
| 169 | * Not accepted: -v |
Denys Vlasenko | 4cab7f3 | 2010-07-18 17:41:17 +0200 | [diff] [blame] | 170 | */ |
| 171 | enum { |
| 172 | //OPT_a = (1 << 0), /* All modules, ignore mods in argv */ |
| 173 | //OPT_A = (1 << 1), /* Only emit .ko that are newer than modules.dep file */ |
| 174 | OPT_b = (1 << 2), /* base directory when modules are in staging area */ |
| 175 | //OPT_e = (1 << 3), /* with -F, print unresolved symbols */ |
| 176 | //OPT_F = (1 << 4), /* System.map that contains the symbols */ |
| 177 | OPT_n = (1 << 5), /* dry-run, print to stdout only */ |
Pascal Bellard | cadf901 | 2010-10-18 00:51:16 +0200 | [diff] [blame] | 178 | OPT_r = (1 << 6), /* Compat dummy. Linux Makefile uses it */ |
| 179 | OPT_u = (1 << 7), /* -u,--unresolved-error: ignored */ |
| 180 | OPT_q = (1 << 8), /* -q,--quiet: ignored */ |
| 181 | OPT_C = (1 << 9), /* -C,--config etc_modules_conf: ignored */ |
Denys Vlasenko | 4cab7f3 | 2010-07-18 17:41:17 +0200 | [diff] [blame] | 182 | }; |
| 183 | |
Bernhard Reutner-Fischer | 55e547e | 2008-05-26 12:01:49 +0000 | [diff] [blame] | 184 | int depmod_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
Denis Vlasenko | a60f84e | 2008-07-05 09:18:54 +0000 | [diff] [blame] | 185 | int depmod_main(int argc UNUSED_PARAM, char **argv) |
Bernhard Reutner-Fischer | 55e547e | 2008-05-26 12:01:49 +0000 | [diff] [blame] | 186 | { |
Denys Vlasenko | 4cab7f3 | 2010-07-18 17:41:17 +0200 | [diff] [blame] | 187 | module_info *modules, *m, *dep; |
Denis Vlasenko | 3526115 | 2009-01-12 22:12:22 +0000 | [diff] [blame] | 188 | const char *moddir_base = "/"; |
| 189 | char *moddir, *version; |
| 190 | struct utsname uts; |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 191 | int tmp; |
Bernhard Reutner-Fischer | 55e547e | 2008-05-26 12:01:49 +0000 | [diff] [blame] | 192 | |
Pascal Bellard | cadf901 | 2010-10-18 00:51:16 +0200 | [diff] [blame] | 193 | getopt32(argv, "aAb:eF:nruqC:", &moddir_base, NULL, NULL); |
Bernhard Reutner-Fischer | 6bb55cf | 2008-05-26 17:04:01 +0000 | [diff] [blame] | 194 | argv += optind; |
Bernhard Reutner-Fischer | c21d9c7 | 2008-05-28 10:35:51 +0000 | [diff] [blame] | 195 | |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 196 | /* goto modules location */ |
Denis Vlasenko | 3526115 | 2009-01-12 22:12:22 +0000 | [diff] [blame] | 197 | xchdir(moddir_base); |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 198 | |
| 199 | /* If a version is provided, then that kernel version's module directory |
Bernhard Reutner-Fischer | beac1bd | 2008-06-02 13:28:47 +0000 | [diff] [blame] | 200 | * is used, rather than the current kernel version (as returned by |
| 201 | * "uname -r"). */ |
Denys Vlasenko | 4cab7f3 | 2010-07-18 17:41:17 +0200 | [diff] [blame] | 202 | if (*argv && sscanf(*argv, "%u.%u.%u", &tmp, &tmp, &tmp) == 3) { |
Denis Vlasenko | 3526115 | 2009-01-12 22:12:22 +0000 | [diff] [blame] | 203 | version = *argv++; |
Bernhard Reutner-Fischer | 1ea2568 | 2008-05-26 21:33:05 +0000 | [diff] [blame] | 204 | } else { |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 205 | uname(&uts); |
Denis Vlasenko | 3526115 | 2009-01-12 22:12:22 +0000 | [diff] [blame] | 206 | version = uts.release; |
Bernhard Reutner-Fischer | 6bb55cf | 2008-05-26 17:04:01 +0000 | [diff] [blame] | 207 | } |
Denis Vlasenko | 3526115 | 2009-01-12 22:12:22 +0000 | [diff] [blame] | 208 | moddir = concat_path_file(&CONFIG_DEFAULT_MODULES_DIR[1], version); |
Denis Vlasenko | 3526115 | 2009-01-12 22:12:22 +0000 | [diff] [blame] | 209 | xchdir(moddir); |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 210 | if (ENABLE_FEATURE_CLEAN_UP) |
Denis Vlasenko | 3526115 | 2009-01-12 22:12:22 +0000 | [diff] [blame] | 211 | free(moddir); |
Bernhard Reutner-Fischer | 6bb55cf | 2008-05-26 17:04:01 +0000 | [diff] [blame] | 212 | |
Denys Vlasenko | 4cab7f3 | 2010-07-18 17:41:17 +0200 | [diff] [blame] | 213 | /* Scan modules */ |
| 214 | modules = NULL; |
| 215 | if (*argv) { |
| 216 | do { |
| 217 | parse_module(*argv, /*sb (unused):*/ NULL, &modules, 0); |
| 218 | } while (*++argv); |
| 219 | } else { |
| 220 | recursive_action(".", ACTION_RECURSE, |
Denys Vlasenko | 6967578 | 2013-01-14 01:34:48 +0100 | [diff] [blame] | 221 | parse_module, NULL, &modules, 0); |
Denys Vlasenko | 4cab7f3 | 2010-07-18 17:41:17 +0200 | [diff] [blame] | 222 | } |
| 223 | |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 224 | /* Generate dependency and alias files */ |
Denys Vlasenko | 4cab7f3 | 2010-07-18 17:41:17 +0200 | [diff] [blame] | 225 | if (!(option_mask32 & OPT_n)) |
Denis Vlasenko | 3526115 | 2009-01-12 22:12:22 +0000 | [diff] [blame] | 226 | xfreopen_write(CONFIG_DEFAULT_DEPMOD_FILE, stdout); |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 227 | for (m = modules; m != NULL; m = m->next) { |
| 228 | printf("%s:", m->name); |
| 229 | |
| 230 | order_dep_list(modules, m, m->dependencies); |
| 231 | while (m->dnext != m) { |
| 232 | dep = m->dnext; |
| 233 | printf(" %s", dep->name); |
| 234 | |
| 235 | /* unlink current entry */ |
| 236 | dep->dnext->dprev = dep->dprev; |
| 237 | dep->dprev->dnext = dep->dnext; |
| 238 | dep->dnext = dep->dprev = dep; |
Bernhard Reutner-Fischer | 55e547e | 2008-05-26 12:01:49 +0000 | [diff] [blame] | 239 | } |
Denis Vlasenko | 3526115 | 2009-01-12 22:12:22 +0000 | [diff] [blame] | 240 | bb_putchar('\n'); |
Bernhard Reutner-Fischer | c2741e1 | 2008-06-02 18:59:16 +0000 | [diff] [blame] | 241 | } |
| 242 | |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 243 | #if ENABLE_FEATURE_MODUTILS_ALIAS |
Denys Vlasenko | 4cab7f3 | 2010-07-18 17:41:17 +0200 | [diff] [blame] | 244 | if (!(option_mask32 & OPT_n)) |
Denis Vlasenko | 3526115 | 2009-01-12 22:12:22 +0000 | [diff] [blame] | 245 | xfreopen_write("modules.alias", stdout); |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 246 | for (m = modules; m != NULL; m = m->next) { |
Denys Vlasenko | 08364da | 2015-01-07 14:39:01 +0100 | [diff] [blame] | 247 | char modname[MODULE_NAME_LEN]; |
Denys Vlasenko | 16bda3b | 2009-05-18 13:08:04 +0200 | [diff] [blame] | 248 | const char *fname = bb_basename(m->name); |
Denys Vlasenko | 08364da | 2015-01-07 14:39:01 +0100 | [diff] [blame] | 249 | filename2modname(fname, modname); |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 250 | while (m->aliases) { |
Denys Vlasenko | cc70b6f | 2015-01-24 22:30:30 +0100 | [diff] [blame] | 251 | /* |
| 252 | * Last word used to be a basename |
| 253 | * (filename with path and .ko.* stripped) |
| 254 | * at the time of module-init-tools 3.4. |
| 255 | * kmod v.12 uses module name, i.e., s/-/_/g. |
| 256 | */ |
Denys Vlasenko | 08364da | 2015-01-07 14:39:01 +0100 | [diff] [blame] | 257 | printf("alias %s %s\n", |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 258 | (char*)llist_pop(&m->aliases), |
Denys Vlasenko | 08364da | 2015-01-07 14:39:01 +0100 | [diff] [blame] | 259 | modname); |
Bernhard Reutner-Fischer | beac1bd | 2008-06-02 13:28:47 +0000 | [diff] [blame] | 260 | } |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 261 | } |
| 262 | #endif |
| 263 | #if ENABLE_FEATURE_MODUTILS_SYMBOLS |
Denys Vlasenko | 4cab7f3 | 2010-07-18 17:41:17 +0200 | [diff] [blame] | 264 | if (!(option_mask32 & OPT_n)) |
Denis Vlasenko | 3526115 | 2009-01-12 22:12:22 +0000 | [diff] [blame] | 265 | xfreopen_write("modules.symbols", stdout); |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 266 | for (m = modules; m != NULL; m = m->next) { |
Denys Vlasenko | 08364da | 2015-01-07 14:39:01 +0100 | [diff] [blame] | 267 | char modname[MODULE_NAME_LEN]; |
Denys Vlasenko | 16bda3b | 2009-05-18 13:08:04 +0200 | [diff] [blame] | 268 | const char *fname = bb_basename(m->name); |
Denys Vlasenko | 08364da | 2015-01-07 14:39:01 +0100 | [diff] [blame] | 269 | filename2modname(fname, modname); |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 270 | while (m->symbols) { |
Denys Vlasenko | 08364da | 2015-01-07 14:39:01 +0100 | [diff] [blame] | 271 | printf("alias symbol:%s %s\n", |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 272 | (char*)llist_pop(&m->symbols), |
Denys Vlasenko | 08364da | 2015-01-07 14:39:01 +0100 | [diff] [blame] | 273 | modname); |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 274 | } |
Bernhard Reutner-Fischer | beac1bd | 2008-06-02 13:28:47 +0000 | [diff] [blame] | 275 | } |
Bernhard Reutner-Fischer | c2741e1 | 2008-06-02 18:59:16 +0000 | [diff] [blame] | 276 | #endif |
Bernhard Reutner-Fischer | beac1bd | 2008-06-02 13:28:47 +0000 | [diff] [blame] | 277 | |
Bernhard Reutner-Fischer | dc5d7fe | 2008-05-26 13:30:41 +0000 | [diff] [blame] | 278 | if (ENABLE_FEATURE_CLEAN_UP) { |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 279 | while (modules) { |
| 280 | module_info *old = modules; |
| 281 | modules = modules->next; |
Bernhard Reutner-Fischer | beac1bd | 2008-06-02 13:28:47 +0000 | [diff] [blame] | 282 | free(old->name); |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 283 | free(old->modname); |
Bernhard Reutner-Fischer | beac1bd | 2008-06-02 13:28:47 +0000 | [diff] [blame] | 284 | free(old); |
| 285 | } |
Bernhard Reutner-Fischer | dc5d7fe | 2008-05-26 13:30:41 +0000 | [diff] [blame] | 286 | } |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 287 | |
| 288 | return EXIT_SUCCESS; |
Bernhard Reutner-Fischer | 55e547e | 2008-05-26 12:01:49 +0000 | [diff] [blame] | 289 | } |