[PATCH] D88674: Add --delete_all_rpaths to llvm-install-name-tool
Tobias Hieta via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 1 09:47:21 PDT 2020
thieta created this revision.
thieta added reviewers: alexshap, MaskRay, jhenderson.
thieta added a project: LLVM.
Herald added a reviewer: rupprecht.
Herald added a subscriber: llvm-commits.
thieta requested review of this revision.
We had a need of deleting all the rpaths in binaries we ship (we later add just one) and instead of parsing the output of objdump -p and calling install-name-tool over and over this seemed like a easy solution to the problem. I know this tool was created to mirror upstream apple - but don't see any problem of it adding additional functionality IMHO.
This patch misses some documentation but I wanted to make sure that people thought that this was an alright thing to add.
Tagged a few reviewers that have worked with install-name-tool before.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D88674
Files:
llvm/tools/llvm-objcopy/CopyConfig.cpp
llvm/tools/llvm-objcopy/CopyConfig.h
llvm/tools/llvm-objcopy/InstallNameToolOpts.td
llvm/tools/llvm-objcopy/MachO/MachOObjcopy.cpp
Index: llvm/tools/llvm-objcopy/MachO/MachOObjcopy.cpp
===================================================================
--- llvm/tools/llvm-objcopy/MachO/MachOObjcopy.cpp
+++ llvm/tools/llvm-objcopy/MachO/MachOObjcopy.cpp
@@ -133,9 +133,16 @@
DenseSet<StringRef> RPathsToRemove(Config.RPathsToRemove.begin(),
Config.RPathsToRemove.end());
- LoadCommandPred RemovePred = [&RPathsToRemove](const LoadCommand &LC) {
+ LoadCommandPred RemovePred = [&RPathsToRemove, &Config](const LoadCommand &LC) {
if (LC.MachOLoadCommand.load_command_data.cmd == MachO::LC_RPATH) {
+ // When removing all RPaths we don't need to care
+ // about what it contains
+ if (Config.RemoveAllRpaths) {
+ return true;
+ }
+
StringRef RPath = getPayloadString(LC);
+
if (RPathsToRemove.count(RPath)) {
RPathsToRemove.erase(RPath);
return true;
Index: llvm/tools/llvm-objcopy/InstallNameToolOpts.td
===================================================================
--- llvm/tools/llvm-objcopy/InstallNameToolOpts.td
+++ llvm/tools/llvm-objcopy/InstallNameToolOpts.td
@@ -21,6 +21,9 @@
def delete_rpath: Option<["-", "--"], "delete_rpath", KIND_SEPARATE>,
HelpText<"Delete specified rpath">;
+def delete_all_rpaths: Flag<["--"], "delete_all_rpaths">,
+ HelpText<"Delete all rpath directives">;
+
def rpath: MultiArg<["-", "--"], "rpath", 2>,
HelpText<"Change rpath path name">;
Index: llvm/tools/llvm-objcopy/CopyConfig.h
===================================================================
--- llvm/tools/llvm-objcopy/CopyConfig.h
+++ llvm/tools/llvm-objcopy/CopyConfig.h
@@ -230,6 +230,9 @@
bool StripUnneeded = false;
bool Weaken = false;
bool DecompressDebugSections = false;
+ // install-name-tool's delete_all_rpaths
+ bool RemoveAllRpaths = false;
+
DebugCompressionType CompressionType = DebugCompressionType::None;
// parseELFConfig performs ELF-specific command-line parsing. Fills `ELF` on
Index: llvm/tools/llvm-objcopy/CopyConfig.cpp
===================================================================
--- llvm/tools/llvm-objcopy/CopyConfig.cpp
+++ llvm/tools/llvm-objcopy/CopyConfig.cpp
@@ -909,6 +909,8 @@
Config.InstallNamesToUpdate.insert({Arg->getValue(0), Arg->getValue(1)});
}
+ Config.RemoveAllRpaths = InputArgs.hasArg(INSTALL_NAME_TOOL_delete_all_rpaths);
+
SmallVector<StringRef, 2> Positional;
for (auto Arg : InputArgs.filtered(INSTALL_NAME_TOOL_UNKNOWN))
return createStringError(errc::invalid_argument, "unknown argument '%s'",
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88674.295602.patch
Type: text/x-patch
Size: 2629 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201001/99ebe0f8/attachment.bin>
More information about the llvm-commits
mailing list