Revision 9042c0e2 elf_ops.h
b/elf_ops.h | ||
---|---|---|
153 | 153 |
glue(bswap_ehdr, SZ)(&ehdr); |
154 | 154 |
} |
155 | 155 |
|
156 |
if (ELF_MACHINE != ehdr.e_machine) |
|
157 |
goto fail; |
|
158 |
|
|
156 | 159 |
if (pentry) |
157 | 160 |
*pentry = (uint64_t)ehdr.e_entry; |
158 | 161 |
|
... | ... | |
164 | 167 |
if (!phdr) |
165 | 168 |
goto fail; |
166 | 169 |
if (read(fd, phdr, size) != size) |
167 |
goto fail; |
|
170 |
goto fail1;
|
|
168 | 171 |
if (must_swab) { |
169 | 172 |
for(i = 0; i < ehdr.e_phnum; i++) { |
170 | 173 |
ph = &phdr[i]; |
... | ... | |
181 | 184 |
data = qemu_mallocz(mem_size); |
182 | 185 |
if (ph->p_filesz > 0) { |
183 | 186 |
if (lseek(fd, ph->p_offset, SEEK_SET) < 0) |
184 |
goto fail; |
|
187 |
goto fail2;
|
|
185 | 188 |
if (read(fd, data, ph->p_filesz) != ph->p_filesz) |
186 |
goto fail; |
|
189 |
goto fail2;
|
|
187 | 190 |
} |
188 | 191 |
addr = ph->p_vaddr + virt_to_phys_addend; |
189 | 192 |
|
... | ... | |
197 | 200 |
} |
198 | 201 |
qemu_free(phdr); |
199 | 202 |
return total_size; |
200 |
fail:
|
|
203 |
fail2:
|
|
201 | 204 |
qemu_free(data); |
205 |
fail1: |
|
202 | 206 |
qemu_free(phdr); |
207 |
fail: |
|
203 | 208 |
return -1; |
204 | 209 |
} |
205 | 210 |
|
Also available in: Unified diff