aboutsummaryrefslogtreecommitdiff
path: root/elf
diff options
context:
space:
mode:
Diffstat (limited to 'elf')
-rw-r--r--elf/dl-load.c16
-rw-r--r--elf/elf.h1
2 files changed, 12 insertions, 5 deletions
diff --git a/elf/dl-load.c b/elf/dl-load.c
index 7640ec3289..2f3e878e7a 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -673,6 +673,11 @@ _dl_map_object_from_fd (const char *name, int fd, char *realname,
/* This is the expected ELF header. */
#define ELF32_CLASS ELFCLASS32
#define ELF64_CLASS ELFCLASS64
+#ifndef VALID_ELF_HEADER
+# define VALID_ELF_HEADER(hdr,exp,size) (memcmp (hdr, exp, size) == 0)
+# define VALID_ELF_OSABI(osabi) (osabi == ELFOSABI_SYSV)
+# define VALID_ELF_ABIVERSION(ver) (ver == 0)
+#endif
static const unsigned char expected[EI_PAD] =
{
[EI_MAG0] = ELFMAG0,
@@ -739,7 +744,8 @@ _dl_map_object_from_fd (const char *name, int fd, char *realname,
header = (void *) readbuf;
/* Check the header for basic validity. */
- if (__builtin_expect (memcmp (header->e_ident, expected, EI_PAD), 0) != 0)
+ if (__builtin_expect (VALID_ELF_HEADER (header->e_ident, expected, EI_PAD),
+ 0) != 0)
{
/* Something is wrong. */
if (*(Elf32_Word *) &header->e_ident !=
@@ -764,10 +770,10 @@ _dl_map_object_from_fd (const char *name, int fd, char *realname,
LOSE (0, "ELF file version ident not " STRING(EV_CURRENT));
/* XXX We should be able so set system specific versions which are
allowed here. */
- if (header->e_ident[EI_OSABI] != ELFOSABI_SYSV)
- LOSE (0, "ELF file OS ABI not " STRING(ELFOSABI_SYSV));
- if (header->e_ident[EI_ABIVERSION] != 0)
- LOSE (0, "ELF file ABI version not 0");
+ if (!VALID_ELF_OSABI (header->e_ident[EI_OSABI]))
+ LOSE (0, "ELF file OS ABI invalid.");
+ if (!VALID_ELF_ABIVERSION (header->e_ident[EI_ABIVERSION]))
+ LOSE (0, "ELF file ABI version invalid.");
LOSE (0, "internal error");
}
diff --git a/elf/elf.h b/elf/elf.h
index e722acbef5..a3ce2d98fc 100644
--- a/elf/elf.h
+++ b/elf/elf.h
@@ -135,6 +135,7 @@ typedef struct
#define EI_OSABI 7 /* OS ABI identification */
#define ELFOSABI_SYSV 0 /* UNIX System V ABI */
#define ELFOSABI_HPUX 1 /* HP-UX */
+#define ELFOSABI_ARM 97 /* ARM */
#define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */
#define EI_ABIVERSION 8 /* ABI version */