https://github.com/christycylee created https://github.com/llvm/llvm-project/pull/68058
It can be hard to predict whether a section exist when using the `INSERT AFTER/BEFORE <section>` directive, this makes it difficult to apply a global linker script that's applicable to the entire build system. We should warn instead of hard error in such cases. >From 639029ce60d22aaeed46675b1fea0f0f20f0e014 Mon Sep 17 00:00:00 2001 From: Christy Lee <christy...@fb.com> Date: Mon, 2 Oct 2023 16:46:07 -0700 Subject: [PATCH] Warn instead of error when linker script fails to find section --- lld/ELF/LinkerScript.cpp | 2 +- lld/test/ELF/linkerscript/insert-not-exist.test | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp index df091613dc0a144..84658751b30487d 100644 --- a/lld/ELF/LinkerScript.cpp +++ b/lld/ELF/LinkerScript.cpp @@ -327,7 +327,7 @@ void LinkerScript::processInsertCommands() { return to != nullptr && to->osec.name == cmd.where; }); if (insertPos == sectionCommands.end()) { - error("unable to insert " + cmd.names[0] + + warn("unable to insert " + cmd.names[0] + (cmd.isAfter ? " after " : " before ") + cmd.where); } else { if (cmd.isAfter) diff --git a/lld/test/ELF/linkerscript/insert-not-exist.test b/lld/test/ELF/linkerscript/insert-not-exist.test index 8bb8a7d0ce8dc8f..4f68ad378678edd 100644 --- a/lld/test/ELF/linkerscript/insert-not-exist.test +++ b/lld/test/ELF/linkerscript/insert-not-exist.test @@ -1,9 +1,9 @@ # REQUIRES: x86 # RUN: llvm-mc -filetype=obj -triple=x86_64 %p/Inputs/insert-after.s -o %t.o -# RUN: not ld.lld -T %s %t.o -o /dev/null 2>&1 | FileCheck %s +# RUN: ld.lld -T %s %t.o -o /dev/null 2>&1 | FileCheck %s -# CHECK: error: unable to insert .foo.data after .not_exist -# CHECK: error: unable to insert .foo.text before .not_exist +# CHECK: warning: unable to insert .foo.data after .not_exist +# CHECK: warning: unable to insert .foo.text before .not_exist SECTIONS { .foo.data : {} } INSERT AFTER .not_exist; SECTIONS { .foo.text : {} } INSERT BEFORE .not_exist; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits