From 90371dac828a4e264adaf2e19bfe2ad1cfc019c1 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 23 Feb 2005 13:16:39 +0000 Subject: * Don't remove non-absolute paths from the RPATH like "$ORIGIN". --- patchelf.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/patchelf.c b/patchelf.c index 9934cef..4e92817 100644 --- a/patchelf.c +++ b/patchelf.c @@ -173,6 +173,13 @@ static void setInterpreter(void) } +static void concat(char * dst, char * src) +{ + if (*dst) strcat(dst, ":"); + strcat(dst, src); +} + + static void shrinkRPath(void) { /* Shrink the RPATH. */ @@ -254,7 +261,13 @@ static void shrinkRPath(void) dirName[end - pos] = 0; if (*end == ':') ++end; pos = end; - if (*dirName != '/') continue; + + /* Non-absolute entries are allowed (e.g., the special + "$ORIGIN" hack). */ + if (*dirName != '/') { + concat(newRPath, dirName); + continue; + } /* For each library that we haven't found yet, see if it exists in this directory. */ @@ -275,11 +288,8 @@ static void shrinkRPath(void) if (!libFound) fprintf(stderr, "removing directory `%s' from RPATH\n", dirName); - else { - if (*newRPath) strcat(newRPath, ":"); - strcat(newRPath, dirName); - } - + else + concat(newRPath, dirName); } if (strcmp(rpath, newRPath) != 0) { -- cgit v0.12