[lld] wasm-ld: Implement function pointer alignment (PR #105532)

Ethan O'Brien via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 14 10:43:23 PDT 2025


ethanaobrien wrote:

>It should be obivous from the disassembly if its address in the table is wrong.

It appears I was incorrect. You're right, main still fires how it should.

The issue is with apparently stdout somehow.


I have this test program `a.c`:
```c
#include <stdio.h>
int main() {
   printf("Potato?\n");
   return 0;
}
```

Compiled with: `EM_LLVM_ROOT=/home/ethan/git/llvm-project/build/bin emcc a.c -o a.html -Wl,--function-pointer-alignment=2 -gsource-map`

And the error appears to be tied to the call to print (or specifically, [this line](https://github.com/emscripten-core/emscripten/blob/c38fe09642e25a02dce25ad3d760f4203940e527/system/lib/libc/musl/src/stdio/fwrite.c#L16))
![{6F1EAFE7-FDA8-4332-970F-156ED3A398B5}](https://github.com/user-attachments/assets/6bf55e98-1b17-483f-8f67-61d8e9d8301e)


Or similar happens if attempting to write data to a file:
![image](https://github.com/user-attachments/assets/b582fede-61c2-4426-8a37-a8d046df5711)
https://github.com/emscripten-core/emscripten/blob/c38fe09642e25a02dce25ad3d760f4203940e527/system/lib/libc/musl/src/stdio/fflush.c#L29

What I dont understand is why changing the index of the first function broke this?

https://github.com/llvm/llvm-project/pull/105532


More information about the llvm-commits mailing list