-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[lld] Add support for EC code map. #69101
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Shouldn't we close the range at the end of each section as well? Or is it valid to have two sections that follow on each other (or one section, followed by a non-code section, followed by another code section with the same type, and having the range spanning over that?)
Uh oh!
There was an error while loading. Please reload this page.
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.
It is valid for code range to span over multiple sections of the same type. I will add a test covering that case.
I retested more corner cases with MS link.exe, because I noticed that the isCodeSection here may not be exactly right. As implemented in #69100 and #70722, data chunks properties are preserved when merging into code sections, code chunks may be preserved when merging into data sections. That's indeed the case, although I ran into some bugs in link.exe so the whole thing seems fragile. Boundaries are not calculated correctly in some cases. I will update patches with what I think is the intended behavior.
One thing I didn't replicate is that data chunks do not cause closing ranges if they don't cross a page boundaries. This usually does not make a difference, because such data chunks are aligned (as implemented in #69100), so they cross page boundaries anyway. However when doing code into data merges, they are not aligned, so it's possible that they don't cross page boundaries. This was a bit confusing when testing and I don't think this makes much sense to replicate (and would be tricky to do because during EC map creation addresses are not yet assigned and can't be assigned because we don't know the size of map itself).
I also noticed a difference in behavior that is not ARM64EC specific. When doing code into data merges with MS link.exe, it marks target section with a code section flag (but still no exec permission, so it doesn't affect isCodeSection result and our use of isCodeSection matches link.exe behavior in that regard). I will create PR implementing that. It's needed for disassembler to disassemble such sections, which is used in my new tests, but if you think it's not worth replicating, I could alternatively just remove that part of the test.
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.
Oh, I overlooked the
if (!sec->isCodeSection()) { closeRange(); continue; }
bit in the previous version - I guess that would have covered the case I thougth about. But with that removed, I guess this also looks good. Thanks!