<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/104576>104576</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[WebAssembly] mysterious imports of aliases
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
yamt
</td>
</tr>
</table>
<pre>
i noticed a lot of mysterious imports in wasi-libc libc.so.
the following is a smaller example of the symptom.
alias.c:
```c
int
add1(int x)
{
return x + 1;
}
extern int add1_alias(int x)
__attribute__((visibility("default"), weak, alias("add1")));
```
build it with:
```shell
clang -nostdlib -shared -Wl,--no-entry -o lib.so alias.c
```
look at the generated lib.so, see `env.add1_alias` import.
```
Import[6]:
- memory[0] pages: initial=0 <- env.memory
- table[0] type=funcref initial=0 <- env.__indirect_function_table
- global[0] i32 mutable=1 <- env.__stack_pointer
- global[1] i32 mutable=0 <- env.__memory_base
- global[2] i32 mutable=0 <- env.__table_base
- func[0] sig=0 <add1_alias> <- env.add1_alias
```
i don't see any obvious reasons to import this symbol.
actually, the imported function doesn't seem to be used within the module at all.
fwiw, the export sections of the module look like:
```
Export[2]:
- func[2] <__wasm_apply_data_relocs> -> "__wasm_apply_data_relocs"
- func[3] <add1> -> "add1_alias"
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyEVcuOqzgQ_RpnUyICEwi9YHHTuS3NF9wlsqGS1LSxI1x0wt-PbKBv-qWJEMRwzvGpB4Xyns4WsRbFQRTHjRr54oZ6Uj1vtOummsA6phY7UGAcgztBP3nGgdzogfqrG9gDWbgpT4kh3UI4bb3bivQo0l98QTg5Y9yN7BnIgwLfK2NwALyr_mowaAaUn_oru37hzWdlSPltK_JlLcp0Ptp5TZYXYNdlQlZkGe5CPi3o_WH-A8tvQB4HC3cQ8gCZyA8r7vi4Kd4ZBwtBK8g20cQXcWgaxTyQHhmbRshKyOqN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