<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/76107>76107</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Symbol info from exports and name sections
</td>
</tr>
<tr>
<th>Labels</th>
<td>
backend:WebAssembly,
llvm:binary-utilities
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
dschuff
</td>
</tr>
</table>
<pre>
#75238 added support to WasmObjectFile to synthesize symbol information from exports rather than from a symbol table. The use case there is for dynamic libraries, but this is useful for nm/objdump too, for things like binary size attribution and general inspection of binaries (currently LLVM has no way to list a binary's imports or exports, nor to use information from the name section). Also, #75238 has pretty minimal information about the symbol (e.g. it has no flags).
objdump prints the following information for each symbol for object files:
Value/address; flags, including global/local/weak/debug; type; section; name.
nm also prints the symbol's size (as does objdump for ELF). and objdump has various other extensions for different object file types.
At minimum I think we should be able to use either/both of exports and name section to print symbols with nm/objdump, and it would be nice to print more complete information than we do in any case. This raises several questions.
1. Should this information be combined (i.e. symbol information is just automatically collected from whatever sources are available), or separated (you only get symbol information from one source at a time, and maybe you have to specify which).
- If combined, which kind of info should "win" in case of duplication?
1. It would be nice to be able to tell the source of a symbol's information (i.e. symtab, export/import, name). This could be a flag, or some kind of extension to the symbol name (e.g. where elf prints hidden symbols as ".hidden foo"), or something printed before (or instead of) "SYMBOL TABLE", or something else?
1. We currently print the size only for data symbols from symbol tables. We should probably just fix that and print it for functions from all sources.
1. We should probably make sure that for linked wasm files, symbol values for functions match up with what browsers print in stack traces (i.e. they use file offsets), as opposed to object files, which IIRC use section offsets.
1. There are several kinds of information in wasm that are not in other formats. How much should we try to show it all? If wabt goes away, this will become more important as a way to get full transparency into the wasm headers and known sections that llvm and binaryen don't currently give.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx0VtFu2zoS_Rr6ZVDDppI6fvBDknuNDZCLC2yLFvs4kkYWa4rUcsio2q9fDG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