[lld] 4f48048 - [ELF] SHF_MERGE: avoid Fatal
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sat Jan 25 15:28:36 PST 2025
Author: Fangrui Song
Date: 2025-01-25T15:28:17-08:00
New Revision: 4f480481716553aa89142131f49e53e7d53c1998
URL: https://github.com/llvm/llvm-project/commit/4f480481716553aa89142131f49e53e7d53c1998
DIFF: https://github.com/llvm/llvm-project/commit/4f480481716553aa89142131f49e53e7d53c1998.diff
LOG: [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.
Added:
Modified:
lld/ELF/InputFiles.cpp
lld/test/ELF/invalid/merge-invalid-size.s
lld/test/ELF/invalid/merge-writable.s
Removed:
################################################################################
diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index c3c6812c262028..b29c7db879fa01 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -700,13 +700,12 @@ bool ObjFile<ELFT>::shouldMerge(const Elf_Shdr &sec, StringRef name) {
if (entSize == 0)
return false;
if (sec.sh_size % entSize)
- Fatal(ctx) << this << ":(" << name << "): SHF_MERGE section size ("
- << uint64_t(sec.sh_size)
- << ") must be a multiple of sh_entsize (" << entSize << ")";
-
+ ErrAlways(ctx) << this << ":(" << name << "): SHF_MERGE section size ("
+ << uint64_t(sec.sh_size)
+ << ") must be a multiple of sh_entsize (" << entSize << ")";
if (sec.sh_flags & SHF_WRITE)
- Fatal(ctx) << this << ":(" << name
- << "): writable SHF_MERGE section is not supported";
+ Err(ctx) << this << ":(" << name
+ << "): writable SHF_MERGE section is not supported";
return true;
}
diff --git a/lld/test/ELF/invalid/merge-invalid-size.s b/lld/test/ELF/invalid/merge-invalid-size.s
index 71c3f98e755294..82ad1f97b4a93a 100644
--- a/lld/test/ELF/invalid/merge-invalid-size.s
+++ b/lld/test/ELF/invalid/merge-invalid-size.s
@@ -1,6 +1,6 @@
// REQUIRES: x86
// RUN: llvm-mc %s -o %t.o -filetype=obj -triple=x86_64-pc-linux
-// RUN: not ld.lld %t.o -o /dev/null 2>&1 | FileCheck %s
+// RUN: not ld.lld %t.o -o /dev/null --noinhibit-exec 2>&1 | FileCheck %s
// CHECK: merge-invalid-size.s.tmp.o:(.foo): SHF_MERGE section size (2) must be a multiple of sh_entsize (4)
.section .foo,"aM", at progbits,4
diff --git a/lld/test/ELF/invalid/merge-writable.s b/lld/test/ELF/invalid/merge-writable.s
index 0c5fe92481da04..24a274b1935769 100644
--- a/lld/test/ELF/invalid/merge-writable.s
+++ b/lld/test/ELF/invalid/merge-writable.s
@@ -1,6 +1,7 @@
// REQUIRES: x86
// RUN: llvm-mc %s -o %t.o -filetype=obj -triple=x86_64-pc-linux
// RUN: not ld.lld %t.o -o /dev/null 2>&1 | FileCheck %s
+// RUN: ld.lld %t.o -o /dev/null --noinhibit-exec 2>&1 | FileCheck %s
// CHECK: merge-writable.s.tmp.o:(.foo): writable SHF_MERGE section is not supported
.section .foo,"awM", at progbits,4
More information about the llvm-commits
mailing list