From 691030d5ce5babec22627c7a396dee9e9922306e Mon Sep 17 00:00:00 2001 From: Arun Thomas Date: Fri, 10 Dec 2010 15:18:28 +0000 Subject: [PATCH] file(1): Add ELF support --- commands/file/file.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/commands/file/file.c b/commands/file/file.c index 13df8a76f..858ecdb4d 100644 --- a/commands/file/file.c +++ b/commands/file/file.c @@ -1,3 +1,4 @@ + /* file - report on file type. Author: Andy Tanenbaum */ /* Magic number detection changed to look-up table 08-Jan-91 - ajm */ @@ -16,7 +17,7 @@ unsigned char buf[BLOCK_SIZE]; struct info { int execflag; /* 1 == ack executable, 2 == gnu executable, - * 3 == core */ + * 3 == core, 4 == elf executable */ unsigned char magic[4]; /* First four bytes of the magic number */ unsigned char mask[4]; /* Mask to apply when matching */ char *description; /* What it means */ @@ -57,6 +58,8 @@ struct info { "MINIX-68k gnu executable", 0x03, 0x82, 0x12, 0xC4, 0xC0, 0xff, 0xff, 0xff, 0xff, "core file", + 0x04, 0x7F, 0x45, 0x4C, 0x46, 0xff, 0xff, 0xff, 0xff, + "ELF executable", }; int tabsize = sizeof(table) / sizeof(struct info); @@ -268,6 +271,11 @@ int type; return; } + if (type == 4) { /* ELF executable */ + printf("\n"); + return; + } + printf("\n"); /* Not an executable file */ }