[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:43 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()){
----------------
smithp35 wrote:

could rel be renamed to relocated here? 

Not part of your change, but I think it would be an improvement. When reviewing just the diff, it was difficult to tell from the name rel whether we are referring to the relocation section, or the section being relocated.

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


More information about the llvm-commits mailing list