diff options
Diffstat (limited to 'modutils/modutils-24.c')
-rw-r--r-- | modutils/modutils-24.c | 28 |
1 files changed, 12 insertions, 16 deletions
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 | ||