[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.
GitOrigin-RevId: f804e2badf30321121df4d0d7df8e32e10f134cc
diff --git a/ELF/SyntheticSections.cpp b/ELF/SyntheticSections.cpp
index bada394..b6bdc35 100644
--- a/ELF/SyntheticSections.cpp
+++ b/ELF/SyntheticSections.cpp
@@ -537,9 +537,11 @@
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/test/ELF/eh-frame-pcrel-overflow.s b/test/ELF/eh-frame-pcrel-overflow.s
index 78e8047..3dfcf9e 100644
--- a/test/ELF/eh-frame-pcrel-overflow.s
+++ b/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