[lld] c1f10ef - [ELF] SHF_LINK_ORDER: replace Fatal with ErrAlways

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sat Jan 25 18:13:50 PST 2025


Author: Fangrui Song
Date: 2025-01-25T18:13:42-08:00
New Revision: c1f10ef0a5c15f1dccf87ff07699055297c715a5

URL: https://github.com/llvm/llvm-project/commit/c1f10ef0a5c15f1dccf87ff07699055297c715a5
DIFF: https://github.com/llvm/llvm-project/commit/c1f10ef0a5c15f1dccf87ff07699055297c715a5.diff

LOG: [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.

Added: 
    

Modified: 
    lld/ELF/InputFiles.cpp
    lld/test/ELF/invalid/linkorder-invalid-sec.test

Removed: 
    


################################################################################
diff  --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index e236057a0d6d19..eba4c234d3f167 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -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.

diff  --git a/lld/test/ELF/invalid/linkorder-invalid-sec.test b/lld/test/ELF/invalid/linkorder-invalid-sec.test
index a2f4ee8f5bc2b1..e0132956f0ba1d 100644
--- a/lld/test/ELF/invalid/linkorder-invalid-sec.test
+++ b/lld/test/ELF/invalid/linkorder-invalid-sec.test
@@ -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


        


More information about the llvm-commits mailing list