Skip to content

Commit c1f10ef

Browse files
committed
[ELF] SHF_LINK_ORDER: replace Fatal with ErrAlways
In LLD_IN_TEST=2 mode, when a thread calls Fatal, there will be no output even if the process exits with code 1. Change the Fatal to ErrAlways (not-recoverable) as subsequent code assumes SHF_LINK_ORDER sh_link is correct.
1 parent 18335f4 commit c1f10ef

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

lld/ELF/InputFiles.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -890,9 +890,11 @@ void ObjFile<ELFT>::initializeSections(bool ignoreComdats,
890890
InputSectionBase *linkSec = nullptr;
891891
if (sec.sh_link < size)
892892
linkSec = this->sections[sec.sh_link];
893-
if (!linkSec)
894-
Fatal(ctx) << this
895-
<< ": invalid sh_link index: " << uint32_t(sec.sh_link);
893+
if (!linkSec) {
894+
ErrAlways(ctx) << this
895+
<< ": invalid sh_link index: " << uint32_t(sec.sh_link);
896+
continue;
897+
}
896898

897899
// A SHF_LINK_ORDER section is discarded if its linked-to section is
898900
// discarded.

lld/test/ELF/invalid/linkorder-invalid-sec.test

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# REQUIRES: x86
22
# RUN: yaml2obj %s -o %t.o
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: invalid sh_link index: 12345
55

66
--- !ELF

0 commit comments

Comments
 (0)