diff options
Diffstat (limited to 'arch/mips/kernel/vpe.c')
-rw-r--r-- | arch/mips/kernel/vpe.c | 47 |
1 files changed, 12 insertions, 35 deletions
diff --git a/arch/mips/kernel/vpe.c b/arch/mips/kernel/vpe.c index 3c09b9785f4c..61b729fa0548 100644 --- a/arch/mips/kernel/vpe.c +++ b/arch/mips/kernel/vpe.c | |||
@@ -936,8 +936,18 @@ static int vpe_elfload(struct vpe * v) | |||
936 | 936 | ||
937 | } | 937 | } |
938 | } else { | 938 | } else { |
939 | for (i = 0; i < hdr->e_shnum; i++) { | 939 | struct elf_phdr *phdr = (struct elf_phdr *) ((char *)hdr + hdr->e_phoff); |
940 | 940 | ||
941 | for (i = 0; i < hdr->e_phnum; i++) { | ||
942 | if (phdr->p_type != PT_LOAD) | ||
943 | continue; | ||
944 | |||
945 | memcpy((void *)phdr->p_vaddr, (char *)hdr + phdr->p_offset, phdr->p_filesz); | ||
946 | memset((void *)phdr->p_vaddr + phdr->p_filesz, 0, phdr->p_memsz - phdr->p_filesz); | ||
947 | phdr++; | ||
948 | } | ||
949 | |||
950 | for (i = 0; i < hdr->e_shnum; i++) { | ||
941 | /* Internal symbols and strings. */ | 951 | /* Internal symbols and strings. */ |
942 | if (sechdrs[i].sh_type == SHT_SYMTAB) { | 952 | if (sechdrs[i].sh_type == SHT_SYMTAB) { |
943 | symindex = i; | 953 | symindex = i; |
@@ -948,39 +958,6 @@ static int vpe_elfload(struct vpe * v) | |||
948 | magic symbols */ | 958 | magic symbols */ |
949 | sechdrs[i].sh_addr = (size_t) hdr + sechdrs[i].sh_offset; | 959 | sechdrs[i].sh_addr = (size_t) hdr + sechdrs[i].sh_offset; |
950 | } | 960 | } |
951 | |||
952 | /* filter sections we dont want in the final image */ | ||
953 | if (!(sechdrs[i].sh_flags & SHF_ALLOC) || | ||
954 | (sechdrs[i].sh_type == SHT_MIPS_REGINFO)) { | ||
955 | printk( KERN_DEBUG " ignoring section, " | ||
956 | "name %s type %x address 0x%x \n", | ||
957 | secstrings + sechdrs[i].sh_name, | ||
958 | sechdrs[i].sh_type, sechdrs[i].sh_addr); | ||
959 | continue; | ||
960 | } | ||
961 | |||
962 | if (sechdrs[i].sh_addr < (unsigned int)v->load_addr) { | ||
963 | printk( KERN_WARNING "VPE loader: " | ||
964 | "fully linked image has invalid section, " | ||
965 | "name %s type %x address 0x%x, before load " | ||
966 | "address of 0x%x\n", | ||
967 | secstrings + sechdrs[i].sh_name, | ||
968 | sechdrs[i].sh_type, sechdrs[i].sh_addr, | ||
969 | (unsigned int)v->load_addr); | ||
970 | return -ENOEXEC; | ||
971 | } | ||
972 | |||
973 | printk(KERN_DEBUG " copying section sh_name %s, sh_addr 0x%x " | ||
974 | "size 0x%x0 from x%p\n", | ||
975 | secstrings + sechdrs[i].sh_name, sechdrs[i].sh_addr, | ||
976 | sechdrs[i].sh_size, hdr + sechdrs[i].sh_offset); | ||
977 | |||
978 | if (sechdrs[i].sh_type != SHT_NOBITS) | ||
979 | memcpy((void *)sechdrs[i].sh_addr, | ||
980 | (char *)hdr + sechdrs[i].sh_offset, | ||
981 | sechdrs[i].sh_size); | ||
982 | else | ||
983 | memset((void *)sechdrs[i].sh_addr, 0, sechdrs[i].sh_size); | ||
984 | } | 961 | } |
985 | } | 962 | } |
986 | 963 | ||
@@ -1044,7 +1021,7 @@ static int getcwd(char *buff, int size) | |||
1044 | old_fs = get_fs(); | 1021 | old_fs = get_fs(); |
1045 | set_fs(KERNEL_DS); | 1022 | set_fs(KERNEL_DS); |
1046 | 1023 | ||
1047 | ret = sys_getcwd(buff,size); | 1024 | ret = sys_getcwd(buff, size); |
1048 | 1025 | ||
1049 | set_fs(old_fs); | 1026 | set_fs(old_fs); |
1050 | 1027 | ||