diff options
author | Ralf Baechle <ralf@linux-mips.org> | 2000-07-12 00:45:49 +0000 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2000-07-12 00:45:49 +0000 |
commit | 66f20d0f9bd86dc11f3869d78f3c5749789323ee (patch) | |
tree | f6462cca735c009dc41d590bc0128102d7645006 /include | |
parent | 45c5d1ba96c0670768c065115604d52afa7882b0 (diff) |
ELF loader changes / cleanup as discussed on linux-kernel.
Diffstat (limited to 'include')
-rw-r--r-- | include/asm-alpha/elf.h | 2 | ||||
-rw-r--r-- | include/asm-i386/elf.h | 3 | ||||
-rw-r--r-- | include/asm-ia64/elf.h | 2 | ||||
-rw-r--r-- | include/asm-m68k/elf.h | 2 | ||||
-rw-r--r-- | include/asm-mips/elf.h | 28 | ||||
-rw-r--r-- | include/asm-mips64/elf.h | 20 | ||||
-rw-r--r-- | include/asm-ppc/elf.h | 2 | ||||
-rw-r--r-- | include/asm-s390/elf.h | 2 | ||||
-rw-r--r-- | include/asm-sh/elf.h | 2 | ||||
-rw-r--r-- | include/asm-sparc/elf.h | 2 | ||||
-rw-r--r-- | include/asm-sparc64/elf.h | 2 |
11 files changed, 52 insertions, 15 deletions
diff --git a/include/asm-alpha/elf.h b/include/asm-alpha/elf.h index 26b2b27a7..d031ef3c2 100644 --- a/include/asm-alpha/elf.h +++ b/include/asm-alpha/elf.h @@ -22,7 +22,7 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG]; /* * This is used to ensure we don't load something for the wrong architecture. */ -#define elf_check_arch(x) ((x) == EM_ALPHA) +#define elf_check_arch(x) ((x)->e_machine == EM_ALPHA) /* * These are used to set parameters in the core dumps. diff --git a/include/asm-i386/elf.h b/include/asm-i386/elf.h index 5bf5ec1c8..de59b793a 100644 --- a/include/asm-i386/elf.h +++ b/include/asm-i386/elf.h @@ -19,7 +19,8 @@ typedef struct user_fxsr_struct elf_fpxregset_t; /* * This is used to ensure we don't load something for the wrong architecture. */ -#define elf_check_arch(x) ( ((x) == EM_386) || ((x) == EM_486) ) +#define elf_check_arch(x) \ + (((x)->e_machine == EM_386) || ((x)->e_machine == EM_486)) /* * These are used to set parameters in the core dumps. diff --git a/include/asm-ia64/elf.h b/include/asm-ia64/elf.h index c0ae62524..149437e8c 100644 --- a/include/asm-ia64/elf.h +++ b/include/asm-ia64/elf.h @@ -14,7 +14,7 @@ /* * This is used to ensure we don't load something for the wrong architecture. */ -#define elf_check_arch(x) ((x) == EM_IA_64) +#define elf_check_arch(x) ((x)->e_machine == EM_IA_64) /* * These are used to set parameters in the core dumps. diff --git a/include/asm-m68k/elf.h b/include/asm-m68k/elf.h index 7456c3114..e2743983c 100644 --- a/include/asm-m68k/elf.h +++ b/include/asm-m68k/elf.h @@ -19,7 +19,7 @@ typedef struct user_m68kfp_struct elf_fpregset_t; /* * This is used to ensure we don't load something for the wrong architecture. */ -#define elf_check_arch(x) ((x) == EM_68K) +#define elf_check_arch(x) ((x)->e_machine == EM_68K) /* * These are used to set parameters in the core dumps. diff --git a/include/asm-mips/elf.h b/include/asm-mips/elf.h index 31f455d9d..732ea22ea 100644 --- a/include/asm-mips/elf.h +++ b/include/asm-mips/elf.h @@ -15,9 +15,33 @@ typedef double elf_fpreg_t; typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG]; /* - * This is used to ensure we don't load something for the wrong architecture. + * This is used to ensure we don't load something for the wrong architecture + * and also rejects IRIX binaries. */ -#define elf_check_arch(x) ((x) == EM_MIPS || (x) == EM_MIPS_RS4_BE) +#define elf_check_arch(hdr) \ +({ \ + int __res = 0; \ + struct elfhdr *__h = (hdr); \ + \ + if ((__h->e_machine != EM_MIPS) && (__h->e_machine != EM_MIPS)) \ + __res = -ENOEXEC; \ + if (__h->e_flags & EF_MIPS_ARCH) \ + __res = -ENOEXEC; \ + \ + __res; \ +}) + +/* This one accepts IRIX binaries. */ +#define irix_elf_check_arch(hdr) \ +({ \ + int __res = 0; \ + struct elfhdr *__h = (hdr); \ + \ + if ((__h->e_machine != EM_MIPS) && (__h->e_machine != EM_MIPS)) \ + __res = -ENOEXEC; \ + \ + __res; \ +}) /* * These are used to set parameters in the core dumps. diff --git a/include/asm-mips64/elf.h b/include/asm-mips64/elf.h index 0c549baf0..429c80561 100644 --- a/include/asm-mips64/elf.h +++ b/include/asm-mips64/elf.h @@ -1,5 +1,4 @@ -/* $Id: elf.h,v 1.3 2000/01/17 23:32:47 ralf Exp $ - * +/* * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive * for more details. @@ -22,9 +21,22 @@ typedef double elf_fpreg_t; typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG]; /* - * This is used to ensure we don't load something for the wrong architecture. + * This is used to ensure we don't load something for the wrong + * architecture or OS. */ -#define elf_check_arch(x) ((x) == EM_MIPS || (x) == EM_MIPS_RS4_BE) +#define elf_check_arch(hdr) \ +({ \ + int __res = 0; \ + struct elfhdr *__h = (hdr); \ + \ + if ((__h->e_machine != EM_MIPS) && (__h->e_machine != EM_MIPS)) \ + __res = -ENOEXEC; \ + if (sizeof(elf_caddr_t) == 8 && \ + __h->e_ident[EI_CLASS] == ELFCLASS32) \ + __res = -ENOEXEC; \ + \ + __res; \ +}) /* * These are used to set parameters in the core dumps. diff --git a/include/asm-ppc/elf.h b/include/asm-ppc/elf.h index a175e8061..75b515e18 100644 --- a/include/asm-ppc/elf.h +++ b/include/asm-ppc/elf.h @@ -13,7 +13,7 @@ /* * This is used to ensure we don't load something for the wrong architecture. */ -#define elf_check_arch(x) ((x) == EM_PPC) +#define elf_check_arch(x) ((x)->e_machine == EM_PPC) /* * These are used to set parameters in the core dumps. diff --git a/include/asm-s390/elf.h b/include/asm-s390/elf.h index 60a08aaae..eea4560fc 100644 --- a/include/asm-s390/elf.h +++ b/include/asm-s390/elf.h @@ -22,7 +22,7 @@ typedef s390_regs elf_gregset_t; /* * This is used to ensure we don't load something for the wrong architecture. */ -#define elf_check_arch(x) ((x) == EM_S390) +#define elf_check_arch(x) ((x)->elf_machine == EM_S390) /* * These are used to set parameters in the core dumps. diff --git a/include/asm-sh/elf.h b/include/asm-sh/elf.h index 22a6f4c0c..be4858639 100644 --- a/include/asm-sh/elf.h +++ b/include/asm-sh/elf.h @@ -19,7 +19,7 @@ typedef struct user_fpu_struct elf_fpregset_t; /* * This is used to ensure we don't load something for the wrong architecture. */ -#define elf_check_arch(x) ( (x) == EM_SH ) +#define elf_check_arch(x) ( (x)->e_machine == EM_SH ) /* * These are used to set parameters in the core dumps. diff --git a/include/asm-sparc/elf.h b/include/asm-sparc/elf.h index c2f54c150..fbeaebf2e 100644 --- a/include/asm-sparc/elf.h +++ b/include/asm-sparc/elf.h @@ -59,7 +59,7 @@ typedef struct { /* * This is used to ensure we don't load something for the wrong architecture. */ -#define elf_check_arch(x) ((x) == EM_SPARC) +#define elf_check_arch(x) ((x)->e_machine == EM_SPARC) /* * These are used to set parameters in the core dumps. diff --git a/include/asm-sparc64/elf.h b/include/asm-sparc64/elf.h index ec946e414..8a5404930 100644 --- a/include/asm-sparc64/elf.h +++ b/include/asm-sparc64/elf.h @@ -36,7 +36,7 @@ typedef struct { * This is used to ensure we don't load something for the wrong architecture. */ #ifndef elf_check_arch -#define elf_check_arch(x) ((x) == ELF_ARCH) /* Might be EM_SPARCV9 or EM_SPARC */ +#define elf_check_arch(x) ((x)->e_machine == ELF_ARCH) /* Might be EM_SPARCV9 or EM_SPARC */ #endif #define USE_ELF_CORE_DUMP |