Issue 143934
Summary WebAssembly tables + global variables + debug info = invalid binaries
Labels new issue
Assignees
Reporter feedab1e
    creating a WebAssembly table and another global variable, then compiling with debug info, yields a binary that cannot be read or linked by any llvm tool ([link](https://gcc.godbolt.org/z/hP5dPq5qx)):
```cpp
// 1.cpp
int a;
inline static __externref_t table[0];

int main() {
    __externref_t get();
    __builtin_wasm_table_set(table, 0, get());
}
```
if compiled with
```
clang++ -g --target=wasm32 1.cpp -c -o 1.o
```
and used like following:
```
llvm-dwarfdump 1.o
```
will yield
```
error: 1.o: invalid data relocation: _ZL5table
```
The same issue occurs when trying to link:
```
wasm-ld --no-entry 1.o -o 1.wasm
```
yields
```
wasm-ld: error: 1.o: invalid data relocation: _ZL5table
```

Notably, the same issue does not occur when we remove the declaration of `a`:
```
// 1.cpp
inline static __externref_t table[0];

int main() {
 __externref_t get();
    __builtin_wasm_table_set(table, 0, get());
}
```
links successfully.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to