summaryrefslogtreecommitdiffstats
path: root/lld/ELF
diff options
context:
space:
mode:
Diffstat (limited to 'lld/ELF')
-rw-r--r--lld/ELF/Driver.cpp10
-rw-r--r--lld/ELF/Filesystem.cpp4
-rw-r--r--lld/ELF/Filesystem.h2
3 files changed, 9 insertions, 7 deletions
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index dfd7eef4355..00524c68762 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -860,10 +860,12 @@ template <class ELFT> void LinkerDriver::link(opt::InputArgList &Args) {
if (Config->OutputFile.empty())
Config->OutputFile = "a.out";
- // Fail early if the output file is not writable. If a user has a long link,
- // e.g. due to a large LTO link, they do not wish to run it and find that it
- // failed because there was a mistake in their command-line.
- if (!isFileWritable(Config->OutputFile))
+ // Fail early if the output file or map file is not writable. If a user has a
+ // long link, e.g. due to a large LTO link, they do not wish to run it and
+ // find that it failed because there was a mistake in their command-line.
+ if (!isFileWritable(Config->OutputFile, "output file"))
+ return;
+ if (!isFileWritable(Config->MapFile, "map file"))
return;
// Use default entry point name if no name was given via the command
diff --git a/lld/ELF/Filesystem.cpp b/lld/ELF/Filesystem.cpp
index d3a965cc78a..75f7bda75a2 100644
--- a/lld/ELF/Filesystem.cpp
+++ b/lld/ELF/Filesystem.cpp
@@ -70,9 +70,9 @@ void elf::unlinkAsync(StringRef Path) {
// 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;
diff --git a/lld/ELF/Filesystem.h b/lld/ELF/Filesystem.h
index 7e97cbe634f..a33dc3651a4 100644
--- a/lld/ELF/Filesystem.h
+++ b/lld/ELF/Filesystem.h
@@ -15,7 +15,7 @@
namespace lld {
namespace elf {
void unlinkAsync(StringRef Path);
-bool isFileWritable(StringRef Path);
+bool isFileWritable(StringRef Path, StringRef FileDescription);
}
}
OpenPOWER on IntegriCloud