Skip to contentSkip to conversation

kernel should not reject -mips2 ELF binaries

DISCUSSION Jay Carlson 2 participants 3 messages Nov 7, 2000 MIPS

lore
Share & tools
lore
#0 lore raw

include/asm-mips/elf.h contains a macro, elf_check_arch, that decides if an executable is plausible to run under this kernel. It currently accepts binaries flagged as MIPS1 ISA, and rejects all other ISAs.

#define elf_check_arch(hdr) \

({									\
	int __res = 1;							\
	struct elfhdr *__h = (hdr);					\
									\
	if ((__h->e_machine != EM_MIPS) &&				\
	    (__h->e_machine != EM_MIPS_RS4_BE))				\
		__res = 0;						\
	if (__h->e_flags & EF_MIPS_ARCH)				\
		__res = 0;						\
									\
	__res;								\
})

I think we should make an exception for MIPS2. Turns out that the two Linux VR processor families benefit from some of the MIPS II features; most notably, code density is improved by eliminating load delay slots. If I build executables that take advantage of this, they legitimately should be flagged with E_MIPS_ARCH_2 (since they won't run on my decstation).

So what's the right way to fix this? Three things come to mind:

1) rip out the EF_MIPS_ARCH check from elf_check_arch.
2) compare the value with E_MIPS_ARCH_1 and E_MIPS_ARCH_2
3) figure out what the capabilities of the current processor are and reject E_MIPS_ARCH2 on R2/3000s.

I'd just go do #3 except it looks like a bigger pain than it's worth. No other linux kernel port goes to that amount of trouble, of course.

(I may do #1 or #2 in the Linux VR CVS as a stopgap.)

Jay

#1 lore raw
Quoted 24 lines · Jay Carlson

include/asm-mips/elf.h contains a macro, elf_check_arch, that decides if an executable is plausible to run under this kernel. It currently accepts binaries flagged as MIPS1 ISA, and rejects all other ISAs.

#define elf_check_arch(hdr) \

({									\
	int __res = 1;							\
	struct elfhdr *__h = (hdr);					\
									\
	if ((__h->e_machine != EM_MIPS) &&				\
	    (__h->e_machine != EM_MIPS_RS4_BE))				\
		__res = 0;						\
	if (__h->e_flags & EF_MIPS_ARCH)				\
		__res = 0;						\
									\
	__res;								\
})

I think we should make an exception for MIPS2. Turns out that the two Linux VR processor families benefit from some of the MIPS II features; most notably, code density is improved by eliminating load delay slots. If I build executables that take advantage of this, they legitimately should be flagged with E_MIPS_ARCH_2 (since they won't run on my decstation).

Quoted 3 lines

So what's the right way to fix this? Three things come to mind:

1) rip out the EF_MIPS_ARCH check from elf_check_arch.

Take 1). The problem we have is distiguishing Linux binaries from IRIX binaries. The code causing problems for you is a heuristic that no longer works these days so I'll have to come up with something new.

Ralf

#2 lore raw
Quoted 10 lines
Quoted 6 lines
	if (__h->e_flags & EF_MIPS_ARCH)				\
		__res = 0;						\

So what's the right way to fix this? Three things come to mind:

1) rip out the EF_MIPS_ARCH check from elf_check_arch.

Take 1). The problem we have is distiguishing Linux binaries from IRIX binaries. The code causing problems for you is a heuristic that no longer works these days so I'll have to come up with something new.

OK. I'm going to remove the above two lines in the Linux VR CVS repository. Thanks!

Jay