diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2009-02-26 11:57:01 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2009-02-26 11:57:01 +0000 |
commit | a76f10b544b4ffe4b0aaf41eede1aeb9b13a95e8 (patch) | |
tree | a41295eaee4b3f28a6e20df4e592ffacc42ac4ab /modutils | |
parent | 15c0b725849875c718b168a26e13872e163cde4c (diff) | |
download | busybox-w32-a76f10b544b4ffe4b0aaf41eede1aeb9b13a95e8.tar.gz busybox-w32-a76f10b544b4ffe4b0aaf41eede1aeb9b13a95e8.tar.bz2 busybox-w32-a76f10b544b4ffe4b0aaf41eede1aeb9b13a95e8.zip |
Apply post-1.13.2 fixes, bump version to 1.13.3
Diffstat (limited to 'modutils')
-rw-r--r-- | modutils/depmod.c | 57 | ||||
-rw-r--r-- | modutils/modutils-24.c | 28 |
2 files changed, 49 insertions, 36 deletions
diff --git a/modutils/depmod.c b/modutils/depmod.c index a4474d5e4..7f3e1d8a6 100644 --- a/modutils/depmod.c +++ b/modutils/depmod.c | |||
@@ -33,7 +33,7 @@ typedef struct module_info { | |||
33 | enum { | 33 | enum { |
34 | ARG_a = (1<<0), /* All modules, ignore mods in argv */ | 34 | ARG_a = (1<<0), /* All modules, ignore mods in argv */ |
35 | ARG_A = (1<<1), /* Only emit .ko that are newer than modules.dep file */ | 35 | ARG_A = (1<<1), /* Only emit .ko that are newer than modules.dep file */ |
36 | ARG_b = (1<<2), /* not /lib/modules/$(uname -r)/ but this base-dir */ | 36 | ARG_b = (1<<2), /* base directory when modules are in staging area */ |
37 | ARG_e = (1<<3), /* with -F, print unresolved symbols */ | 37 | ARG_e = (1<<3), /* with -F, print unresolved symbols */ |
38 | ARG_F = (1<<4), /* System.map that contains the symbols */ | 38 | ARG_F = (1<<4), /* System.map that contains the symbols */ |
39 | ARG_n = (1<<5) /* dry-run, print to stdout only */ | 39 | ARG_n = (1<<5) /* dry-run, print to stdout only */ |
@@ -57,7 +57,7 @@ static int FAST_FUNC parse_module(const char *fname, struct stat *sb, | |||
57 | *first = info; | 57 | *first = info; |
58 | 58 | ||
59 | info->dnext = info->dprev = info; | 59 | info->dnext = info->dprev = info; |
60 | info->name = xstrdup(fname); | 60 | info->name = xasprintf("/%s", fname); |
61 | info->modname = filename2modname(fname, NULL); | 61 | info->modname = filename2modname(fname, NULL); |
62 | for (ptr = image; ptr < image + len - 10; ptr++) { | 62 | for (ptr = image; ptr < image + len - 10; ptr++) { |
63 | if (strncmp(ptr, "depends=", 8) == 0) { | 63 | if (strncmp(ptr, "depends=", 8) == 0) { |
@@ -123,44 +123,61 @@ static void order_dep_list(module_info *modules, module_info *start, | |||
123 | } | 123 | } |
124 | } | 124 | } |
125 | 125 | ||
126 | static void xfreopen_write(const char *file, FILE *f) | ||
127 | { | ||
128 | if (freopen(file, "w", f) == NULL) | ||
129 | bb_perror_msg_and_die("can't open '%s'", file); | ||
130 | } | ||
131 | |||
126 | int depmod_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 132 | int depmod_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
127 | int depmod_main(int argc UNUSED_PARAM, char **argv) | 133 | int depmod_main(int argc UNUSED_PARAM, char **argv) |
128 | { | 134 | { |
129 | module_info *modules = NULL, *m, *dep; | 135 | module_info *modules = NULL, *m, *dep; |
130 | char *moddir_base = (char *)CONFIG_DEFAULT_MODULES_DIR; | 136 | const char *moddir_base = "/"; |
137 | char *moddir, *version; | ||
138 | struct utsname uts; | ||
131 | int tmp; | 139 | int tmp; |
132 | 140 | ||
133 | getopt32(argv, "aAb:eF:n", &moddir_base, NULL); | 141 | getopt32(argv, "aAb:eF:n", &moddir_base, NULL); |
134 | argv += optind; | 142 | argv += optind; |
135 | 143 | ||
136 | /* goto modules location */ | 144 | /* goto modules location */ |
145 | xchdir(moddir_base); | ||
137 | 146 | ||
138 | /* If a version is provided, then that kernel version's module directory | 147 | /* If a version is provided, then that kernel version's module directory |
139 | * is used, rather than the current kernel version (as returned by | 148 | * is used, rather than the current kernel version (as returned by |
140 | * "uname -r"). */ | 149 | * "uname -r"). */ |
141 | xchdir(moddir_base); | 150 | if (*argv && sscanf(*argv, "%d.%d.%d", &tmp, &tmp, &tmp) == 3) { |
142 | if (*argv && (sscanf(*argv, "%d.%d.%d", &tmp, &tmp, &tmp) == 3)) { | 151 | version = *argv++; |
143 | xchdir(*argv++); | ||
144 | } else { | 152 | } else { |
145 | struct utsname uts; | ||
146 | uname(&uts); | 153 | uname(&uts); |
147 | xchdir(uts.release); | 154 | version = uts.release; |
148 | } | 155 | } |
149 | /* If no modules are given on the command-line, -a is on per default. */ | 156 | moddir = concat_path_file(&CONFIG_DEFAULT_MODULES_DIR[1], version); |
150 | option_mask32 |= *argv == NULL; | ||
151 | 157 | ||
152 | /* Scan modules */ | 158 | /* Scan modules */ |
153 | moddir_base = xrealloc_getcwd_or_warn(NULL); | 159 | if (*argv) { |
154 | do { | 160 | char *modfile; |
155 | recursive_action((option_mask32 & ARG_a) ? moddir_base : *argv, | 161 | struct stat sb; |
156 | ACTION_RECURSE, parse_module, NULL, &modules, 0); | 162 | do { |
157 | } while (!(option_mask32 & ARG_a) && *(++argv)); | 163 | modfile = concat_path_file(moddir, *argv); |
164 | xstat(modfile, &sb); | ||
165 | parse_module(modfile, &sb, &modules, 0); | ||
166 | free(modfile); | ||
167 | } while (*(++argv)); | ||
168 | } else { | ||
169 | recursive_action(moddir, ACTION_RECURSE, | ||
170 | parse_module, NULL, &modules, 0); | ||
171 | } | ||
172 | |||
173 | /* Prepare for writing out the dep files */ | ||
174 | xchdir(moddir); | ||
158 | if (ENABLE_FEATURE_CLEAN_UP) | 175 | if (ENABLE_FEATURE_CLEAN_UP) |
159 | free(moddir_base); | 176 | free(moddir); |
160 | 177 | ||
161 | /* Generate dependency and alias files */ | 178 | /* Generate dependency and alias files */ |
162 | if (!(option_mask32 & ARG_n)) | 179 | if (!(option_mask32 & ARG_n)) |
163 | freopen(CONFIG_DEFAULT_DEPMOD_FILE, "w", stdout); | 180 | xfreopen_write(CONFIG_DEFAULT_DEPMOD_FILE, stdout); |
164 | for (m = modules; m != NULL; m = m->next) { | 181 | for (m = modules; m != NULL; m = m->next) { |
165 | printf("%s:", m->name); | 182 | printf("%s:", m->name); |
166 | 183 | ||
@@ -174,12 +191,12 @@ int depmod_main(int argc UNUSED_PARAM, char **argv) | |||
174 | dep->dprev->dnext = dep->dnext; | 191 | dep->dprev->dnext = dep->dnext; |
175 | dep->dnext = dep->dprev = dep; | 192 | dep->dnext = dep->dprev = dep; |
176 | } | 193 | } |
177 | puts(""); | 194 | bb_putchar('\n'); |
178 | } | 195 | } |
179 | 196 | ||
180 | #if ENABLE_FEATURE_MODUTILS_ALIAS | 197 | #if ENABLE_FEATURE_MODUTILS_ALIAS |
181 | if (!(option_mask32 & ARG_n)) | 198 | if (!(option_mask32 & ARG_n)) |
182 | freopen("modules.alias", "w", stdout); | 199 | xfreopen_write("modules.alias", stdout); |
183 | for (m = modules; m != NULL; m = m->next) { | 200 | for (m = modules; m != NULL; m = m->next) { |
184 | while (m->aliases) { | 201 | while (m->aliases) { |
185 | printf("alias %s %s\n", | 202 | printf("alias %s %s\n", |
@@ -190,7 +207,7 @@ int depmod_main(int argc UNUSED_PARAM, char **argv) | |||
190 | #endif | 207 | #endif |
191 | #if ENABLE_FEATURE_MODUTILS_SYMBOLS | 208 | #if ENABLE_FEATURE_MODUTILS_SYMBOLS |
192 | if (!(option_mask32 & ARG_n)) | 209 | if (!(option_mask32 & ARG_n)) |
193 | freopen("modules.symbols", "w", stdout); | 210 | xfreopen_write("modules.symbols", stdout); |
194 | for (m = modules; m != NULL; m = m->next) { | 211 | for (m = modules; m != NULL; m = m->next) { |
195 | while (m->symbols) { | 212 | while (m->symbols) { |
196 | printf("alias symbol:%s %s\n", | 213 | printf("alias symbol:%s %s\n", |
diff --git a/modutils/modutils-24.c b/modutils/modutils-24.c index c6e7226cd..622ab3abe 100644 --- a/modutils/modutils-24.c +++ b/modutils/modutils-24.c | |||
@@ -2150,7 +2150,7 @@ static struct obj_section *obj_create_alloced_section(struct obj_file *f, | |||
2150 | sec->name = name; | 2150 | sec->name = name; |
2151 | sec->idx = newidx; | 2151 | sec->idx = newidx; |
2152 | if (size) | 2152 | if (size) |
2153 | sec->contents = xmalloc(size); | 2153 | sec->contents = xzalloc(size); |
2154 | 2154 | ||
2155 | obj_insert_section_load_order(f, sec); | 2155 | obj_insert_section_load_order(f, sec); |
2156 | 2156 | ||
@@ -2165,7 +2165,7 @@ static struct obj_section *obj_create_alloced_section_first(struct obj_file *f, | |||
2165 | int newidx = f->header.e_shnum++; | 2165 | int newidx = f->header.e_shnum++; |
2166 | struct obj_section *sec; | 2166 | struct obj_section *sec; |
2167 | 2167 | ||
2168 | f->sections = xrealloc(f->sections, (newidx + 1) * sizeof(sec)); | 2168 | f->sections = xrealloc_vector(f->sections, 2, newidx); |
2169 | f->sections[newidx] = sec = arch_new_section(); | 2169 | f->sections[newidx] = sec = arch_new_section(); |
2170 | 2170 | ||
2171 | sec->header.sh_type = SHT_PROGBITS; | 2171 | sec->header.sh_type = SHT_PROGBITS; |
@@ -2175,7 +2175,7 @@ static struct obj_section *obj_create_alloced_section_first(struct obj_file *f, | |||
2175 | sec->name = name; | 2175 | sec->name = name; |
2176 | sec->idx = newidx; | 2176 | sec->idx = newidx; |
2177 | if (size) | 2177 | if (size) |
2178 | sec->contents = xmalloc(size); | 2178 | sec->contents = xzalloc(size); |
2179 | 2179 | ||
2180 | sec->load_next = f->load_order; | 2180 | sec->load_next = f->load_order; |
2181 | f->load_order = sec; | 2181 | f->load_order = sec; |
@@ -2571,8 +2571,7 @@ static void new_get_kernel_symbols(void) | |||
2571 | /* Collect the modules' symbols. */ | 2571 | /* Collect the modules' symbols. */ |
2572 | 2572 | ||
2573 | if (nmod) { | 2573 | if (nmod) { |
2574 | ext_modules = modules = xmalloc(nmod * sizeof(*modules)); | 2574 | ext_modules = modules = xzalloc(nmod * sizeof(*modules)); |
2575 | memset(modules, 0, nmod * sizeof(*modules)); | ||
2576 | for (i = 0, mn = module_names, m = modules; | 2575 | for (i = 0, mn = module_names, m = modules; |
2577 | i < nmod; ++i, ++m, mn += strlen(mn) + 1) { | 2576 | i < nmod; ++i, ++m, mn += strlen(mn) + 1) { |
2578 | struct new_module_info info; | 2577 | struct new_module_info info; |
@@ -2652,13 +2651,14 @@ static int new_is_kernel_checksummed(void) | |||
2652 | } | 2651 | } |
2653 | 2652 | ||
2654 | 2653 | ||
2655 | static void new_create_this_module(struct obj_file *f, const char *m_name) | 2654 | static void new_create_this_module(struct obj_file *f, const char *m_name) |
2656 | { | 2655 | { |
2657 | struct obj_section *sec; | 2656 | struct obj_section *sec; |
2658 | 2657 | ||
2659 | sec = obj_create_alloced_section_first(f, ".this", tgt_sizeof_long, | 2658 | sec = obj_create_alloced_section_first(f, ".this", tgt_sizeof_long, |
2660 | sizeof(struct new_module)); | 2659 | sizeof(struct new_module)); |
2661 | memset(sec->contents, 0, sizeof(struct new_module)); | 2660 | /* done by obj_create_alloced_section_first: */ |
2661 | /*memset(sec->contents, 0, sizeof(struct new_module));*/ | ||
2662 | 2662 | ||
2663 | obj_add_symbol(f, SPFX "__this_module", -1, | 2663 | obj_add_symbol(f, SPFX "__this_module", -1, |
2664 | ELF_ST_INFO(STB_LOCAL, STT_OBJECT), sec->idx, 0, | 2664 | ELF_ST_INFO(STB_LOCAL, STT_OBJECT), sec->idx, 0, |
@@ -2965,9 +2965,9 @@ static void obj_allocate_commons(struct obj_file *f) | |||
2965 | if (i == f->header.e_shnum) { | 2965 | if (i == f->header.e_shnum) { |
2966 | struct obj_section *sec; | 2966 | struct obj_section *sec; |
2967 | 2967 | ||
2968 | f->header.e_shnum++; | ||
2968 | f->sections = xrealloc_vector(f->sections, 2, i); | 2969 | f->sections = xrealloc_vector(f->sections, 2, i); |
2969 | f->sections[i] = sec = arch_new_section(); | 2970 | f->sections[i] = sec = arch_new_section(); |
2970 | f->header.e_shnum = i + 1; | ||
2971 | 2971 | ||
2972 | sec->header.sh_type = SHT_PROGBITS; | 2972 | sec->header.sh_type = SHT_PROGBITS; |
2973 | sec->header.sh_flags = SHF_WRITE | SHF_ALLOC; | 2973 | sec->header.sh_flags = SHF_WRITE | SHF_ALLOC; |
@@ -3006,12 +3006,9 @@ static void obj_allocate_commons(struct obj_file *f) | |||
3006 | for (i = 0; i < f->header.e_shnum; ++i) { | 3006 | for (i = 0; i < f->header.e_shnum; ++i) { |
3007 | struct obj_section *s = f->sections[i]; | 3007 | struct obj_section *s = f->sections[i]; |
3008 | if (s->header.sh_type == SHT_NOBITS) { | 3008 | if (s->header.sh_type == SHT_NOBITS) { |
3009 | s->contents = NULL; | ||
3009 | if (s->header.sh_size != 0) | 3010 | if (s->header.sh_size != 0) |
3010 | s->contents = memset(xmalloc(s->header.sh_size), | 3011 | s->contents = xzalloc(s->header.sh_size); |
3011 | 0, s->header.sh_size); | ||
3012 | else | ||
3013 | s->contents = NULL; | ||
3014 | |||
3015 | s->header.sh_type = SHT_PROGBITS; | 3012 | s->header.sh_type = SHT_PROGBITS; |
3016 | } | 3013 | } |
3017 | } | 3014 | } |
@@ -3275,14 +3272,13 @@ static struct obj_file *obj_load(FILE *fp, int loadprogbits UNUSED_PARAM) | |||
3275 | case SHT_SYMTAB: | 3272 | case SHT_SYMTAB: |
3276 | case SHT_STRTAB: | 3273 | case SHT_STRTAB: |
3277 | case SHT_RELM: | 3274 | case SHT_RELM: |
3275 | sec->contents = NULL; | ||
3278 | if (sec->header.sh_size > 0) { | 3276 | if (sec->header.sh_size > 0) { |
3279 | sec->contents = xmalloc(sec->header.sh_size); | 3277 | sec->contents = xzalloc(sec->header.sh_size); |
3280 | fseek(fp, sec->header.sh_offset, SEEK_SET); | 3278 | fseek(fp, sec->header.sh_offset, SEEK_SET); |
3281 | if (fread(sec->contents, sec->header.sh_size, 1, fp) != 1) { | 3279 | if (fread(sec->contents, sec->header.sh_size, 1, fp) != 1) { |
3282 | bb_perror_msg_and_die("error reading ELF section data"); | 3280 | bb_perror_msg_and_die("error reading ELF section data"); |
3283 | } | 3281 | } |
3284 | } else { | ||
3285 | sec->contents = NULL; | ||
3286 | } | 3282 | } |
3287 | break; | 3283 | break; |
3288 | 3284 | ||