-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[MachO] Report error when there are too many sections #167418
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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.
|
@llvm/pr-subscribers-llvm-mc Author: Prabhu Rajasekaran (Prabhuk) ChangesWhen there are more than 255 sections, MachO object writer allows Full diff: https://github.com/llvm/llvm-project/pull/167418.diff 1 Files Affected:
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);
}
}
|
|
Addresses issue: #167408 |
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
lhames
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Thanks @Prabhuk!
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/144/builds/39919 Here is the relevant piece of the build log for the reference |
|
Hello, we saw llvm test failure with this PR. Could you please take a look? Thanks! bot: https://lab.llvm.org/buildbot/#/builders/10/builds/17126 |
|
Apologies @Kewen12 -- sending out a fix right away. If that doesn't work I'll revert ASAP. |
|
#167598 -- please let me know if this fixes the failure. |
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/160/builds/28102 Here is the relevant piece of the build log for the reference |
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/180/builds/28242 Here is the relevant piece of the build log for the reference |
When there are more than 255 sections, MachO object writer allows
creation of object files which are potentially malformed. Currently,
there are assertions in object writer code that prevents this behavior.
But for distributions where assertions are turned off this still results in
creation of malformed object files. Turning assertions into explicit
errors.