diff --git a/lld/test/wasm/shared.ll b/lld/test/wasm/shared.ll --- a/lld/test/wasm/shared.ll +++ b/lld/test/wasm/shared.ll @@ -132,7 +132,7 @@ ; CHECK-NEXT: Index: 2 ; CHECK-NEXT: Functions: [ 4, 3 ] -; check the generated code in __wasm_call_ctors and __wasm_apply_relocs functions +; check the generated code in __wasm_call_ctors and __wasm_apply_data_relocs functions ; TODO(sbc): Disassemble and verify instructions. ; CHECK: - Type: CODE diff --git a/lld/test/wasm/weak-undefined-pic.s b/lld/test/wasm/weak-undefined-pic.s --- a/lld/test/wasm/weak-undefined-pic.s +++ b/lld/test/wasm/weak-undefined-pic.s @@ -29,7 +29,7 @@ # Verify that we do not generate dynamic relocations for the GOT entry. -# CHECK-NOT: __wasm_apply_relocs +# CHECK-NOT: __wasm_apply_global_relocs # Verify that we do not generate an import for foo @@ -45,7 +45,7 @@ # CHECK-NEXT: Value: 66560 # Global 'undefined_weak:foo' representing the GOT entry for foo # Unlike other internal GOT entries that need to be mutable this one -# is immutable and not updated by `__wasm_apply_relocs` +# is immutable and not updated by `__wasm_apply_gloal_relocs` # CHECK-NEXT: - Index: 1 # CHECK-NEXT: Type: I32 # CHECK-NEXT: Mutable: false diff --git a/lld/wasm/MarkLive.cpp b/lld/wasm/MarkLive.cpp --- a/lld/wasm/MarkLive.cpp +++ b/lld/wasm/MarkLive.cpp @@ -189,7 +189,7 @@ return false; // In Emscripten-style PIC, we call `__wasm_call_ctors` which calls - // `__wasm_apply_relocs`. + // `__wasm_apply_data_relocs`. if (config->isPic) return true; diff --git a/lld/wasm/SyntheticSections.cpp b/lld/wasm/SyntheticSections.cpp --- a/lld/wasm/SyntheticSections.cpp +++ b/lld/wasm/SyntheticSections.cpp @@ -333,7 +333,7 @@ WasmGlobal global; // In the case of dynamic linking, internal GOT entries // need to be mutable since they get updated to the correct - // runtime value during `__wasm_apply_relocs`. + // runtime value during `__wasm_apply_global_relocs`. bool mutable_ = config->isPic & !sym->isStub; global.Type = {WASM_TYPE_I32, mutable_}; global.InitExpr.Opcode = WASM_OPCODE_I32_CONST; diff --git a/lld/wasm/Writer.cpp b/lld/wasm/Writer.cpp --- a/lld/wasm/Writer.cpp +++ b/lld/wasm/Writer.cpp @@ -1121,8 +1121,8 @@ // For -shared (PIC) output, we create create a synthetic function which will // apply any relocations to the data segments on startup. This function is -// called __wasm_apply_relocs and is added at the beginning of __wasm_call_ctors -// before any of the constructors run. +// called `__wasm_apply_data_relocs` and is added at the beginning of +// `__wasm_call_ctors` before any of the constructors run. void Writer::createApplyDataRelocationsFunction() { LLVM_DEBUG(dbgs() << "createApplyDataRelocationsFunction\n"); // First write the body's contents to a string. @@ -1160,7 +1160,7 @@ // in input object. void Writer::createCallCtorsFunction() { // If __wasm_call_ctors isn't referenced, there aren't any ctors, and we - // aren't calling `__wasm_apply_relocs` for Emscripten-style PIC, don't + // aren't calling `__wasm_apply_data_relocs` for Emscripten-style PIC, don't // define the `__wasm_call_ctors` function. if (!WasmSym::callCtors->isLive() && !WasmSym::applyDataRelocs && initFunctions.empty()) @@ -1203,9 +1203,8 @@ raw_string_ostream os(bodyContent); writeUleb128(os, 0, "num locals"); - // If we have any ctors, or we're calling `__wasm_apply_relocs` for - // Emscripten-style PIC, call `__wasm_call_ctors` which performs those - // calls. + // Call `__wasm_call_ctors` which call static constructors (and + // applies any runtime relocations in Emscripten-style PIC mode) if (WasmSym::callCtors->isLive()) { writeU8(os, WASM_OPCODE_CALL, "CALL"); writeUleb128(os, WasmSym::callCtors->getFunctionIndex(),