--- trunk/src/file.c 2007/10/08 16:18:51 14 +++ trunk/src/file.c 2007/10/08 16:19:23 20 @@ -25,7 +25,7 @@ * SUCH DAMAGE. * * - * $Id: file.c,v 1.116 2005/09/30 14:07:45 debug Exp $ + * $Id: file.c,v 1.119 2005/11/19 21:00:59 debug Exp $ * * This file contains functions which load executable images into (emulated) * memory. File formats recognized so far are: @@ -1392,6 +1392,7 @@ } break; case ARCH_MIPS: + case ARCH_NEWMIPS: switch (emachine) { case EM_MIPS: case EM_MIPS_RS3_LE: @@ -1462,7 +1463,8 @@ * TODO: Find out what e_flag actually contains. * TODO 2: This only sets mips16 for cpu 0. Yuck. Fix this! */ - if (arch == ARCH_MIPS && ((eflags >> 24) & 0xff) == 0x24) { + if ((arch == ARCH_MIPS || arch == ARCH_NEWMIPS) + && ((eflags >> 24) & 0xff) == 0x24) { debug("MIPS16 encoding (e_flags = 0x%08x)\n", eflags); #ifdef ENABLE_MIPS16 m->cpus[0]->cd.mips.mips16 = 1; @@ -1471,7 +1473,8 @@ "(or use the --mips16 configure option)\n"); exit(1); #endif - } else if (arch == ARCH_MIPS && (eentry & 0x3)) { + } else if ((arch == ARCH_MIPS || arch == ARCH_NEWMIPS) + && (eentry & 0x3)) { debug("MIPS16 encoding (eentry not 32-bit aligned)\n"); #ifdef ENABLE_MIPS16 m->cpus[0]->cd.mips.mips16 = 1; @@ -1527,6 +1530,20 @@ unencode(p_align, &phdr32.p_align, Elf32_Word); } + /* + * Hack for loading Linux/PPC kernels, linked to high + * addresses, at low addresses. + */ + if (arch == ARCH_PPC) { + if (elf64) { + p_vaddr &= 0x0fffffffffffffffULL; + p_paddr &= 0x0fffffffffffffffULL; + } else { + p_vaddr &= 0x0fffffff; + p_paddr &= 0x0fffffff; + } + } + if (p_memsz != 0 && (p_type == PT_LOAD || (p_type & PF_MASKPROC) == PT_MIPS_REGINFO)) { debug("chunk %i (", i); @@ -1767,7 +1784,7 @@ } else { sym32 = symbols_sym32[i]; unencode(st_name, &sym32.st_name, Elf32_Word); - unencode(st_info, &sym64.st_info, Elf_Byte); + unencode(st_info, &sym32.st_info, Elf_Byte); unencode(addr, &sym32.st_value, Elf32_Word); unencode(size, &sym32.st_size, Elf32_Word); }