-
Notifications
You must be signed in to change notification settings - Fork 108
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
Any reason FrameDescriptionEntry::write is not public? #648
Comments
It's not public because it didn't seem useful, and I didn't want to expose implementation details. I'm not yet convinced that it would be useful. My understanding is that |
Hard to know what this stuff expects, it's all tremendously badly documented. I don't know for sure what I'm trying to do will work, I only just started implementing it... My reading of the source seems to suggest that passing a single FDE to __register_frame will work, it will construct a single But yeah I have absolutely no idea if this will actually work. I guess i'll roll it by hand and report back here if it worked or not. |
On macOS you need to pass a single FDE. Wasmtime handles this by creating a full .eh_frame section and then walking the FDE in it. |
So the relevant code is https://github.com/bytecodealliance/wasmtime/blob/d3fdb5fc2c02c043e716f4aedf4854bb92705c7c/crates/jit/src/unwind/systemv.rs#L37-L68 which is called for an ELF file that is built up in memory, with a complete Does Wasmtime do JIT for individual functions? If so it must build an ELF for each one? |
Wasmtime always compiles an entire wasm module at once. |
So yes libgcc does want a full eh_frame section, because it advances through the provided list of FDE's until it sees a zero-length one (here: https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libgcc/unwind-dw2-fde.c;h=7b74c391ced1b70990736161a22c9adcea524a04;hb=HEAD#l719) It might work to pass an individual FDE with a four-byte NULL at the end, but each such FDE will be added as a separate That said, I did actually find having the FDE/CIE Maybe this kind of streaming construction of eh_frame sections would be a useful thing to add to gimli? |
That does sound useful. I'll be happy to apply patches that expose the write methods. Perhaps adding |
OK - let me keep banging my unwinder generator into shape, and when I figure out a good idea for the interface I'd like in gimli, I'll open up a PR. Thanks! |
I'm looking at generating .eh_frame data for JIT'd code with gimli. When the code generator makes code for a function, I want to use gimli to generate a Frame Description Entry for it, so I can immediately register it with libgcc's
__register_frame
API (which expects a pointer to a single FDE or CIE).Unfortunately I can't use gimli to generate a single Frame Description Entry or Common Information Entry, because the write function for those are private. Instead, only an entire
.eh_frame
section can be generated. Using this interface would require me to generate a .eh_frame section and hence a CIE for each generated function; however, I only really need one CIE for the whole program otherwise (I think) so this seems very wasteful.Instead, what I'd like to do is use gimli to generate FDE's and CIEs, and handle registering them with libgcc on an individual basis. I understand that this would mean generating the CIE first, getting its address, registering it with libgcc, and then passing that address to the
write
function of each FDE generated (so the offset to the CIE could be computed) - but this doesn't seem like a huge problem to me.Is there any reason that
FrameDescriptionEntry::write
andCommonInformationEntry::write
could not be made public for this use-case?Thanks!
The text was updated successfully, but these errors were encountered: