Add a new signature test for linux probe function. We look for a .debuglink
section, which is specific to the Linux dynamic interpeter (yes, Linux can execute it as a stand alone program)
This commit is contained in:
parent
f646b59f80
commit
05c8a1b827
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: linux_exec.h,v 1.3 2005/12/16 14:16:14 christos Exp $ */
|
||||
/* $NetBSD: linux_exec.h,v 1.4 2006/08/07 14:19:57 manu Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2005 Emmanuel Dreyfus, all rights reserved.
|
||||
@ -63,6 +63,8 @@ struct linux_extra_stack_data64 {
|
||||
/* we have special powerpc ELF copyargs */
|
||||
#define LINUX_MACHDEP_ELF_COPYARGS
|
||||
|
||||
#define LINUX_DEBUGLINK_SIGNATURE
|
||||
|
||||
int linux_exec_setup_stack(struct lwp *, struct exec_package *);
|
||||
|
||||
#endif /* !_AMD64_LINUX_EXEC_H */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: linux_exec.h,v 1.37 2006/02/09 19:18:56 manu Exp $ */
|
||||
/* $NetBSD: linux_exec.h,v 1.38 2006/08/07 14:19:57 manu Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
|
||||
@ -149,6 +149,10 @@ int linux_elf32_signature __P((struct lwp *, struct exec_package *,
|
||||
int linux_elf32_gcc_signature __P((struct lwp *l,
|
||||
struct exec_package *, Elf32_Ehdr *));
|
||||
#endif
|
||||
#ifdef LINUX_DEBUGLINK_SIGNATURE
|
||||
int linux_elf32_debuglink_signature __P((struct lwp *l,
|
||||
struct exec_package *, Elf32_Ehdr *));
|
||||
#endif
|
||||
#ifdef LINUX_ATEXIT_SIGNATURE
|
||||
int linux_elf32_atexit_signature __P((struct lwp *l,
|
||||
struct exec_package *, Elf32_Ehdr *));
|
||||
@ -165,6 +169,10 @@ int linux_elf64_signature __P((struct lwp *, struct exec_package *,
|
||||
int linux_elf64_gcc_signature __P((struct lwp *l,
|
||||
struct exec_package *, Elf64_Ehdr *));
|
||||
#endif
|
||||
#ifdef LINUX_DEBUGLINK_SIGNATURE
|
||||
int linux_elf64_debuglink_signature __P((struct lwp *l,
|
||||
struct exec_package *, Elf64_Ehdr *));
|
||||
#endif
|
||||
#ifdef LINUX_ATEXIT_SIGNATURE
|
||||
int linux_elf64_atexit_signature __P((struct lwp *l,
|
||||
struct exec_package *, Elf64_Ehdr *));
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: linux_exec_elf32.c,v 1.73 2006/07/23 22:06:09 ad Exp $ */
|
||||
/* $NetBSD: linux_exec_elf32.c,v 1.74 2006/08/07 14:19:57 manu Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1995, 1998, 2000, 2001 The NetBSD Foundation, Inc.
|
||||
@ -42,7 +42,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: linux_exec_elf32.c,v 1.73 2006/07/23 22:06:09 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: linux_exec_elf32.c,v 1.74 2006/08/07 14:19:57 manu Exp $");
|
||||
|
||||
#ifndef ELFSIZE
|
||||
/* XXX should die */
|
||||
@ -222,6 +222,75 @@ out:
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef LINUX_DEBUGLINK_SIGNATURE
|
||||
/*
|
||||
* Look for a .gnu_debuglink, specific to x86_64 interpeter
|
||||
*/
|
||||
int
|
||||
ELFNAME2(linux,debuglink_signature)(l, epp, eh)
|
||||
struct lwp *l;
|
||||
struct exec_package *epp;
|
||||
Elf_Ehdr *eh;
|
||||
{
|
||||
size_t shsize;
|
||||
int strndx;
|
||||
size_t i;
|
||||
static const char signature[] = ".gnu_debuglink";
|
||||
char *strtable = NULL;
|
||||
Elf_Shdr *sh;
|
||||
|
||||
int error;
|
||||
|
||||
/*
|
||||
* load the section header table
|
||||
*/
|
||||
shsize = eh->e_shnum * sizeof(Elf_Shdr);
|
||||
sh = (Elf_Shdr *) malloc(shsize, M_TEMP, M_WAITOK);
|
||||
error = exec_read_from(l, epp->ep_vp, eh->e_shoff, sh, shsize);
|
||||
if (error)
|
||||
goto out;
|
||||
|
||||
/*
|
||||
* Now let's find the string table. If it does not exists, give up.
|
||||
*/
|
||||
strndx = (int)(eh->e_shstrndx);
|
||||
if (strndx == SHN_UNDEF) {
|
||||
error = ENOEXEC;
|
||||
goto out;
|
||||
}
|
||||
|
||||
/*
|
||||
* strndx is the index in section header table of the string table
|
||||
* section get the whole string table in strtable, and then we get access to the names
|
||||
* s->sh_name is the offset of the section name in strtable.
|
||||
*/
|
||||
strtable = malloc(sh[strndx].sh_size, M_TEMP, M_WAITOK);
|
||||
error = exec_read_from(l, epp->ep_vp, sh[strndx].sh_offset, strtable,
|
||||
sh[strndx].sh_size);
|
||||
if (error)
|
||||
goto out;
|
||||
|
||||
for (i = 0; i < eh->e_shnum; i++) {
|
||||
Elf_Shdr *s = &sh[i];
|
||||
|
||||
if (!memcmp((void*)(&(strtable[s->sh_name])), signature,
|
||||
sizeof(signature))) {
|
||||
DPRINTF(("linux_debuglink_sig=%s\n",
|
||||
&(strtable[s->sh_name])));
|
||||
error = 0;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
error = ENOEXEC;
|
||||
|
||||
out:
|
||||
free(sh, M_TEMP);
|
||||
if (strtable)
|
||||
free(strtable, M_TEMP);
|
||||
return (error);
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
ELFNAME2(linux,signature)(l, epp, eh, itp)
|
||||
struct lwp *l;
|
||||
@ -319,8 +388,13 @@ ELFNAME2(linux,probe)(l, epp, eh, itp, pos)
|
||||
#ifdef LINUX_ATEXIT_SIGNATURE
|
||||
((error = ELFNAME2(linux,atexit_signature)(l, epp, eh)) != 0) &&
|
||||
#endif
|
||||
1)
|
||||
#ifdef LINUX_DEBUGLINK_SIGNATURE
|
||||
((error = ELFNAME2(linux,debuglink_signature)(l, epp, eh)) != 0) &&
|
||||
#endif
|
||||
1) {
|
||||
DPRINTF(("linux_probe: returning %d\n", error));
|
||||
return error;
|
||||
}
|
||||
|
||||
if (itp) {
|
||||
if ((error = emul_find_interp(l, epp->ep_esch->es_emul->e_path,
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: linux32_exec.h,v 1.1 2006/02/09 19:18:57 manu Exp $ */
|
||||
/* $NetBSD: linux32_exec.h,v 1.2 2006/08/07 14:19:57 manu Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved.
|
||||
@ -39,7 +39,7 @@
|
||||
#define LINUX32_MID_MACHINE LINUX_M_I386
|
||||
#define LINUX32_USRSTACK 0xC0000000
|
||||
|
||||
#define LINUX32_GCC_SIGNATURE 1
|
||||
#define LINUX32_DEBUGLINK_SIGNATURE 1
|
||||
|
||||
#define LINUX32_ELF_AUX_ENTRIES 18
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: linux32_exec.h,v 1.1 2006/02/09 19:18:57 manu Exp $ */
|
||||
/* $NetBSD: linux32_exec.h,v 1.2 2006/08/07 14:19:57 manu Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved.
|
||||
@ -49,6 +49,21 @@ int linux32_elf32_probe __P((struct lwp *, struct exec_package *, void *,
|
||||
char *, vaddr_t *));
|
||||
int linux32_elf32_copyargs __P((struct lwp *, struct exec_package *,
|
||||
struct ps_strings *, char **, void *));
|
||||
int linux_elf32_signature __P((struct lwp *, struct exec_package *,
|
||||
Elf32_Ehdr *, char *));
|
||||
#ifdef LINUX32_GCC_SIGNATURE
|
||||
int linux_elf32_gcc_signature __P((struct lwp *l,
|
||||
struct exec_package *, Elf32_Ehdr *));
|
||||
#endif
|
||||
#ifdef LINUX32_DEBUGLINK_SIGNATURE
|
||||
int linux_elf32_debuglink_signature __P((struct lwp *l,
|
||||
struct exec_package *, Elf32_Ehdr *));
|
||||
#endif
|
||||
#ifdef LINUX32_ATEXIT_SIGNATURE
|
||||
int linux_elf32_atexit_signature __P((struct lwp *l,
|
||||
struct exec_package *, Elf32_Ehdr *));
|
||||
#endif
|
||||
|
||||
#endif /* EXEC_ELF32 */
|
||||
|
||||
void linux32_setregs (struct lwp *, struct exec_package *, u_long stack);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: linux32_exec_elf32.c,v 1.4 2006/07/23 22:06:09 ad Exp $ */
|
||||
/* $NetBSD: linux32_exec_elf32.c,v 1.5 2006/08/07 14:19:57 manu Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1995, 1998, 2000, 2001,2006 The NetBSD Foundation, Inc.
|
||||
@ -38,7 +38,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: linux32_exec_elf32.c,v 1.4 2006/07/23 22:06:09 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: linux32_exec_elf32.c,v 1.5 2006/08/07 14:19:57 manu Exp $");
|
||||
|
||||
#define ELFSIZE 32
|
||||
|
||||
@ -68,18 +68,6 @@ __KERNEL_RCSID(0, "$NetBSD: linux32_exec_elf32.c,v 1.4 2006/07/23 22:06:09 ad Ex
|
||||
#define DPRINTF(a)
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
static int ELFNAME2(linux32,signature) __P((struct lwp *, struct exec_package *,
|
||||
Elf_Ehdr *, char *));
|
||||
#ifdef LINUX_GCC_SIGNATURE
|
||||
static int ELFNAME2(linux32,gcc_signature) __P((struct lwp *l,
|
||||
struct exec_package *, Elf_Ehdr *));
|
||||
#endif
|
||||
#ifdef LINUX_ATEXIT_SIGNATURE
|
||||
static int ELFNAME2(linux32,atexit_signature) __P((struct lwp *l,
|
||||
struct exec_package *, Elf_Ehdr *));
|
||||
#endif
|
||||
#endif
|
||||
int linux32_copyinargs(struct exec_package *, struct ps_strings *,
|
||||
void *, size_t, const void *, const void *);
|
||||
|
||||
@ -94,11 +82,14 @@ ELFNAME2(linux32,probe)(l, epp, eh, itp, pos)
|
||||
int error;
|
||||
|
||||
if (((error = ELFNAME2(linux,signature)(l, epp, eh, itp)) != 0) &&
|
||||
#ifdef LINUX_GCC_SIGNATURE
|
||||
#ifdef LINUX32_GCC_SIGNATURE
|
||||
((error = ELFNAME2(linux,gcc_signature)(l, epp, eh)) != 0) &&
|
||||
#endif
|
||||
#ifdef LINUX_ATEXIT_SIGNATURE
|
||||
#ifdef LINUX32_ATEXIT_SIGNATURE
|
||||
((error = ELFNAME2(linux,atexit_signature)(l, epp, eh)) != 0) &&
|
||||
#endif
|
||||
#ifdef LINUX32_DEBUGLINK_SIGNATURE
|
||||
((error = ELFNAME2(linux,debuglink_signature)(l, epp, eh)) != 0) &&
|
||||
#endif
|
||||
1)
|
||||
return error;
|
||||
|
Loading…
Reference in New Issue
Block a user