~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/mips/boot/tools/relocs_main.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

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

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php