diff options
| -rw-r--r-- | arch/mips/boot/elf2ecoff.c | 60 |
1 files changed, 33 insertions, 27 deletions
diff --git a/arch/mips/boot/elf2ecoff.c b/arch/mips/boot/elf2ecoff.c index 8585078ae50e..0b0f3cab068b 100644 --- a/arch/mips/boot/elf2ecoff.c +++ b/arch/mips/boot/elf2ecoff.c | |||
| @@ -349,39 +349,45 @@ int main(int argc, char *argv[]) | |||
| 349 | 349 | ||
| 350 | for (i = 0; i < ex.e_phnum; i++) { | 350 | for (i = 0; i < ex.e_phnum; i++) { |
| 351 | /* Section types we can ignore... */ | 351 | /* Section types we can ignore... */ |
| 352 | if (ph[i].p_type == PT_NULL || ph[i].p_type == PT_NOTE || | 352 | switch (ph[i].p_type) { |
| 353 | ph[i].p_type == PT_PHDR | 353 | case PT_NULL: |
| 354 | || ph[i].p_type == PT_MIPS_REGINFO) | 354 | case PT_NOTE: |
| 355 | case PT_PHDR: | ||
| 356 | case PT_MIPS_REGINFO: | ||
| 355 | continue; | 357 | continue; |
| 356 | /* Section types we can't handle... */ | ||
| 357 | else if (ph[i].p_type != PT_LOAD) { | ||
| 358 | fprintf(stderr, | ||
| 359 | "Program header %d type %d can't be converted.\n", | ||
| 360 | ex.e_phnum, ph[i].p_type); | ||
| 361 | exit(1); | ||
| 362 | } | ||
| 363 | /* Writable (data) segment? */ | ||
| 364 | if (ph[i].p_flags & PF_W) { | ||
| 365 | struct sect ndata, nbss; | ||
| 366 | 358 | ||
| 367 | ndata.vaddr = ph[i].p_vaddr; | 359 | case PT_LOAD: |
| 368 | ndata.len = ph[i].p_filesz; | 360 | /* Writable (data) segment? */ |
| 369 | nbss.vaddr = ph[i].p_vaddr + ph[i].p_filesz; | 361 | if (ph[i].p_flags & PF_W) { |
| 370 | nbss.len = ph[i].p_memsz - ph[i].p_filesz; | 362 | struct sect ndata, nbss; |
| 363 | |||
| 364 | ndata.vaddr = ph[i].p_vaddr; | ||
| 365 | ndata.len = ph[i].p_filesz; | ||
| 366 | nbss.vaddr = ph[i].p_vaddr + ph[i].p_filesz; | ||
| 367 | nbss.len = ph[i].p_memsz - ph[i].p_filesz; | ||
| 371 | 368 | ||
| 372 | combine(&data, &ndata, 0); | 369 | combine(&data, &ndata, 0); |
| 373 | combine(&bss, &nbss, 1); | 370 | combine(&bss, &nbss, 1); |
| 374 | } else { | 371 | } else { |
| 375 | struct sect ntxt; | 372 | struct sect ntxt; |
| 376 | 373 | ||
| 377 | ntxt.vaddr = ph[i].p_vaddr; | 374 | ntxt.vaddr = ph[i].p_vaddr; |
| 378 | ntxt.len = ph[i].p_filesz; | 375 | ntxt.len = ph[i].p_filesz; |
| 379 | 376 | ||
| 380 | combine(&text, &ntxt, 0); | 377 | combine(&text, &ntxt, 0); |
| 378 | } | ||
| 379 | /* Remember the lowest segment start address. */ | ||
| 380 | if (ph[i].p_vaddr < cur_vma) | ||
| 381 | cur_vma = ph[i].p_vaddr; | ||
| 382 | break; | ||
| 383 | |||
| 384 | default: | ||
| 385 | /* Section types we can't handle... */ | ||
| 386 | fprintf(stderr, | ||
| 387 | "Program header %d type %d can't be converted.\n", | ||
| 388 | ex.e_phnum, ph[i].p_type); | ||
| 389 | exit(1); | ||
| 381 | } | 390 | } |
| 382 | /* Remember the lowest segment start address. */ | ||
| 383 | if (ph[i].p_vaddr < cur_vma) | ||
| 384 | cur_vma = ph[i].p_vaddr; | ||
| 385 | } | 391 | } |
| 386 | 392 | ||
| 387 | /* Sections must be in order to be converted... */ | 393 | /* Sections must be in order to be converted... */ |
