[lld] f804e2b - [ELF] .eh_frame: use errorOrWarn for "PC offset is too large"
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 20 12:53:45 PST 2024
Author: Fangrui Song
Date: 2024-02-20T12:53:40-08:00
New Revision: f804e2badf30321121df4d0d7df8e32e10f134cc
URL: https://github.com/llvm/llvm-project/commit/f804e2badf30321121df4d0d7df8e32e10f134cc
DIFF: https://github.com/llvm/llvm-project/commit/f804e2badf30321121df4d0d7df8e32e10f134cc.diff
LOG: [ELF] .eh_frame: use errorOrWarn for "PC offset is too large"
errorOrWarn is more conventional for recoverable errors. This error
message does not have to use `fatal`, and we try to remove such uses in
parallel code paths.
Added:
Modified:
lld/ELF/SyntheticSections.cpp
lld/test/ELF/eh-frame-pcrel-overflow.s
Removed:
################################################################################
diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index bada394aa30d7d..b6bdc350bc0dd1 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -537,9 +537,11 @@ SmallVector<EhFrameSection::FdeData, 0> EhFrameSection::getFdeData() const {
for (EhSectionPiece *fde : rec->fdes) {
uint64_t pc = getFdePc(buf, fde->outputOff, enc);
uint64_t fdeVA = getParent()->addr + fde->outputOff;
- if (!isInt<32>(pc - va))
- fatal(toString(fde->sec) + ": PC offset is too large: 0x" +
- Twine::utohexstr(pc - va));
+ if (!isInt<32>(pc - va)) {
+ errorOrWarn(toString(fde->sec) + ": PC offset is too large: 0x" +
+ Twine::utohexstr(pc - va));
+ continue;
+ }
ret.push_back({uint32_t(pc - va), uint32_t(fdeVA - va)});
}
}
diff --git a/lld/test/ELF/eh-frame-pcrel-overflow.s b/lld/test/ELF/eh-frame-pcrel-overflow.s
index 78e804768dad63..3dfcf9ee1a7f9a 100644
--- a/lld/test/ELF/eh-frame-pcrel-overflow.s
+++ b/lld/test/ELF/eh-frame-pcrel-overflow.s
@@ -4,7 +4,9 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/eh-frame-pcrel-overflow.s -o %t1.o
# RUN: ld.lld --eh-frame-hdr -Ttext=0x90000000 %t.o -o /dev/null
# RUN: not ld.lld --eh-frame-hdr %t.o %t1.o -o /dev/null 2>&1 | FileCheck %s
+# RUN: ld.lld --eh-frame-hdr %t.o %t1.o -o /dev/null --noinhibit-exec 2>&1 | FileCheck %s --check-prefix=WARN
# CHECK: error: {{.*}}.o:(.eh_frame): PC offset is too large: 0x90001054
+# WARN: warning: {{.*}}.o:(.eh_frame): PC offset is too large: 0x90001054
.text
.global _start
More information about the llvm-commits
mailing list