-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Add N_NO_DEAD_STRIP flag to section symbols #106444
Add N_NO_DEAD_STRIP flag to section symbols #106444
Conversation
…e beginning of the section are not stripped if there's no other N_NO_DEAD_STRIP symbol referencing them
Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas |
/azp run runtime-nativeaot-outerloop, runtime-extra-platforms |
Azure Pipelines successfully started running 2 pipeline(s). |
/azp run runtime-nativeaot-outerloop, runtime-extra-platforms |
Azure Pipelines successfully started running 2 pipeline(s). |
Cc @ivanpovazan @dotnet/jit-contrib @dotnet/ilc-contrib for Apple-specific ObjWriter change. Looks reasonable to me but don't know much about Apple stuff. |
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.
LGTM
@filipnavara I assume that we do not need to backport this fix to .NET 9. Correct?
I am on a verge on this one. On one hand it's not something that I saw in practice so it may not meet the bar. On the other hand, if it ever happens it will be incredibly difficult to trace it back to the root cause. Note the |
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.
The change looks good to me.
I am curious though, how did you find out the edge case that the previous PR did not cover?
It was result of the discussion in #106224. Michal pointed out that I tested the PR #106224 with both the old ld64 linker and the new ld-prime linker (which is still disabled by default in .NET), and I actually hit a case that exposed this bug. That said, it was most likely an artifact of other (local) changes and not reproducible in the wild. |
Extracted from #106224.
PR #103039 added
N_NO_DEAD_STRIP
flag to all symbols emitted by ILC and enabled the dead code stripping in the native linker.It failed to handle one specific edge case that is luckily not happening in the wild. If the first node emitted into a section has a symbol with non-zero offset NN the first
N_NO_DEAD_STRIP
symbol is not pointing at the start of the section. The native linker then splits up the section into atom and the first atom from offset 0 to offset NN is never referenced and becomes eligible for dead code stripping. Since we emit a symbol for each section start (for use in section-relative relocations) we can just mark the symbol withN_NO_DEAD_STRIP
to resolve the issue.