summaryrefslogtreecommitdiffstats
path: root/usr.sbin/crunch/crunchide/exec_elf32.c
diff options
context:
space:
mode:
authoremaste <emaste@FreeBSD.org>2015-12-18 03:06:39 +0000
committeremaste <emaste@FreeBSD.org>2015-12-18 03:06:39 +0000
commitceeb430497959309c5dcbbf6dc0717588a4c2fa1 (patch)
tree4530058c75fdbc6070e2ac8d15114a28f319412d /usr.sbin/crunch/crunchide/exec_elf32.c
parentc068c81a4df70e14d444f258a550b3b72f7b30c6 (diff)
downloadFreeBSD-src-ceeb430497959309c5dcbbf6dc0717588a4c2fa1.zip
FreeBSD-src-ceeb430497959309c5dcbbf6dc0717588a4c2fa1.tar.gz
MFC r281674: crunchide: always include both 32- and 64-bit ELF support
This avoids the need to build a target-specific crunchide for cross- builds. Sponsored by: The FreeBSD Foundation
Diffstat (limited to 'usr.sbin/crunch/crunchide/exec_elf32.c')
-rw-r--r--usr.sbin/crunch/crunchide/exec_elf32.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/usr.sbin/crunch/crunchide/exec_elf32.c b/usr.sbin/crunch/crunchide/exec_elf32.c
index dd8c1b0..52a340c 100644
--- a/usr.sbin/crunch/crunchide/exec_elf32.c
+++ b/usr.sbin/crunch/crunchide/exec_elf32.c
@@ -79,6 +79,9 @@ __FBSDID("$FreeBSD$");
#define ELFNAME2(x,y) CONCAT(x,CONCAT(_elf,CONCAT(ELFSIZE,CONCAT(_,y))))
#define ELFNAMEEND(x) CONCAT(x,CONCAT(_elf,ELFSIZE))
#define ELFDEFNNAME(x) CONCAT(ELF,CONCAT(ELFSIZE,CONCAT(_,x)))
+#ifndef ELFCLASS
+#define ELFCLASS CONCAT(ELFCLASS,ELFSIZE)
+#endif
#define xe16toh(x) ((data == ELFDATA2MSB) ? be16toh(x) : le16toh(x))
#define xe32toh(x) ((data == ELFDATA2MSB) ? be32toh(x) : le32toh(x))
@@ -167,7 +170,7 @@ ELFNAMEEND(check)(int fd, const char *fn)
if (read(fd, &eh, sizeof eh) != sizeof eh)
return 0;
- if (IS_ELF(eh) == 0)
+ if (IS_ELF(eh) == 0 || eh.e_ident[EI_CLASS] != ELFCLASS)
return 0;
data = eh.e_ident[EI_DATA];
OpenPOWER on IntegriCloud