diff options
Diffstat (limited to 'trunk/src')
-rw-r--r-- | trunk/src/Makefile.am | 6 | ||||
-rw-r--r-- | trunk/src/execstack.c | 22 | ||||
-rw-r--r-- | trunk/src/main.c | 16 |
3 files changed, 31 insertions, 13 deletions
diff --git a/trunk/src/Makefile.am b/trunk/src/Makefile.am index 6db7b2c..34760e9 100644 --- a/trunk/src/Makefile.am +++ b/trunk/src/Makefile.am @@ -4,7 +4,11 @@ AUTOMAKE_OPTIONS = 1.4 gnu DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H -Wall AM_CFLAGS = -Wall -AM_CPPFLAGS = -DSBINDIR='"@sbindir@"' -DBINDIR='"@bindir@"' +AM_CPPFLAGS = -DSBINDIR='"@sbindir@"' -DBINDIR='"@bindir@"' \ + -DPRELINK_PROG="\"`echo prelink | sed '$(transform)'`\"" \ + -DPRELINK_RTLD_PROG="\"`echo prelink-rtld | \ + sed '$(transform)'`\"" \ + -DEXEEXT='"$(EXEEXT)"' INCLUDES = @GELFINCLUDE@ sbin_PROGRAMS = prelink prelink-rtld diff --git a/trunk/src/execstack.c b/trunk/src/execstack.c index f38fead..686e170 100644 --- a/trunk/src/execstack.c +++ b/trunk/src/execstack.c @@ -47,6 +47,13 @@ static struct argp_option options[] = { { 0 } }; +/* The cached value of argv[0]. */ +const char *program_path; + +/* The full pathname of the prelink tool, or NULL if it hasn't been + computed yet. */ +const char *prelink_path; + static error_t parse_opt (int key, char *arg, struct argp_state *state) { @@ -90,6 +97,8 @@ execstack_make_rdwr (DSO *dso, int flag) DSO *ndso = NULL; char *p = NULL; char filename[strlen (dso->filename) + sizeof ".#execstack#.XXXXXX"]; + extern char *make_relative_prefix (const char *, const char *, const char *); + char *dirname; for (i = 0; i < dso->ehdr.e_shnum; ++i) { @@ -123,13 +132,18 @@ execstack_make_rdwr (DSO *dso, int flag) goto error_out; } + if (prelink_path == NULL) + { + dirname = make_relative_prefix (program_path, BINDIR, SBINDIR); + asprintf (&prelink_path, "%s/%s", dirname, PRELINK_PROG EXEEXT); + free (dirname); + } + pid = vfork (); if (pid == 0) { close (fd); - execlp ("prelink", "prelink", "-u", "-o", filename, - dso->filename, NULL); - execl (SBINDIR "/prelink", "prelink", "-u", "-o", filename, + execl (prelink_path, prelink_path, "-u", "-o", filename, dso->filename, NULL); _exit (-1); } @@ -400,6 +414,8 @@ main (int argc, char *argv[]) { int remaining, failures = 0; + program_path = argv[0]; + setlocale (LC_ALL, ""); argp_parse (&argp, argc, argv, 0, &remaining, 0); diff --git a/trunk/src/main.c b/trunk/src/main.c index 631da44..e7e87c9 100644 --- a/trunk/src/main.c +++ b/trunk/src/main.c @@ -61,11 +61,11 @@ const char *undo_output; int noreexecinit; time_t initctime; -const char *argp_program_version = "prelink 1.0 (20061201) Wind River Linux"; +const char *argp_program_version = PRELINK_PROG "1.0 (20061201) Wind River Linux"; const char *argp_program_bug_address = "<support@windriver.com>"; -static char argp_doc[] = "prelink -- program to relocate and prelink ELF shared libraries and programs"; +static char argp_doc[] = PRELINK_PROG " -- program to relocate and prelink ELF shared libraries and programs"; #define OPT_DYNAMIC_LINKER 0x80 #define OPT_LD_LIBRARY_PATH 0x81 @@ -320,18 +320,16 @@ main (int argc, char *argv[]) error (EXIT_FAILURE, 0, "Could not canonicalize --root argument"); asprintf ((char **) &prelink_conf, "%s%s", sysroot, prelink_conf); } - + if (prelink_rtld != NULL && prelink_rtld[0] == 0) + prelink_rtld = NULL; + else if (prelink_rtld == NULL) { extern char *make_relative_prefix (const char *, const char *, const char *); const char *path = make_relative_prefix (argv[0], BINDIR, BINDIR); - if (strchr (argv[0], '/')) - asprintf ((char **) &prelink_rtld, "%s-rtld", argv[0]); - else - asprintf ((char **) &prelink_rtld, "%s/%s-rtld", path, argv[0]); + asprintf ((char **) &prelink_rtld, "%s/%s", path, + PRELINK_RTLD_PROG EXEEXT); } - else if (prelink_rtld[0] == 0) - prelink_rtld = NULL; if (print_cache) { |