aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Hatle <mark.hatle@windriver.com>2016-03-22 16:52:15 -0500
committerMark Hatle <mark.hatle@windriver.com>2016-03-22 16:52:15 -0500
commite7d3832dbbf72bdf9c30b610a9c8e10e6174b72c (patch)
tree0483dc219c7ddfa8848f0d7c475a0f1e4f78af98
parent335a6e50385e540a2b61b62438414b4376c31947 (diff)
parent5cb7a3e7ad4ce01e1f091f232ed03d1fd7300a66 (diff)
downloadprelink-cross-e7d3832dbbf72bdf9c30b610a9c8e10e6174b72c.tar.gz
prelink-cross-e7d3832dbbf72bdf9c30b610a9c8e10e6174b72c.tar.bz2
prelink-cross-e7d3832dbbf72bdf9c30b610a9c8e10e6174b72c.zip
Merge branch 'cross_prelink_staging' into master_staging
Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
-rw-r--r--ChangeLog6
-rw-r--r--src/gather.c20
-rw-r--r--src/get.c20
3 files changed, 34 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index a6a0578..b8fb3e5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,8 @@
-2016-22-28 Mark Hatle <mark.hatle@windriver.com>
+2016-03-22 Mark Hatle <mark.hatle@windriver.com>
+ * src/gather.c, src/get.c: Fix LD_PRELOAD
+ * Merge with cross_prelink
+
+2016-03-22 Mark Hatle <mark.hatle@windriver.com>
* Merge with cross_prelink
2016-03-18 Donn Seeley <donn.seeley@windriver.com>
diff --git a/src/gather.c b/src/gather.c
index 2eb7cbc..277f1b5 100644
--- a/src/gather.c
+++ b/src/gather.c
@@ -62,7 +62,7 @@ gather_deps (DSO *dso, struct prelink_entry *ent)
int i, j, seen = 0;
FILE *f = NULL;
const char *argv[5];
- const char *envp[4];
+ const char *envp[5];
char *line = NULL, *p, *q = NULL;
const char **depends = NULL, **depends_temp;
size_t ndepends = 0, ndepends_alloced = 0;
@@ -162,10 +162,20 @@ gather_deps (DSO *dso, struct prelink_entry *ent)
argv[i++] = ent_filename;
argv[i] = NULL;
- envp[0] = "LD_TRACE_LOADED_OBJECTS=1";
- envp[1] = "LD_TRACE_PRELINKING=1";
- envp[2] = "LD_WARN=";
- envp[3] = NULL;
+
+ j = 0;
+ if(etype == ET_EXEC && ld_preload)
+ {
+ p = alloca (sizeof "LD_PRELOAD=" + strlen (ld_preload) + 1);
+ strcpy (stpcpy (p, "LD_PRELOAD="), ld_preload);
+ envp[j++] = p;
+ }
+
+ envp[j++] = "LD_TRACE_LOADED_OBJECTS=1";
+ envp[j++] = "LD_TRACE_PRELINKING=1";
+ envp[j++] = "LD_WARN=";
+ envp[j] = NULL;
+
f = execve_open (dl, (char * const *)argv, (char * const *)envp);
if (f == NULL)
goto error_out;
diff --git a/src/get.c b/src/get.c
index 6b4fed2..0659962 100644
--- a/src/get.c
+++ b/src/get.c
@@ -643,8 +643,8 @@ prelink_get_relocations (struct prelink_info *info)
FILE *f;
DSO *dso = info->dso;
const char *argv[5];
- const char *envp[4];
- int i, ret, status;
+ const char *envp[5];
+ int i, j, ret, status;
char *p;
const char *dl = dynamic_linker ?: dso->arch->dynamic_linker;
const char *ent_filename;
@@ -691,12 +691,20 @@ prelink_get_relocations (struct prelink_info *info)
}
argv[i++] = ent_filename;
argv[i] = NULL;
- envp[0] = "LD_TRACE_LOADED_OBJECTS=1";
- envp[1] = "LD_BIND_NOW=1";
+
+ j = 0;
+ if(etype == ET_EXEC && ld_preload)
+ {
+ p = alloca (sizeof "LD_PRELOAD=" + strlen (ld_preload));
+ strcpy (stpcpy (p, "LD_PRELOAD="), ld_preload);
+ envp[j++] = p;
+ }
+ envp[j++] = "LD_TRACE_LOADED_OBJECTS=1";
+ envp[j++] = "LD_BIND_NOW=1";
p = alloca (sizeof "LD_TRACE_PRELINKING=" + strlen (info->ent->filename));
strcpy (stpcpy (p, "LD_TRACE_PRELINKING="), info->ent->filename);
- envp[2] = p;
- envp[3] = NULL;
+ envp[j++] = p;
+ envp[j] = NULL;
ret = 2;
f = execve_open (dl, (char * const *)argv, (char * const *)envp);