Commit fd75a33e authored by James Cowgill's avatar James Cowgill Committed by Ralf Baechle

MIPS: ELF: fix loading o32 binaries on 64-bit kernels

Commit 90cee759 ("MIPS: ELF: Set FP mode according to .MIPS.abiflags")
introduced checking of the .MIPS.abiflags ELF section but did so through
the native sized "elfhdr" and "elf_phdr" structures regardless whether the
ELF was actually 32-bit or 64-bit. This produces wrong results when trying
to use a 64-bit kernel to load o32 ELF files.

Change the uses of the generic elf structures to their 32-bit versions.
Since the code bails out on any 64-bit cases, this is OK until they are
implemented.

Fixes: 90cee759 ("MIPS: ELF: Set FP mode according to .MIPS.abiflags")
Signed-off-by: default avatarJames Cowgill <James.Cowgill@imgtec.com>
Cc: linux-mips@linux-mips.org
Cc: Paul Burton <paul.burton@imgtec.com>
Reviewed-by: default avatarMaciej W. Rozycki <macro@linux-mips.org>
Patchwork: https://patchwork.linux-mips.org/patch/8932/Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
parent 50083928
...@@ -19,8 +19,8 @@ enum { ...@@ -19,8 +19,8 @@ enum {
int arch_elf_pt_proc(void *_ehdr, void *_phdr, struct file *elf, int arch_elf_pt_proc(void *_ehdr, void *_phdr, struct file *elf,
bool is_interp, struct arch_elf_state *state) bool is_interp, struct arch_elf_state *state)
{ {
struct elfhdr *ehdr = _ehdr; struct elf32_hdr *ehdr = _ehdr;
struct elf_phdr *phdr = _phdr; struct elf32_phdr *phdr = _phdr;
struct mips_elf_abiflags_v0 abiflags; struct mips_elf_abiflags_v0 abiflags;
int ret; int ret;
...@@ -48,7 +48,7 @@ int arch_elf_pt_proc(void *_ehdr, void *_phdr, struct file *elf, ...@@ -48,7 +48,7 @@ int arch_elf_pt_proc(void *_ehdr, void *_phdr, struct file *elf,
return 0; return 0;
} }
static inline unsigned get_fp_abi(struct elfhdr *ehdr, int in_abi) static inline unsigned get_fp_abi(struct elf32_hdr *ehdr, int in_abi)
{ {
/* If the ABI requirement is provided, simply return that */ /* If the ABI requirement is provided, simply return that */
if (in_abi != -1) if (in_abi != -1)
...@@ -65,7 +65,7 @@ static inline unsigned get_fp_abi(struct elfhdr *ehdr, int in_abi) ...@@ -65,7 +65,7 @@ static inline unsigned get_fp_abi(struct elfhdr *ehdr, int in_abi)
int arch_check_elf(void *_ehdr, bool has_interpreter, int arch_check_elf(void *_ehdr, bool has_interpreter,
struct arch_elf_state *state) struct arch_elf_state *state)
{ {
struct elfhdr *ehdr = _ehdr; struct elf32_hdr *ehdr = _ehdr;
unsigned fp_abi, interp_fp_abi, abi0, abi1; unsigned fp_abi, interp_fp_abi, abi0, abi1;
/* Ignore non-O32 binaries */ /* Ignore non-O32 binaries */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment