]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
(_dl_map_object_from_fd): Use VALID_ELF_HEADER,
authorUlrich Drepper <drepper@redhat.com>
Tue, 10 Aug 1999 05:13:48 +0000 (05:13 +0000)
committerUlrich Drepper <drepper@redhat.com>
Tue, 10 Aug 1999 05:13:48 +0000 (05:13 +0000)
VALID_ELF_OSABI, VALID_ELF_ABIVERSION to decide whether an
object's header and ABI values are acceptable.
(VALID_ELF_HEADER): New macro; provide default definition.
(VALID_ELF_OSABI): New macro; provide default definition.
(VALID_ELF_ABIVERSION): New macro; provide default definition.

elf/dl-load.c

index a0448e9091d3a91b15b08be346e6762e181cf71a..9be151646c681ccf42b488a4152e920a79f5dfef 100644 (file)
@@ -655,6 +655,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
+#if !defined 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,
@@ -721,7 +726,7 @@ _dl_map_object_from_fd (const char *name, int fd, char *realname,
   header = (void *) readbuf;
 
   /* Check the header for basic validity.  */
-  if (memcmp (header->e_ident, expected, EI_PAD) != 0)
+  if (!VALID_ELF_HEADER(header->e_ident, expected, EI_PAD))
     {
       /* Something is wrong.  */
       if (*(Elf32_Word *) &header->e_ident !=
@@ -746,10 +751,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");
     }