diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2005-09-30 23:04:25 (GMT) |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2005-09-30 23:04:25 (GMT) |
commit | 58ec67927fb649a8325c016f04e050d17f787d66 (patch) | |
tree | a5d409ebedc6425a891445b136e37f8b3c8e0f69 /src/patchelf.cc | |
parent | c95131955924d63b2acd26fb9f0f04cdf38fed01 (diff) | |
download | patchelf-58ec67927fb649a8325c016f04e050d17f787d66.zip patchelf-58ec67927fb649a8325c016f04e050d17f787d66.tar.gz patchelf-58ec67927fb649a8325c016f04e050d17f787d66.tar.bz2 |
* `patchelf --set-rpath': short case.
Diffstat (limited to 'src/patchelf.cc')
-rw-r--r-- | src/patchelf.cc | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/src/patchelf.cc b/src/patchelf.cc index 1932fa3..a5b804b 100644 --- a/src/patchelf.cc +++ b/src/patchelf.cc @@ -437,15 +437,23 @@ static void modifyRPath(RPathOp op, string newRPath) } - if (string(rpath) != newRPath) { - assert(newRPath.size() <= strlen(rpath)); - /* Zero out the previous rpath to prevent retained - dependencies in Nix. */ - memset(rpath, 0, strlen(rpath)); + if (string(rpath) == newRPath) return; + + changed = true; + + /* Zero out the previous rpath to prevent retained + dependencies in Nix. */ + unsigned int rpathSize = strlen(rpath); + memset(rpath, 0, rpathSize); + + fprintf(stderr, "new rpath is `%s'\n", newRPath.c_str()); + + if (newRPath.size() <= rpathSize) { strcpy(rpath, newRPath.c_str()); - changed = true; + return; } - + + fprintf(stderr, "rpath is too long, resizing...\n"); } @@ -499,11 +507,13 @@ static void parseElf() } +static bool printInterpreter = false; static string newInterpreter; static bool shrinkRPath = false; +static bool setRPath = false; static bool printRPath = false; -static bool printInterpreter = false; +static string newRPath; static void patchElf() @@ -527,12 +537,14 @@ static void patchElf() if (newInterpreter != "") setInterpreter(newInterpreter); - if (shrinkRPath) - modifyRPath(rpShrink, ""); - if (printRPath) modifyRPath(rpPrint, ""); + if (shrinkRPath) + modifyRPath(rpShrink, ""); + else if (setRPath) + modifyRPath(rpSet, newRPath); + if (changed){ rewriteSections(); @@ -567,6 +579,11 @@ int main(int argc, char * * argv) else if (arg == "--shrink-rpath") { shrinkRPath = true; } + else if (arg == "--set-rpath") { + if (++i == argc) error("missing argument"); + setRPath = true; + newRPath = argv[i]; + } else if (arg == "--print-rpath") { printRPath = true; } |