summaryrefslogtreecommitdiffstats
path: root/trunk/src/execstack.c
diff options
context:
space:
mode:
Diffstat (limited to 'trunk/src/execstack.c')
-rw-r--r--trunk/src/execstack.c22
1 files changed, 19 insertions, 3 deletions
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);