summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavide Italiano <davide@freebsd.org>2016-11-16 19:35:36 +0000
committerDavide Italiano <davide@freebsd.org>2016-11-16 19:35:36 +0000
commitc223d1bc6bd5850a887025f23464829faa77f643 (patch)
tree58c07b126e6ee0eacc5d9325767b7421b3055d09
parent8301c645c80d8de32de060d43be6a50429d47f4e (diff)
downloadbcm5719-llvm-c223d1bc6bd5850a887025f23464829faa77f643.tar.gz
bcm5719-llvm-c223d1bc6bd5850a887025f23464829faa77f643.zip
[ELF] Don't replace path separators on *NIX.
Apparently this is wrong because it's legal to have a filename on UNIX which contains a backslash. Differential Revision: https://reviews.llvm.org/D26734 llvm-svn: 287143
-rw-r--r--lld/lib/Core/Reproduce.cpp2
-rw-r--r--lld/test/ELF/reproduce-backslash.s9
2 files changed, 11 insertions, 0 deletions
diff --git a/lld/lib/Core/Reproduce.cpp b/lld/lib/Core/Reproduce.cpp
index a6f5019702e..5ff668e64fc 100644
--- a/lld/lib/Core/Reproduce.cpp
+++ b/lld/lib/Core/Reproduce.cpp
@@ -53,7 +53,9 @@ static void writeMember(raw_fd_ostream &OS, StringRef Path, StringRef Data) {
// Converts path to use unix path separators so the cpio can be extracted on
// both unix and windows.
static void convertToUnixPathSeparator(SmallString<128> &Path) {
+#ifdef LLVM_ON_WIN32
std::replace(Path.begin(), Path.end(), '\\', '/');
+#endif
}
void CpioFile::append(StringRef Path, StringRef Data) {
diff --git a/lld/test/ELF/reproduce-backslash.s b/lld/test/ELF/reproduce-backslash.s
new file mode 100644
index 00000000000..a694bfcfb77
--- /dev/null
+++ b/lld/test/ELF/reproduce-backslash.s
@@ -0,0 +1,9 @@
+# REQUIRES: x86, cpio, shell
+
+# Test that we don't erroneously replace \ with / on UNIX, as it's
+# legal for a filename to contain backslashes.
+# RUN: llvm-mc %s -o foo\\.o -filetype=obj -triple=x86_64-pc-linux
+# RUN: ld.lld foo\\.o --reproduce repro
+# RUN: cpio -t < repro.cpio | FileCheck %s
+
+# CHECK: repro/{{.*}}/foo\.o
OpenPOWER on IntegriCloud