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'}
37 #else /* not HAVE_GETOPT_LONG */
38 # define GETOPT_LONG(argc,argv,optstr,lopts,lidx) getopt(argc,argv,optstr)
39 #endif /* not HAVE_GETOPT_LONG */
44 printf("Usage: %s [-v|-d|-c|-r <path>] <program> [<program> ...]\n\n",
46 printf(" -v|--version Display program version number\n");
47 printf(" -d|--delete Delete current rpath/runpath setting\n");
48 #if defined(DT_RUNPATH)
49 printf(" -c|--convert Convert rpath to runpath\n");
50 #endif /* DT_RUNPATH */
51 printf(" -r <path>|--replace <path> Replace current rpath/runpath setting\n");
52 printf(" with the path given\n");
53 printf(" -l|--list List the current rpath/runpath (default)\n");
54 printf(" -h|--help Show this usage information.\n");
55 #ifndef HAVE_GETOPT_LONG
56 printf("\n *** The long options are not available on this platform");
57 #endif /* not HAVE_GETOPT_LONG */
58 #if !defined(DT_RUNPATH)
59 printf("\n *** There is no support for runpath on this platform");
60 #endif /* DT_RUNPATH */
65 main(int argc, char * const argv[])
68 int convert = 0; /* convert to given type */
69 int remove = 0; /* remove or not */
70 int keep_going = 0; /* Break on first error, or keep going? */
71 char *newpath = NULL; /* insert this path */
73 #ifdef HAVE_GETOPT_LONG
75 #endif /* HAVE_GETOPT_LONG */
84 opt = GETOPT_LONG(argc, argv, "cdhklr:v", long_options, &option_index);
87 #if defined(DT_RUNPATH)
91 #endif /* DT_RUNPATH */
102 printf("%s version %s\n", PACKAGE, VERSION);
105 case 'l': /* This is the default action */
111 printf("Invalid argument '%c'\n", opt);
119 while (optind < argc && (!retval || keep_going))
122 retval |= killrpath(argv[optind++]);
124 /* list by default, replace if path is set */
125 retval |= chrpath(argv[optind++], newpath, convert);