1 // SPDX-License-Identifier: GPL-2.0
4 void die(char *fmt, ...)
8 vfprintf(stderr, fmt, ap);
13 static void usage(void)
15 die("relocs [--abs-syms|--abs-relocs|--reloc-info|--text|--realmode]" \
19 int main(int argc, char **argv)
21 int show_absolute_syms, show_absolute_relocs, show_reloc_info;
22 int as_text, use_real_mode;
26 unsigned char e_ident[EI_NIDENT];
28 show_absolute_syms = 0;
29 show_absolute_relocs = 0;
34 for (i = 1; i < argc; i++) {
37 if (strcmp(arg, "--abs-syms") == 0) {
38 show_absolute_syms = 1;
41 if (strcmp(arg, "--abs-relocs") == 0) {
42 show_absolute_relocs = 1;
45 if (strcmp(arg, "--reloc-info") == 0) {
49 if (strcmp(arg, "--text") == 0) {
53 if (strcmp(arg, "--realmode") == 0) {
67 fp = fopen(fname, "r");
69 die("Cannot open %s: %s\n", fname, strerror(errno));
71 if (fread(&e_ident, 1, EI_NIDENT, fp) != EI_NIDENT) {
72 die("Cannot read %s: %s", fname, strerror(errno));
75 if (e_ident[EI_CLASS] == ELFCLASS64)
76 process_64(fp, use_real_mode, as_text,
77 show_absolute_syms, show_absolute_relocs,
80 process_32(fp, use_real_mode, as_text,
81 show_absolute_syms, show_absolute_relocs,