[ELF] Fail the link early if the map file path is invalid
As with the changes made in r297645, we do not want a potentially long link to
be run, if it will ultimately fail because the map file is not writable. This
change reuses the same functionality as the output file path check. See
https://reviews.llvm.org/D30449 for further justification and explanations.
Reviewers: ruiu
Differential Revision: https://reviews.llvm.org/D31603
llvm-svn: 299420
diff --git a/lld/ELF/Filesystem.cpp b/lld/ELF/Filesystem.cpp
index d3a965c..75f7bda 100644
--- a/lld/ELF/Filesystem.cpp
+++ b/lld/ELF/Filesystem.cpp
@@ -70,9 +70,9 @@
// FileOutputBuffer doesn't touch a desitnation file until commit()
// is called. We use that class without calling commit() to predict
// if the given file is writable.
-bool elf::isFileWritable(StringRef Path) {
+bool elf::isFileWritable(StringRef Path, StringRef Desc) {
if (auto EC = FileOutputBuffer::create(Path, 1).getError()) {
- error("cannot open output file " + Path + ": " + EC.message());
+ error("cannot open " + Desc + " " + Path + ": " + EC.message());
return false;
}
return true;