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

Sam Clegg via llvm-commits llvm-commits at lists.llvm.org
Mon May 12 09:44:28 PDT 2025


================
@@ -568,6 +568,13 @@ void ElemSection::addEntry(FunctionSymbol *sym) {
     return;
   sym->setTableIndex(ctx.arg.tableBase + indirectFunctions.size());
   indirectFunctions.emplace_back(sym);
----------------
sbc100 wrote:

The problem here is that the very first function will not be aligned here since `tableBase` defaults to `1` which is not aligned.

How about doing this before the call to `indirectFunctions.emplace_back(sym);` (i.e. do the alignment before placing the function in the table instead of after?  That should also avoid the trailing null function entries in the table, that serve no purpose.


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


More information about the llvm-commits mailing list