-
Notifications
You must be signed in to change notification settings - Fork 168
Support parsing symbols from the linking section for wasm objects #471
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
Comments
Is this blocked on wasmparser support? Can you provide a wasm file that I can use for testing this? |
produces foo.o.gz (gzip compressed without a tar archive as github didn't accept a gzipped tarball despite saying that For reference:
|
This can be implemented without wasmparser changes. |
I didn't see anything in wasmparser that can parse these sections. Are you recommending we implement our own parsing? If we're going to use wasmparser for parsing wasm then I expect parsing of the linking section to be implemented in wasmparser. |
Wasmparser indeed doesn't have any code to parse this AFAIK. Adding the code to wasmparser would avoid code duplication with anyone else who needs it, but it would be possible to put the parse code for the linking custom section in object too. Wasmparser gives a raw byte slice as content for custom sections. |
If someone has to write the code, they may as well do it in wasmparser, so let's wait for someone to do that. |
I think this is now added in bytecodealliance/wasm-tools#1348 |
Does this explain why wasm symbols sometimes show up with no name? For a small demo: // rustc a.rs --emit=obj --target=wasm32-unknown-unknown --crate-type=lib -Cdebuginfo=0
extern "C" { fn some_undef(); }
#[unsafe(no_mangle)]
extern "C" fn somefunc() {
unsafe { some_undef() };
} llvm-nm correctly shows the two symbols but using
Util for reference fn main() {
let path = env::args().nth(1).unwrap();
let data = fs::read(path).expect("reading file failed");
let obj = object::File::parse(&*data).expect("failed to parse object");
for sym in obj.symbols() {
println!("{sym:?}");
}
} |
Yes, that's a Wasm object file so this issue needs to be fixed to properly support it. |
I've started implementing this. |
Can someone who wants this please review #766. |
Symbol names should be correct now. There is further work to do:
|
In case of wasm object files there is no export section. Instead all exported symbols are defined in the "linking" section. This is necessary for rust-lang/rust#97485. See https://github.com/WebAssembly/tool-conventions/blob/main/Linking.md for the full specification.
The text was updated successfully, but these errors were encountered: