[lld] [lld][ELF] Improve the vulnerability in Orphan Sections initialization (PR #156354)

Peter Smith via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 2 05:32:42 PDT 2025


================
@@ -1037,10 +1037,14 @@ void LinkerScript::addOrphanSections() {
     if (ctx.arg.relocatable && (isec->flags & SHF_LINK_ORDER))
       continue;
 
-    if (auto *sec = dyn_cast<InputSection>(isec))
-      if (InputSectionBase *rel = sec->getRelocatedSection())
+    if (auto *sec = dyn_cast<InputSection>(isec)){
+      if (InputSectionBase *rel = sec->getRelocatedSection()){
+        if (auto *relIS = dyn_cast_or_null<InputSectionBase>(rel))
----------------
smithp35 wrote:

Could we add a comment before the if statement like
// Ensure creation of OutputSection for relocated section before relocation section.

https://github.com/llvm/llvm-project/pull/156354


More information about the llvm-commits mailing list