2 * Author: Petter Reinholdtsen <pere@hungry.com>
5 * Alter ELF rpath information (insert, modify, remove).
7 * Based on source from Peeter Joot <peeterj@ca.ibm.com> and Geoffrey
8 * Keating <geoffk@ozemail.com.au>.
23 #ifdef HAVE_GETOPT_LONG
24 # define GETOPT_LONG getopt_long
26 static struct option long_options[] =
28 {"convert", 0, 0, 'c'},
29 {"delete", 0, 0, 'd'},
31 {"keepgoing", 0, 0, 'k'},
33 {"replace", 1, 0, 'r'},
34 {"version", 0, 0, 'v'},
38 #else /* not HAVE_GETOPT_LONG */
39 # define GETOPT_LONG(argc,argv,optstr,lopts,lidx) getopt(argc,argv,optstr)
40 #endif /* not HAVE_GETOPT_LONG */
45 printf("Usage: %s [-v|-d|-c|-r <path>] <program> [<program> ...]\n\n",
47 printf(" -v|--version Display program version number\n");
48 printf(" -d|--delete Delete current rpath/runpath setting\n");
49 #if defined(DT_RUNPATH)
50 printf(" -c|--convert Convert rpath to runpath\n");
51 #endif /* DT_RUNPATH */
52 printf(" -r <path>|--replace <path> Replace current rpath/runpath setting\n");
53 printf(" with the path given\n");
54 printf(" -l|--list List the current rpath/runpath (default)\n");
55 printf(" -k|--keepgoing Do not fail on first error\n");
56 printf(" -h|--help Show this usage information.\n");
57 #ifndef HAVE_GETOPT_LONG
58 printf("\n *** The long options are not available on this platform");
59 #endif /* not HAVE_GETOPT_LONG */
60 #if !defined(DT_RUNPATH)
61 printf("\n *** There is no support for runpath on this platform");
62 #endif /* DT_RUNPATH */
67 main(int argc, char * const argv[])
70 int convert = 0; /* convert to given type */
71 int remove = 0; /* remove or not */
72 int keep_going = 0; /* Break on first error, or keep going? */
73 char *newpath = NULL; /* insert this path */
75 #ifdef HAVE_GETOPT_LONG
77 #endif /* HAVE_GETOPT_LONG */
86 opt = GETOPT_LONG(argc, argv, "cdhklr:v", long_options, &option_index);
89 #if defined(DT_RUNPATH)
93 #endif /* DT_RUNPATH */
104 printf("%s version %s\n", PACKAGE, VERSION);
107 case 'l': /* This is the default action */
113 printf("Invalid argument '%c'\n", opt);
122 while (optind < argc && (!retval || keep_going))
125 retval |= killrpath(argv[optind++]);
127 /* list by default, replace if path is set */
128 retval |= chrpath(argv[optind++], newpath, convert);