[llvm] 51f8d46 - [llvm-install-name-tool] Quote passed rpath args in error messages
Alexander Shaposhnikov via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 28 15:28:32 PDT 2020
Author: Keith Smiley
Date: 2020-10-28T15:22:33-07:00
New Revision: 51f8d46491c7efd4e2054b036c13ef6266fceab3
URL: https://github.com/llvm/llvm-project/commit/51f8d46491c7efd4e2054b036c13ef6266fceab3
DIFF: https://github.com/llvm/llvm-project/commit/51f8d46491c7efd4e2054b036c13ef6266fceab3.diff
LOG: [llvm-install-name-tool] Quote passed rpath args in error messages
This diff refactors error reporting to make it more clear
what arguments were passed to llvm-install-name-tool.
Test plan: make check-all
Differential revision: https://reviews.llvm.org/D90080
Added:
Modified:
llvm/test/tools/llvm-objcopy/MachO/install-name-tool-add-rpath.test
llvm/test/tools/llvm-objcopy/MachO/install-name-tool-delete-rpath.test
llvm/test/tools/llvm-objcopy/MachO/install-name-tool-prepend-rpath.test
llvm/test/tools/llvm-objcopy/MachO/install-name-tool-rpath.test
llvm/tools/llvm-objcopy/CopyConfig.cpp
llvm/tools/llvm-objcopy/MachO/MachOObjcopy.cpp
Removed:
################################################################################
diff --git a/llvm/test/tools/llvm-objcopy/MachO/install-name-tool-add-rpath.test b/llvm/test/tools/llvm-objcopy/MachO/install-name-tool-add-rpath.test
index 7b21fdc2e03c..5199b3b3aaa4 100644
--- a/llvm/test/tools/llvm-objcopy/MachO/install-name-tool-add-rpath.test
+++ b/llvm/test/tools/llvm-objcopy/MachO/install-name-tool-add-rpath.test
@@ -15,7 +15,7 @@
# RUN: not llvm-install-name-tool -add_rpath @executable_path/. %t.i386 2>&1 \
# RUN: | FileCheck --check-prefix=DUPLICATE-RPATH %s
-# DUPLICATE-RPATH: duplicate load command
+# DUPLICATE-RPATH: rpath '@executable_path/.' would create a duplicate load command
# RUN: not llvm-install-name-tool -add_rpath @executable_path/. 2>&1 \
# RUN: | FileCheck --check-prefix=NO-INPUT %s
@@ -27,7 +27,7 @@
# RUN: -add_rpath @executable_X %t.i386 2>&1 \
# RUN: | FileCheck --check-prefix=DOUBLE %s
-# DOUBLE: duplicate load command
+# DOUBLE: rpath '@executable_X' would create a duplicate load command
## Check that cmdsize accounts for NULL terminator.
# RUN: yaml2obj %p/Inputs/x86_64.yaml -o %t.x86_64
diff --git a/llvm/test/tools/llvm-objcopy/MachO/install-name-tool-delete-rpath.test b/llvm/test/tools/llvm-objcopy/MachO/install-name-tool-delete-rpath.test
index 77dd6d5eb9c4..aea899fd1a19 100644
--- a/llvm/test/tools/llvm-objcopy/MachO/install-name-tool-delete-rpath.test
+++ b/llvm/test/tools/llvm-objcopy/MachO/install-name-tool-delete-rpath.test
@@ -40,7 +40,7 @@
# RUN: -delete_rpath @executable_b/. %t 2>&1 | \
# RUN: FileCheck %s --check-prefix=COMBINED
-# COMBINED: cannot specify both -add_rpath @executable_b/. and -delete_rpath @executable_b/.
+# COMBINED: cannot specify both -add_rpath '@executable_b/.' and -delete_rpath '@executable_b/.'
## Remove all RPATHS
# RUN: yaml2obj %s -o %t2
diff --git a/llvm/test/tools/llvm-objcopy/MachO/install-name-tool-prepend-rpath.test b/llvm/test/tools/llvm-objcopy/MachO/install-name-tool-prepend-rpath.test
index 4f88f14f4219..6d0fb5fdecb4 100644
--- a/llvm/test/tools/llvm-objcopy/MachO/install-name-tool-prepend-rpath.test
+++ b/llvm/test/tools/llvm-objcopy/MachO/install-name-tool-prepend-rpath.test
@@ -30,28 +30,28 @@
# RUN: not llvm-install-name-tool -prepend_rpath first_rpath %t.i386 2>&1 | \
# RUN: FileCheck --check-prefix=DUPLICATE-RPATH %s
-# DUPLICATE-RPATH: rpath first_rpath would create a duplicate load command
+# DUPLICATE-RPATH: rpath 'first_rpath' would create a duplicate load command
## Prepend same RPATH twice:
# RUN: not llvm-install-name-tool -prepend_rpath @executable_X \
# RUN: -prepend_rpath @executable_X %t.i386 2>&1 | \
# RUN: FileCheck --check-prefix=DOUBLE %s
-# DOUBLE: rpath @executable_X would create a duplicate load command
+# DOUBLE: rpath '@executable_X' would create a duplicate load command
## Prepend and delete RPATH:
# RUN: not llvm-install-name-tool -prepend_rpath foo \
# RUN: -delete_rpath foo %t.i386 2>&1 | \
# RUN: FileCheck --check-prefix=DELETE %s
-# DELETE: cannot specify both -prepend_rpath foo and -delete_rpath foo
+# DELETE: cannot specify both -prepend_rpath 'foo' and -delete_rpath 'foo'
## Prepend and replace RPATH:
# RUN: not llvm-install-name-tool -prepend_rpath foo \
# RUN: -rpath foo bar %t.i386 2>&1 | \
# RUN: FileCheck --check-prefix=REPLACE %s
-# REPLACE: cannot specify both -prepend_rpath foo and -rpath foo bar
+# REPLACE: cannot specify both -prepend_rpath 'foo' and -rpath 'foo' 'bar'
## Check that cmdsize accounts for NULL terminator:
# RUN: yaml2obj %p/Inputs/x86_64.yaml -o %t.x86_64
diff --git a/llvm/test/tools/llvm-objcopy/MachO/install-name-tool-rpath.test b/llvm/test/tools/llvm-objcopy/MachO/install-name-tool-rpath.test
index ae92401b3a5d..a0621f4a66bb 100644
--- a/llvm/test/tools/llvm-objcopy/MachO/install-name-tool-rpath.test
+++ b/llvm/test/tools/llvm-objcopy/MachO/install-name-tool-rpath.test
@@ -74,7 +74,7 @@
# RUN: FileCheck %s --check-prefix=EXISTING
# RUN: cmp %t %t1
-# EXISTING: rpath ABCD would create a duplicate load command
+# EXISTING: rpath 'ABCD' would create a duplicate load command
## Duplicate RPath entries:
# RUN: not llvm-install-name-tool -rpath DDD1/. @exec_d/. \
@@ -82,7 +82,7 @@
# RUN: FileCheck %s --check-prefix=DUPLICATE
# RUN: cmp %t %t1
-# DUPLICATE: cannot specify both -rpath DDD1/. @exec_d/. and -rpath @exec_d/. DDD2/.
+# DUPLICATE: cannot specify both -rpath 'DDD1/.' '@exec_d/.' and -rpath '@exec_d/.' 'DDD2/.'
## Updating and deleting RPath at the same time:
# RUN: not llvm-install-name-tool -rpath @executable_d/. DD/. \
@@ -90,7 +90,7 @@
# RUN: FileCheck %s --check-prefix=COMBINED-DELETE
# RUN: cmp %t %t1
-# COMBINED-DELETE: cannot specify both -delete_rpath @executable_d/. and -rpath @executable_d/. DD/.
+# COMBINED-DELETE: cannot specify both -delete_rpath '@executable_d/.' and -rpath '@executable_d/.' 'DD/.'
## Updating and adding RPath at the same time:
# RUN: not llvm-install-name-tool -rpath @executable_e/. EE/. \
@@ -98,7 +98,7 @@
# RUN: FileCheck %s --check-prefix=COMBINED-ADD
# RUN: cmp %t %t1
-# COMBINED-ADD: cannot specify both -add_rpath @executable_e/. and -rpath @executable_e/. EE/.
+# COMBINED-ADD: cannot specify both -add_rpath '@executable_e/.' and -rpath '@executable_e/.' 'EE/.'
## Missing an RPath argument:
# RUN: not llvm-install-name-tool %t -rpath @executable_e/. 2>&1 | \
diff --git a/llvm/tools/llvm-objcopy/CopyConfig.cpp b/llvm/tools/llvm-objcopy/CopyConfig.cpp
index 1bab7cd23b64..ba74759a34c2 100644
--- a/llvm/tools/llvm-objcopy/CopyConfig.cpp
+++ b/llvm/tools/llvm-objcopy/CopyConfig.cpp
@@ -905,12 +905,12 @@ parseInstallNameToolOptions(ArrayRef<const char *> ArgsArr) {
if (is_contained(Config.RPathToAdd, RPath))
return createStringError(
errc::invalid_argument,
- "cannot specify both -add_rpath %s and -delete_rpath %s",
+ "cannot specify both -add_rpath '%s' and -delete_rpath '%s'",
RPath.str().c_str(), RPath.str().c_str());
if (is_contained(Config.RPathToPrepend, RPath))
return createStringError(
errc::invalid_argument,
- "cannot specify both -prepend_rpath %s and -delete_rpath %s",
+ "cannot specify both -prepend_rpath '%s' and -delete_rpath '%s'",
RPath.str().c_str(), RPath.str().c_str());
Config.RPathsToRemove.insert(RPath);
@@ -930,30 +930,30 @@ parseInstallNameToolOptions(ArrayRef<const char *> ArgsArr) {
});
if (It1 != Config.RPathsToUpdate.end())
return createStringError(errc::invalid_argument,
- "cannot specify both -rpath " + It1->getFirst() +
- " " + It1->getSecond() + " and -rpath " +
- Old + " " + New);
+ "cannot specify both -rpath '" +
+ It1->getFirst() + "' '" + It1->getSecond() +
+ "' and -rpath '" + Old + "' '" + New + "'");
// Cannot specify the same rpath under both -delete_rpath and -rpath
auto It2 = find_if(Config.RPathsToRemove, Match);
if (It2 != Config.RPathsToRemove.end())
return createStringError(errc::invalid_argument,
- "cannot specify both -delete_rpath " + *It2 +
- " and -rpath " + Old + " " + New);
+ "cannot specify both -delete_rpath '" + *It2 +
+ "' and -rpath '" + Old + "' '" + New + "'");
// Cannot specify the same rpath under both -add_rpath and -rpath
auto It3 = find_if(Config.RPathToAdd, Match);
if (It3 != Config.RPathToAdd.end())
return createStringError(errc::invalid_argument,
- "cannot specify both -add_rpath " + *It3 +
- " and -rpath " + Old + " " + New);
+ "cannot specify both -add_rpath '" + *It3 +
+ "' and -rpath '" + Old + "' '" + New + "'");
// Cannot specify the same rpath under both -prepend_rpath and -rpath.
auto It4 = find_if(Config.RPathToPrepend, Match);
if (It4 != Config.RPathToPrepend.end())
return createStringError(errc::invalid_argument,
- "cannot specify both -prepend_rpath " + *It4 +
- " and -rpath " + Old + " " + New);
+ "cannot specify both -prepend_rpath '" + *It4 +
+ "' and -rpath '" + Old + "' '" + New + "'");
Config.RPathsToUpdate.insert({Old, New});
}
diff --git a/llvm/tools/llvm-objcopy/MachO/MachOObjcopy.cpp b/llvm/tools/llvm-objcopy/MachO/MachOObjcopy.cpp
index 311a9962a8cc..1394339b27d6 100644
--- a/llvm/tools/llvm-objcopy/MachO/MachOObjcopy.cpp
+++ b/llvm/tools/llvm-objcopy/MachO/MachOObjcopy.cpp
@@ -183,8 +183,8 @@ static Error processLoadCommands(const CopyConfig &Config, Object &Obj) {
"no LC_RPATH load command with path: " + Old);
if (RPaths.count(New) != 0)
return createStringError(errc::invalid_argument,
- "rpath " + New +
- " would create a duplicate load command");
+ "rpath '" + New +
+ "' would create a duplicate load command");
}
// Update load commands.
@@ -222,8 +222,8 @@ static Error processLoadCommands(const CopyConfig &Config, Object &Obj) {
for (StringRef RPath : Config.RPathToAdd) {
if (RPaths.count(RPath) != 0)
return createStringError(errc::invalid_argument,
- "rpath " + RPath +
- " would create a duplicate load command");
+ "rpath '" + RPath +
+ "' would create a duplicate load command");
RPaths.insert(RPath);
Obj.LoadCommands.push_back(buildRPathLoadCommand(RPath));
}
@@ -231,8 +231,8 @@ static Error processLoadCommands(const CopyConfig &Config, Object &Obj) {
for (StringRef RPath : Config.RPathToPrepend) {
if (RPaths.count(RPath) != 0)
return createStringError(errc::invalid_argument,
- "rpath " + RPath +
- " would create a duplicate load command");
+ "rpath '" + RPath +
+ "' would create a duplicate load command");
RPaths.insert(RPath);
Obj.LoadCommands.insert(Obj.LoadCommands.begin(),
More information about the llvm-commits
mailing list