-
Notifications
You must be signed in to change notification settings - Fork 6
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
Should DW_OP_Wasm_location's "index" field be an int32 so it can be easily relocatable? #12
Comments
I tried to keep it flexible. |
From Binaryen's point of view (and likely other tools doing DWARF post-processing) using int32s for such fields would be greatly preferred (almost all fields we need to update are such already). |
Ok, so if it's a flexible format, are we ok with it changing from a LEB to an int32? Do we need any kind of backwards compatibility? There will currently be a single 0 byte, and in the future 4 zero bytes (for its current use). Old code expecting a LEB will thus sorta work if its ok with extra bytes? |
I recommend to add another code in case if somebody already started writing tools. Also, it is nice to have compact form as well. In LLVM, we can keep |
so we add a |
Why is the word |
Good point. It was probably left from pilot -- we can remove "_START"s |
I can probably do that as part of my change :) |
/cc @pfaffe |
We have definitions like:
I don't see how. |
That's unfortunate. It looks like it is LLVM's
Did we completely abandon the idea of using expanded LEBs here? That might not be as bad as redesigning LLVM and crating different Wasm tags. |
That is still an option I guess, but it doesn't get around all the issues. You still have the problem that |
The more generic way for creation of relocatable DWARF expressions might be desired functionality similar e.g. for I saw similar request in the gimli-rs library. |
@yurydelendik Thanks! I see no existing use of |
The implementing of |
Ok, I've created a possible solution here: https://reviews.llvm.org/D77353 The output in .S is now:
Before it was:
Dwarfdump says: As discussed, the new code replicates functionality of what normally Note that it would be nice to use the same code for the I haven't tested this code beyond checking the above output, and modifying the tests that used type Oh and then there's the small matters of not wanting to include |
Final call for comments on this issue or https://reviews.llvm.org/D77353 :) |
Just to clarify, that the requirement of having int32 as an argument for DW_OP_Wasm_location comes from external tools (such as Binaryen?) and not from LLVM itself. Reading the patch at https://reviews.llvm.org/D77353 shows that we already had The added |
Is there anything needs to be changed at https://github.com/yurydelendik/webassembly-dwarf/ to document the new encoding? |
@yurydelendik I am not sure if there is a requirement, I am simply going with the consensus earlier in this issue about what is a better representation. The primary consumer of this would be LLD I think. And yes, we should probably document it, but it doesn't seem that it is final yet. |
Can people give their opinion on which tag encoding they prefer (see the end of https://reviews.llvm.org/D77353) |
This to allow us to add reloctable global indices as a symbol. Also adds R_WASM_GLOBAL_INDEX_I32 relocation type to support it. See discussion in WebAssembly/debugging#12
This to allow us to add reloctable global indices as a symbol. Also adds R_WASM_GLOBAL_INDEX_I32 relocation type to support it. See discussion in WebAssembly/debugging#12
This to allow us to add reloctable global indices as a symbol. Also adds R_WASM_GLOBAL_INDEX_I32 relocation type to support it. See discussion in WebAssembly/debugging#12
DW_OP_Wasm_location
currently has a type and index field that are both LEBs. For use with typeTI_GLOBAL_START
the index needs to be relocatable.Doing LEB relocations in DWARF seems messy, as we need expanded LEBs that then (maybe) get re-compressed by a tool like Binaryen, if at all. int32 relocations are more common, simpler, and would better fit DWARF.
Why are we doing this at all? The first use case is having the Frame Base refer to
__stack_pointer
in case the function doesn't have an explicit Frame Base Local set. This is not super useful since it typically means the function has no shadow stack usage, but there may be other reasons to refer to globals from DWARF, so it be good to get this right?For context:
WebAssemblyFrameLowering::getDwarfFrameBase
: https://github.com/llvm/llvm-project/blob/e8d67ada2df35ca6c70dbbe8185b0edbb18c1150/llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp#L271-L274Called from
DwarfCompileUnit::updateSubprogramScopeDIE
: https://github.com/llvm/llvm-project/blob/e8d67ada2df35ca6c70dbbe8185b0edbb18c1150/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp#L423-L432Calls into
DwarfExpression::addWasmLocation
: https://github.com/llvm/llvm-project/blob/e8d67ada2df35ca6c70dbbe8185b0edbb18c1150/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp#L585-L591This functionality originally introduced in https://reviews.llvm.org/D52634 https://reviews.llvm.org/D44184
Or maybe we should do this entirely differently? How does this affect unwinding by the debugger?
cc: @dschuff @sbc100 @kripken @yurydelendik @sunfishcode
The text was updated successfully, but these errors were encountered: