tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

make COMPAT_LINUX match SYSV binaries


As a background, some Linux binaries don't claim to be targeting the
Linux OS, but instead are "SYSV".

We have used some heuristics to still identify those binaries as being
Linux binaries, like looking into the symbols defined by the binary.

it looks like we no longer have other forms of compat expected to use
SYSV ELF binaries. Perhaps we should drop this elaborate detection logic
in favour of detecting SYSV == Linux?

As an added bonus, it allows detecting binaries built with a musl
toolchain as being Linux binaries.

Index: linux/common/linux_exec_elf32.c
RCS file: /cvsroot/src/sys/compat/linux/common/linux_exec_elf32.c,v
retrieving revision 1.100
diff -u -r1.100 linux_exec_elf32.c
--- linux/common/linux_exec_elf32.c	12 Jan 2020 18:30:58 -0000	1.100
+++ linux/common/linux_exec_elf32.c	19 Oct 2020 17:47:40 -0000
@@ -370,6 +281,9 @@
 	    memcmp(&eh->e_ident[EI_ABIVERSION], linux, sizeof(linux)) == 0)
 		return 0;
+	if (eh->e_ident[EI_OSABI] == ELFOSABI_SYSV)
+		return 0;
 	phsize = eh->e_phnum * sizeof(Elf_Phdr);
 	ph = (Elf_Phdr *)malloc(phsize, M_TEMP, M_WAITOK);
 	error = exec_read(l, epp->ep_vp, eh->e_phoff, ph, phsize,

Home | Main Index | Thread Index | Old Index