* Patch to recognize the new ARM ELF_OSABI value...
@ 1999-08-09 14:31 scottb
1999-08-09 22:13 ` Ulrich Drepper
0 siblings, 1 reply; 2+ messages in thread
From: scottb @ 1999-08-09 14:31 UTC (permalink / raw)
To: libc-hacker
1999-08-09 Scott Bambrough <scottb@netwinder.org>
* elf/elf.h: Added definition of ELFOSABI_ARM.
* elf/dl-load.c (_dl_map_object_from_fd): Use VALID_ELF_HEADER,
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.
* sysdeps/arm/dl-machine.h Define ARM specific versions of
VALID_ELF_HEADER, VALID_ELF_OSABI, VALID_ELF_ABIVERSION.
These patches are similar to the one Phil submitted. They don't
penalize other platforms at runtime, since the checks are almost the
same for other platforms. A default version is provided as well, so
every platform is not required to define these values.
Index: elf/dl-load.c
===================================================================
RCS file: /glibc/cvsfiles/libc/elf/dl-load.c,v
retrieving revision 1.103.2.1
diff -u -r1.103.2.1 dl-load.c
--- dl-load.c 1999/06/17 10:41:12 1.103.2.1
+++ dl-load.c 1999/08/09 21:13:09
@@ -655,6 +655,11 @@
/* 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 @@
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 @@
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");
}
Index: elf/elf.h
===================================================================
RCS file: /glibc/cvsfiles/libc/elf/elf.h,v
retrieving revision 1.47
diff -u -r1.47 elf.h
--- elf.h 1999/04/12 09:01:08 1.47
+++ elf.h 1999/08/09 21:13:10
@@ -140,6 +140,7 @@
#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 */
Index: sysdeps/arm/dl-machine.h
===================================================================
RCS file: /glibc/cvsfiles/libc/sysdeps/arm/dl-machine.h,v
retrieving revision 1.12.2.1
diff -u -r1.12.2.1 dl-machine.h
--- dl-machine.h 1999/06/13 09:23:47 1.12.2.1
+++ dl-machine.h 1999/08/09 21:13:23
@@ -26,6 +26,15 @@
#include <assert.h>
+#define VALID_ELF_ABIVERSION(ver) (ver == 0)
+#define VALID_ELF_OSABI(osabi) \
+ ((osabi == ELFOSABI_SYSV) || (osabi == ELFOSABI_ARM))
+#define VALID_ELF_HEADER(hdr,exp,size) ( \
+ memcmp(hdr,exp,size-2) == 0 && \
+ VALID_ELF_OSABI(hdr[EI_OSABI]) && \
+ VALID_ELF_ABIVERSION(hdr[EI_ABIVERSION]) \
+)
+
/* Return nonzero iff E_MACHINE is compatible with the running host. */
static inline int __attribute__ ((unused))
elf_machine_matches_host (Elf32_Half e_machine)
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Patch to recognize the new ARM ELF_OSABI value...
1999-08-09 14:31 Patch to recognize the new ARM ELF_OSABI value scottb
@ 1999-08-09 22:13 ` Ulrich Drepper
0 siblings, 0 replies; 2+ messages in thread
From: Ulrich Drepper @ 1999-08-09 22:13 UTC (permalink / raw)
To: scottb; +Cc: libc-hacker
scottb <scottb@netwinder.org> writes:
> These patches are similar to the one Phil submitted. They don't
> penalize other platforms at runtime, since the checks are almost the
> same for other platforms. A default version is provided as well, so
> every platform is not required to define these values.
Thanks, I like this solution. I've applied the patches.
--
---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace
Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA
Cygnus Solutions `--' drepper at cygnus.com `------------------------
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1999-08-09 22:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-08-09 14:31 Patch to recognize the new ARM ELF_OSABI value scottb
1999-08-09 22:13 ` Ulrich Drepper
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).