[llvm] [MachO] Fatal error on invalid section index (PR #167418)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 10 15:50:09 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-mc
Author: Prabhu Rajasekaran (Prabhuk)
<details>
<summary>Changes</summary>
When there are more than 255 sections, MachO object writer allows
creation of object files which are potentially malformed. Currently,
there is an assertion in object writer code that prevents it. But for
distributions where assertions are turned on this still results in
creation of malformed objects. Turning the assertion into an explicit
fatal error.
---
Full diff: https://github.com/llvm/llvm-project/pull/167418.diff
1 Files Affected:
- (modified) llvm/lib/MC/MachObjectWriter.cpp (+2-1)
``````````diff
diff --git a/llvm/lib/MC/MachObjectWriter.cpp b/llvm/lib/MC/MachObjectWriter.cpp
index 39542bfbdd8e3..a6d87827795c2 100644
--- a/llvm/lib/MC/MachObjectWriter.cpp
+++ b/llvm/lib/MC/MachObjectWriter.cpp
@@ -646,7 +646,8 @@ void MachObjectWriter::computeSymbolTable(
LocalSymbolData.push_back(MSD);
} else {
MSD.SectionIndex = SectionIndexMap.lookup(&Symbol.getSection());
- assert(MSD.SectionIndex && "Invalid section index!");
+ if (!MSD.SectionIndex)
+ report_fatal_error("Invalid section index!");
LocalSymbolData.push_back(MSD);
}
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/167418
More information about the llvm-commits
mailing list