-
Notifications
You must be signed in to change notification settings - Fork 61
Move functions to ELF sections with mangled names. #1160
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
54e04a2
to
e1d10df
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1160 +/- ##
==========================================
- Coverage 95.64% 95.62% -0.03%
==========================================
Files 148 150 +2
Lines 42531 42646 +115
==========================================
+ Hits 40680 40779 +99
- Misses 1851 1867 +16 ☔ View full report in Codecov by Sentry. |
Hello Arthur, |
That makes a lot of sense!
I think the name mangling algorithm will evolve over time, and it will create lots of changes in the testsuite each time - furthermore, its goal is only to be consumed by the dynamic loader, so I think the format changing is not super worrisome. I think adding a flag and keeping mangling off by default is the way to go. It might be good to create a new mangling testsuite where code is compiled using this flag to see changes to the mangling, but I don't think this is really necessary. In our local development branch we have also started adding the reverse operation, in order to decode mangled names into instances of 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.
I think this approach is fine. Since there is lots of things open I guess we're going to discuss things in more detail.
Things that cought my attention were that we can probably discuss during future work:
- you're basically re-building the type-information in a separate enum that more or less (so far) reflects the DataTypeInformation enum - I think this is fine for now if that feels natural for you - for the moment it looks like it does not add any new information and will become a 1-to-1 relationship. So maybe you will decide at one point that you can mangle the type names directly from the DataTypeInformation.
- I dont really mind the section names in the test. If it gets annoying that you keep changing the tests I'm also fine with introducing a feature-flag
- Have you thought about using a hash instead of the whole signature? - but this is off-topic now ...
so overall I think this can be merged
2dc7e84
to
6a307b6
Compare
I think that having a feature flag would make it easier to iterate on mangling schemes as well as test the future parser - I'll add it and push |
Nevermind, accessing the CLI flags this far down the line is non-trivial, so if we do decide to go through with this I think it should be done in a separate PR. On a separate note, the "Style" check fails due to files that were not modified in this PR |
6a307b6
to
b77e9b6
Compare
should now be rebased properly :) |
b77e9b6
to
53b44c4
Compare
The section-mangler crate provides a simple builder for representing StructuredText functions and variables and mangling their name.
This commit relocates generated LLVM functions to sections using the appropriate mangled name.
This enables sharing the type mangling with the variable generator
This PR adds a basic section name mangling library to encode the type information of variables and functions as a section name within the resulting binary. When codegen'ing POUs, we can now set the section name of the function using the provided inkwell API. I'll add the same functionality for variables in a later PR.
The section-mangler library should stay quite simple but it will also include decoding of a mangled string, to enable reconstructing an instance of
SectionMangler
from a section name. Let me know if you'd like the API to look differently or if using a simple builder-like pattern like this one is okay.Last commit updates all of the snapshots, hence making that PR quite big.