file(1): Add ELF support
This commit is contained in:
parent
11904c0435
commit
691030d5ce
1 changed files with 9 additions and 1 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
|
||||||
/* file - report on file type. Author: Andy Tanenbaum */
|
/* file - report on file type. Author: Andy Tanenbaum */
|
||||||
/* Magic number detection changed to look-up table 08-Jan-91 - ajm */
|
/* Magic number detection changed to look-up table 08-Jan-91 - ajm */
|
||||||
|
|
||||||
|
@ -16,7 +17,7 @@ unsigned char buf[BLOCK_SIZE];
|
||||||
|
|
||||||
struct info {
|
struct info {
|
||||||
int execflag; /* 1 == ack executable, 2 == gnu executable,
|
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 magic[4]; /* First four bytes of the magic number */
|
||||||
unsigned char mask[4]; /* Mask to apply when matching */
|
unsigned char mask[4]; /* Mask to apply when matching */
|
||||||
char *description; /* What it means */
|
char *description; /* What it means */
|
||||||
|
@ -57,6 +58,8 @@ struct info {
|
||||||
"MINIX-68k gnu executable",
|
"MINIX-68k gnu executable",
|
||||||
0x03, 0x82, 0x12, 0xC4, 0xC0, 0xff, 0xff, 0xff, 0xff,
|
0x03, 0x82, 0x12, 0xC4, 0xC0, 0xff, 0xff, 0xff, 0xff,
|
||||||
"core file",
|
"core file",
|
||||||
|
0x04, 0x7F, 0x45, 0x4C, 0x46, 0xff, 0xff, 0xff, 0xff,
|
||||||
|
"ELF executable",
|
||||||
};
|
};
|
||||||
|
|
||||||
int tabsize = sizeof(table) / sizeof(struct info);
|
int tabsize = sizeof(table) / sizeof(struct info);
|
||||||
|
@ -268,6 +271,11 @@ int type;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (type == 4) { /* ELF executable */
|
||||||
|
printf("\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
printf("\n"); /* Not an executable file */
|
printf("\n"); /* Not an executable file */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue