<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/63354>63354</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang -fPIC creates wrong relocation type for wasm32
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
TerrorJack
</td>
</tr>
</table>
<pre>
Minimal repro:
```c
void internal_memalign();
void *dlmemalign() { return internal_memalign; }
```
Compile and link with:
```
clang --target=wasm32 -fPIC -c test.c -o test.o
wasm-ld --shared --no-gc-sections test.o -o test.wasm
```
Linking step fails with:
```
wasm-ld: warning: creating shared libraries, with -shared, is not yet stable
wasm-ld: error: test.o: relocation R_WASM_TABLE_INDEX_SLEB cannot be used against symbol `internal_memalign`; recompile with -fPIC
```
This can be reproduced by latest llvm build from current `main` branch.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMk99v2jAQx_8a5-UUFGwS4CEPUIrUqZ2mtdL2hi72kXh1bGQ7Rfz3kxO2detWTULkTrkfH-f7NYagW0tUs3LLyl2GQ-ycr5_Ie-c_oHzOGqcu9YO2ukcDnk7eMbFhxY4VP_6rYvrJKX9xWoG2kbxFc-ipR6Nby_iK8TUT21dFjG-U-b0A2HILnuLg7V9miC2w5e6Pta9Zblx_0oYArQKj7TOcdez-xTul0qBtIc8j-pYiE7szhl5wyI-f7m4glxApxJmE3E2Rm9pSVW4U5Hno0FMKrMtbmQeSUTsbrtU_-1LDO-T32j5r20KIdIIjahP-g_0KwcQGzuittm0KpSeM46yJzOjGo9cUGL8Zh8KVOeU6gHURLhQhRGwMvZk8WiEF1-OLDXgyTmI6Jnw-fNk8PhyeNtv728Pdx93t18Pj_e0WJNo0tyEYAinAFrUNEcKlb5wBVhVv1a2KJLAneRVxQk0yvPPdnjod0rK0aXSnGiQpaC5gMAGDMS89NIM2Co7e9SAH78nGhNCjTluh8WhlN8tULdRarDGjel6tqvVivlyVWVcjV2tcSFWo9fFYHYUqZblCzvl8KYWiRaZrXnBRVPNqviorXs6Wc5JLVRQVrtRiLgVbFNSjNrNEM3O-zXQIA9WVEOUiM9iQCeMV5NzSGcaXjPN0I32devJmaANbFEaHGH5NiToaqq8WHg07ik8Bzt7Z9rVQ8XIiODoPk7-zwZu6i_EUksX4nvF9q2M3NDPpesb3acX1kZ-8-0YyMr4fwQLj-xH8ewAAAP__v3VSwg">