Skip to content

Commit

Permalink
Requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanaobrien committed Jan 22, 2025
1 parent 50aa217 commit 983433d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
3 changes: 2 additions & 1 deletion lld/wasm/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,8 @@ static void readConfigs(opt::InputArgList &args) {
LLVM_DEBUG(errorHandler().verbose = true);

ctx.arg.tableBase = args::getInteger(args, OPT_table_base, 0);
ctx.arg.functionPointerAlignment = args::getInteger(args, OPT_function_pointer_alignment, 0);
ctx.arg.functionPointerAlignment =
args::getInteger(args, OPT_function_pointer_alignment, 0);
ctx.arg.globalBase = args::getInteger(args, OPT_global_base, 0);
ctx.arg.initialHeap = args::getInteger(args, OPT_initial_heap, 0);
ctx.arg.initialMemory = args::getInteger(args, OPT_initial_memory, 0);
Expand Down
13 changes: 5 additions & 8 deletions lld/wasm/SyntheticSections.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -569,8 +569,9 @@ void ElemSection::addEntry(FunctionSymbol *sym) {
sym->setTableIndex(ctx.arg.tableBase + indirectFunctions.size());
indirectFunctions.emplace_back(sym);

// Pad with null function pointers if alignment is requesting.
if (ctx.arg.functionPointerAlignment > 1) {
for (uint32_t i=0; i<ctx.arg.functionPointerAlignment-1; i++) {
while ((ctx.arg.tableBase + indirectFunctions.size()) % ctx.arg.functionPointerAlignment) {
indirectFunctions.push_back(nullptr);
}
}
Expand Down Expand Up @@ -610,15 +611,11 @@ void ElemSection::writeBody() {
writeUleb128(os, indirectFunctions.size(), "elem count");
uint32_t tableIndex = ctx.arg.tableBase;
for (const FunctionSymbol *sym : indirectFunctions) {
if (sym == nullptr) {
(void) tableIndex;
writeUleb128(os, 0, "function index");
++tableIndex;
continue;
if (sym != nullptr) {
assert(sym->getTableIndex() == tableIndex);
}
assert(sym->getTableIndex() == tableIndex);
(void) tableIndex;
writeUleb128(os, sym->getFunctionIndex(), "function index");
writeUleb128(os, sym ? sym->getFunctionIndex() : 0, "function index");
++tableIndex;
}
}
Expand Down

0 comments on commit 983433d

Please sign in to comment.