diff options
-rw-r--r-- | trunk/ChangeLog.cross | 24 | ||||
-rw-r--r-- | trunk/configure.in | 3 | ||||
-rw-r--r-- | trunk/src/Makefile.am | 6 | ||||
-rw-r--r-- | trunk/src/execstack.c | 22 | ||||
-rw-r--r-- | trunk/src/main.c | 16 |
5 files changed, 57 insertions, 14 deletions
diff --git a/trunk/ChangeLog.cross b/trunk/ChangeLog.cross index d4f922f..4ad0463 100644 --- a/trunk/ChangeLog.cross +++ b/trunk/ChangeLog.cross @@ -1,3 +1,27 @@ +2010-06-14 Mark Hatle <mark.hatle@windriver.com> + + * Integrate prelinker/cross-prelinking patches + + 2006-10-03 Richard Sandiford <richard@codesourcery.com> + + * configure.in (AC_CANONICAL_HOST): Remove in favour of... + (AC_CANONICAL_SYSTEM): ...this new directive. + (AC_ARG_PROGRAM): New directive. + * src/Makefile.am (AM_CFLAGS): Define PRELINK_PROG, PRELINK_RTLD_PROG + and EXEEXT. + (execstack_LDADD): Add -liberty. + * src/execstack.c (program_path, prelink_path): New variables. + (execstack_make_rdwr): Initialize prelink_path if it has not + been set yet. Use make_relative_prefix, PRELINK_PROG and EXEEXT + to get the full pathname of the prelink executable. Pass this path + to execl() as the name of executable file. + (main): Initialize program_path. + * src/main.c (argp_program_version, argp_doc): Use PRELINK_PROG as + the program name. + (main): Handle empty --rtld= arguments first. Always use + make_relative_prefix to work out the path of the defalt rtld + executable. Also use PRELINK_RTLD and EXEEXT for this purpose. + 2010-06-14 Mark Hatle <mark.hatle@windriver.com> * configure.in: Add option to disable selinux * src/Makefile.am: Stop static linking diff --git a/trunk/configure.in b/trunk/configure.in index f99a0d9..86a2513 100644 --- a/trunk/configure.in +++ b/trunk/configure.in @@ -2,7 +2,8 @@ dnl Process this file with autoconf to produce a configure script. -*-m4-*- AC_INIT(src/prelink.c) AM_CONFIG_HEADER(config.h) AC_PREREQ(2.13) dnl Minimum Autoconf version required. -AC_CANONICAL_HOST +AC_CANONICAL_SYSTEM +AC_ARG_PROGRAM AM_INIT_AUTOMAKE([prelink], [0.0]) 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) { |