diff options
| -rw-r--r-- | lld/ELF/Filesystem.cpp | 2 | ||||
| -rw-r--r-- | lld/test/ELF/driver-access.test | 14 |
2 files changed, 16 insertions, 0 deletions
diff --git a/lld/ELF/Filesystem.cpp b/lld/ELF/Filesystem.cpp index 0b9cea92bd4..b63d521a83b 100644 --- a/lld/ELF/Filesystem.cpp +++ b/lld/ELF/Filesystem.cpp @@ -70,5 +70,7 @@ void elf::unlinkAsync(StringRef Path) { // is called. We use that class without calling commit() to predict // if the given file is writable. std::error_code elf::tryCreateFile(StringRef Path) { + if (Path.empty()) + return std::error_code(); return FileOutputBuffer::create(Path, 1).getError(); } diff --git a/lld/test/ELF/driver-access.test b/lld/test/ELF/driver-access.test new file mode 100644 index 00000000000..3c976a66d0f --- /dev/null +++ b/lld/test/ELF/driver-access.test @@ -0,0 +1,14 @@ +# REQUIRES: x86, shell +# Make sure that LLD works even if the current directory is not writable. + +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o +# RUN: ld.lld %t.o -o %t.exe + +# RUN: mkdir -p %t.dir +# RUN: chmod 100 %t.dir +# RUN: cd %t.dir +# RUN: ld.lld %t.o -o %t.exe + +.globl _start +_start: + nop |

