Skip to content

Commit 4f48048

Browse files
committed
[ELF] SHF_MERGE: avoid Fatal
In LLD_IN_TEST=2 mode, when a thread calls Fatal, there will be no output even if the process exits with code 1.
1 parent d2c7cab commit 4f48048

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

lld/ELF/InputFiles.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -700,13 +700,12 @@ bool ObjFile<ELFT>::shouldMerge(const Elf_Shdr &sec, StringRef name) {
700700
if (entSize == 0)
701701
return false;
702702
if (sec.sh_size % entSize)
703-
Fatal(ctx) << this << ":(" << name << "): SHF_MERGE section size ("
704-
<< uint64_t(sec.sh_size)
705-
<< ") must be a multiple of sh_entsize (" << entSize << ")";
706-
703+
ErrAlways(ctx) << this << ":(" << name << "): SHF_MERGE section size ("
704+
<< uint64_t(sec.sh_size)
705+
<< ") must be a multiple of sh_entsize (" << entSize << ")";
707706
if (sec.sh_flags & SHF_WRITE)
708-
Fatal(ctx) << this << ":(" << name
709-
<< "): writable SHF_MERGE section is not supported";
707+
Err(ctx) << this << ":(" << name
708+
<< "): writable SHF_MERGE section is not supported";
710709

711710
return true;
712711
}

lld/test/ELF/invalid/merge-invalid-size.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// REQUIRES: x86
22
// RUN: llvm-mc %s -o %t.o -filetype=obj -triple=x86_64-pc-linux
3-
// RUN: not ld.lld %t.o -o /dev/null 2>&1 | FileCheck %s
3+
// RUN: not ld.lld %t.o -o /dev/null --noinhibit-exec 2>&1 | FileCheck %s
44
// CHECK: merge-invalid-size.s.tmp.o:(.foo): SHF_MERGE section size (2) must be a multiple of sh_entsize (4)
55

66
.section .foo,"aM",@progbits,4

lld/test/ELF/invalid/merge-writable.s

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// REQUIRES: x86
22
// RUN: llvm-mc %s -o %t.o -filetype=obj -triple=x86_64-pc-linux
33
// RUN: not ld.lld %t.o -o /dev/null 2>&1 | FileCheck %s
4+
// RUN: ld.lld %t.o -o /dev/null --noinhibit-exec 2>&1 | FileCheck %s
45
// CHECK: merge-writable.s.tmp.o:(.foo): writable SHF_MERGE section is not supported
56

67
.section .foo,"awM",@progbits,4

0 commit comments

Comments
 (0)