-
Notifications
You must be signed in to change notification settings - Fork 1
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
ykstackmaps can't deal with >1 compilation unit #2
Comments
I think the answer to the following question is "no", but: can we enforce / check |
There's another side-problem relating to your question too. To correctly issue sequential stackmap IDs we cannot use incremental compilation either. Since we are forking rustc, we can pretty do what we want, so yes, we could check for these things. |
Bah, sadly the workaround doesn't work if you have dependencies, as each dependency forks off a fresh rustc with its own CGU. |
Surely each dependency would have to be compiled with our fork of rustc? |
That is true, but irrelevant. Because a dependency is built using a fresh rustc (and thus a fresh CGU), each dependency is compiled separately and gets its own stackmap table. Only at the linking stage do the stackmap tables get merged by the linker. It also means that stack map IDs are not unique, which is another issue for us. |
Surely it was inevitable that stackmaps are only valid for their crate? I don't see how it could be any other way, but maybe I'm missing out on something. |
Maybe, yeah. We can work around the ID issue, but there's no avoiding the need to change ykstackmaps to cater for >1 stackmap table. What is slightly ironic is that LLVM's own stackmap dumping tool doesn't cater for >1 table either! |
Currently ykstackmaps finds the stackmap section, and reads the stackmap info it finds there, allowing the user to iterate it, stopping after the end of all stackmap records.
The problem is that multiple stackmap "tables" can be encoded in the section. If you have more than one CGU, then multiple sets of stackmap info are created independently in separate object files. Then at the end, the linker simply concatenates all of the stackmap infos together back-to-back (using the documented 8-byte alignment on the end of each stackmap "block").
ykstackmaps only expects one "table" of stackmap info, but there can be many.
You can verify this using radare2.
We can see in the hexdumps above the stackmap version, # of funcs, # of constants and # of records fields for those two stackmap "tables".
Ultimately, we'd want to allow >1 CGU, which would mean finding a way to know how many tables to expect and reading them all.
Until then, we can use the following hack to force one CGU and thus one set of stackmap data. In
Cargo.toml
:(
profile.release
for--release
builds)This seems to give a full set of stackmaps in the first table, BUT sadly r2 still finds other tables (
loc.__LLVM_StackMaps_1
etc.) which contain garbage. The have a correct looking LLVM stackmap version header, but the info beyond that is junk.We'd need to look into a way to find how many tables to look for.
The text was updated successfully, but these errors were encountered: