Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) #include "relocs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4) void die(char *fmt, ...)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6) 	va_list ap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) 	va_start(ap, fmt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) 	vfprintf(stderr, fmt, ap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) 	va_end(ap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) 	exit(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) static void usage(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) 	die("relocs [--abs-syms|--abs-relocs|--reloc-info|--text|--realmode]" \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) 	    " vmlinux\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) int main(int argc, char **argv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 	int show_absolute_syms, show_absolute_relocs, show_reloc_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 	int as_text, use_real_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 	const char *fname;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 	FILE *fp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 	unsigned char e_ident[EI_NIDENT];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 	show_absolute_syms = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 	show_absolute_relocs = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 	show_reloc_info = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 	as_text = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 	use_real_mode = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 	fname = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 	for (i = 1; i < argc; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 		char *arg = argv[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 		if (*arg == '-') {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 			if (strcmp(arg, "--abs-syms") == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 				show_absolute_syms = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 				continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 			if (strcmp(arg, "--abs-relocs") == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 				show_absolute_relocs = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 				continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 			if (strcmp(arg, "--reloc-info") == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 				show_reloc_info = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 				continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 			if (strcmp(arg, "--text") == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 				as_text = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 				continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 			if (strcmp(arg, "--realmode") == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 				use_real_mode = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 				continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 		else if (!fname) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) 			fname = arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 		usage();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) 	if (!fname) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) 		usage();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) 	fp = fopen(fname, "r");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) 	if (!fp) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) 		die("Cannot open %s: %s\n", fname, strerror(errno));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) 	if (fread(&e_ident, 1, EI_NIDENT, fp) != EI_NIDENT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) 		die("Cannot read %s: %s", fname, strerror(errno));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) 	rewind(fp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) 	if (e_ident[EI_CLASS] == ELFCLASS64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) 		process_64(fp, use_real_mode, as_text,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) 			   show_absolute_syms, show_absolute_relocs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) 			   show_reloc_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) 		process_32(fp, use_real_mode, as_text,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) 			   show_absolute_syms, show_absolute_relocs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) 			   show_reloc_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) 	fclose(fp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) }