Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1// SPDX-License-Identifier: GPL-2.0
2#include <stdio.h>
3#include <stdlib.h>
4#include <string.h>
5#include <elf.h>
6
7int
8main(int argc, char **argv)
9{
10 unsigned char ei[EI_NIDENT];
11
12 if (fread(ei, 1, EI_NIDENT, stdin) != EI_NIDENT) {
13 fprintf(stderr, "Error: input truncated\n");
14 return 1;
15 }
16 if (memcmp(ei, ELFMAG, SELFMAG) != 0) {
17 fprintf(stderr, "Error: not ELF\n");
18 return 1;
19 }
20 switch (ei[EI_CLASS]) {
21 case ELFCLASS32:
22 printf("#define KERNEL_ELFCLASS ELFCLASS32\n");
23 break;
24 case ELFCLASS64:
25 printf("#define KERNEL_ELFCLASS ELFCLASS64\n");
26 break;
27 default:
28 exit(1);
29 }
30
31 return 0;
32}