Skip to content

Commit

Permalink
[ELF] SHF_LINK_ORDER: replace Fatal with ErrAlways
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
MaskRay committed Jan 26, 2025
1 parent 18335f4 commit c1f10ef
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions lld/ELF/InputFiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -890,9 +890,11 @@ void ObjFile<ELFT>::initializeSections(bool ignoreComdats,
InputSectionBase *linkSec = nullptr;
if (sec.sh_link < size)
linkSec = this->sections[sec.sh_link];
if (!linkSec)
Fatal(ctx) << this
<< ": invalid sh_link index: " << uint32_t(sec.sh_link);
if (!linkSec) {
ErrAlways(ctx) << this
<< ": invalid sh_link index: " << uint32_t(sec.sh_link);
continue;
}

// A SHF_LINK_ORDER section is discarded if its linked-to section is
// discarded.
Expand Down
2 changes: 1 addition & 1 deletion lld/test/ELF/invalid/linkorder-invalid-sec.test
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# REQUIRES: x86
# RUN: yaml2obj %s -o %t.o
# 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: invalid sh_link index: 12345

--- !ELF
Expand Down

0 comments on commit c1f10ef

Please sign in to comment.