1 // SPDX-License-Identifier: GPL-2.0
14 void die(char *fmt
, ...)
19 vfprintf(stderr
, fmt
, ap
);
24 static void usage(void)
26 die("relocs [--reloc-info|--text|--bin|--keep] vmlinux\n");
29 int main(int argc
, char **argv
)
31 int show_reloc_info
, as_text
, as_bin
, keep_relocs
;
35 unsigned char e_ident
[EI_NIDENT
];
42 for (i
= 1; i
< argc
; i
++) {
46 if (strcmp(arg
, "--reloc-info") == 0) {
50 if (strcmp(arg
, "--text") == 0) {
54 if (strcmp(arg
, "--bin") == 0) {
58 if (strcmp(arg
, "--keep") == 0) {
71 fp
= fopen(fname
, "r+");
73 die("Cannot open %s: %s\n", fname
, strerror(errno
));
75 if (fread(&e_ident
, 1, EI_NIDENT
, fp
) != EI_NIDENT
)
76 die("Cannot read %s: %s", fname
, strerror(errno
));
79 if (e_ident
[EI_CLASS
] == ELFCLASS64
)
80 process_64(fp
, as_text
, as_bin
, show_reloc_info
, keep_relocs
);
82 process_32(fp
, as_text
, as_bin
, show_reloc_info
, keep_relocs
);