| .. | .. |
|---|
| 7 | 7 | |
|---|
| 8 | 8 | static void BITSFUNC(go)(void *raw_addr, size_t raw_len, |
|---|
| 9 | 9 | void *stripped_addr, size_t stripped_len, |
|---|
| 10 | | - FILE *outfile, const char *name) |
|---|
| 10 | + FILE *outfile, const char *image_name) |
|---|
| 11 | 11 | { |
|---|
| 12 | 12 | int found_load = 0; |
|---|
| 13 | 13 | unsigned long load_size = -1; /* Work around bogus warning */ |
|---|
| 14 | 14 | unsigned long mapping_size; |
|---|
| 15 | 15 | ELF(Ehdr) *hdr = (ELF(Ehdr) *)raw_addr; |
|---|
| 16 | | - int i; |
|---|
| 17 | | - unsigned long j; |
|---|
| 16 | + unsigned long i, syms_nr; |
|---|
| 18 | 17 | ELF(Shdr) *symtab_hdr = NULL, *strtab_hdr, *secstrings_hdr, |
|---|
| 19 | 18 | *alt_sec = NULL; |
|---|
| 20 | 19 | ELF(Dyn) *dyn = 0, *dyn_end = 0; |
|---|
| .. | .. |
|---|
| 86 | 85 | strtab_hdr = raw_addr + GET_LE(&hdr->e_shoff) + |
|---|
| 87 | 86 | GET_LE(&hdr->e_shentsize) * GET_LE(&symtab_hdr->sh_link); |
|---|
| 88 | 87 | |
|---|
| 88 | + syms_nr = GET_LE(&symtab_hdr->sh_size) / GET_LE(&symtab_hdr->sh_entsize); |
|---|
| 89 | 89 | /* Walk the symbol table */ |
|---|
| 90 | | - for (i = 0; |
|---|
| 91 | | - i < GET_LE(&symtab_hdr->sh_size) / GET_LE(&symtab_hdr->sh_entsize); |
|---|
| 92 | | - i++) { |
|---|
| 93 | | - int k; |
|---|
| 90 | + for (i = 0; i < syms_nr; i++) { |
|---|
| 91 | + unsigned int k; |
|---|
| 94 | 92 | ELF(Sym) *sym = raw_addr + GET_LE(&symtab_hdr->sh_offset) + |
|---|
| 95 | 93 | GET_LE(&symtab_hdr->sh_entsize) * i; |
|---|
| 96 | | - const char *name = raw_addr + GET_LE(&strtab_hdr->sh_offset) + |
|---|
| 97 | | - GET_LE(&sym->st_name); |
|---|
| 94 | + const char *sym_name = raw_addr + |
|---|
| 95 | + GET_LE(&strtab_hdr->sh_offset) + |
|---|
| 96 | + GET_LE(&sym->st_name); |
|---|
| 98 | 97 | |
|---|
| 99 | 98 | for (k = 0; k < NSYMS; k++) { |
|---|
| 100 | | - if (!strcmp(name, required_syms[k].name)) { |
|---|
| 99 | + if (!strcmp(sym_name, required_syms[k].name)) { |
|---|
| 101 | 100 | if (syms[k]) { |
|---|
| 102 | 101 | fail("duplicate symbol %s\n", |
|---|
| 103 | 102 | required_syms[k].name); |
|---|
| .. | .. |
|---|
| 134 | 133 | if (syms[sym_vvar_start] % 4096) |
|---|
| 135 | 134 | fail("vvar_begin must be a multiple of 4096\n"); |
|---|
| 136 | 135 | |
|---|
| 137 | | - if (!name) { |
|---|
| 136 | + if (!image_name) { |
|---|
| 138 | 137 | fwrite(stripped_addr, stripped_len, 1, outfile); |
|---|
| 139 | 138 | return; |
|---|
| 140 | 139 | } |
|---|
| .. | .. |
|---|
| 149 | 148 | fprintf(outfile, |
|---|
| 150 | 149 | "static unsigned char raw_data[%lu] __ro_after_init __aligned(PAGE_SIZE) = {", |
|---|
| 151 | 150 | mapping_size); |
|---|
| 152 | | - for (j = 0; j < stripped_len; j++) { |
|---|
| 153 | | - if (j % 10 == 0) |
|---|
| 151 | + for (i = 0; i < stripped_len; i++) { |
|---|
| 152 | + if (i % 10 == 0) |
|---|
| 154 | 153 | fprintf(outfile, "\n\t"); |
|---|
| 155 | 154 | fprintf(outfile, "0x%02X, ", |
|---|
| 156 | | - (int)((unsigned char *)stripped_addr)[j]); |
|---|
| 155 | + (int)((unsigned char *)stripped_addr)[i]); |
|---|
| 157 | 156 | } |
|---|
| 158 | 157 | fprintf(outfile, "\n};\n\n"); |
|---|
| 159 | 158 | |
|---|
| 160 | | - fprintf(outfile, "const struct vdso_image %s = {\n", name); |
|---|
| 159 | + fprintf(outfile, "const struct vdso_image %s = {\n", image_name); |
|---|
| 161 | 160 | fprintf(outfile, "\t.data = raw_data,\n"); |
|---|
| 162 | 161 | fprintf(outfile, "\t.size = %lu,\n", mapping_size); |
|---|
| 163 | 162 | if (alt_sec) { |
|---|