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