Return early if writeMapFile failed.

This patch adds a test for an invalid output path for -Map option,
though that test is not for verifying that we are using error()
instead of fatal() in writeMapFile.

llvm-svn: 292336
This commit is contained in:
Rui Ueyama
2017-01-18 03:34:38 +00:00
parent c606efabb7
commit 40eaa9968d
2 changed files with 8 additions and 0 deletions

View File

@@ -237,7 +237,11 @@ template <class ELFT> void Writer<ELFT>::run() {
if (ErrorCount)
return;
// Handle -Map option.
writeMapFile<ELFT>(OutputSections);
if (ErrorCount)
return;
if (auto EC = Buffer->commit())
error("failed to write to the output file: " + EC.message());

View File

@@ -54,3 +54,7 @@ local:
// CHECK-NEXT: 0000000000000000 0000000000000039 1 .shstrtab
// CHECK-NEXT: 0000000000000000 000000000000002f 1 .strtab
// CHECK-NEXT: 0000000000000000 000000000000002f 1 .strtab
// RUN: not ld.lld %t1.o %t2.o %t3.o %t4.a -o %t -Map=/ 2>&1 \
// RUN: | FileCheck -check-prefix=FAIL %s
// FAIL: cannot open /