Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / scripts / mod / mk_elfconfig.c
blobe8cee4e4bc733a29f760722ecad6a19b2c5fb4e9
1 // SPDX-License-Identifier: GPL-2.0
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <string.h>
5 #include <elf.h>
7 int
8 main(int argc, char **argv)
10 unsigned char ei[EI_NIDENT];
12 if (fread(ei, 1, EI_NIDENT, stdin) != EI_NIDENT) {
13 fprintf(stderr, "Error: input truncated\n");
14 return 1;
16 if (memcmp(ei, ELFMAG, SELFMAG) != 0) {
17 fprintf(stderr, "Error: not ELF\n");
18 return 1;
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);
31 return 0;