aboutsummaryrefslogtreecommitdiff
path: root/lld/wasm/SyntheticSections.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lld/wasm/SyntheticSections.cpp')
-rw-r--r--lld/wasm/SyntheticSections.cpp56
1 files changed, 28 insertions, 28 deletions
diff --git a/lld/wasm/SyntheticSections.cpp b/lld/wasm/SyntheticSections.cpp
index 6b32d12..715fba1 100644
--- a/lld/wasm/SyntheticSections.cpp
+++ b/lld/wasm/SyntheticSections.cpp
@@ -55,7 +55,7 @@ public:
bool DylinkSection::isNeeded() const {
return ctx.isPic ||
- config->unresolvedSymbols == UnresolvedPolicy::ImportDynamic ||
+ ctx.arg.unresolvedSymbols == UnresolvedPolicy::ImportDynamic ||
!ctx.sharedFiles.empty();
}
@@ -162,7 +162,7 @@ void TypeSection::writeBody() {
uint32_t ImportSection::getNumImports() const {
assert(isSealed);
uint32_t numImports = importedSymbols.size() + gotSymbols.size();
- if (config->memoryImport.has_value())
+ if (ctx.arg.memoryImport.has_value())
++numImports;
return numImports;
}
@@ -232,20 +232,20 @@ void ImportSection::writeBody() {
writeUleb128(os, getNumImports(), "import count");
- bool is64 = config->is64.value_or(false);
+ bool is64 = ctx.arg.is64.value_or(false);
- if (config->memoryImport) {
+ if (ctx.arg.memoryImport) {
WasmImport import;
- import.Module = config->memoryImport->first;
- import.Field = config->memoryImport->second;
+ import.Module = ctx.arg.memoryImport->first;
+ import.Field = ctx.arg.memoryImport->second;
import.Kind = WASM_EXTERNAL_MEMORY;
import.Memory.Flags = 0;
import.Memory.Minimum = out.memorySec->numMemoryPages;
- if (out.memorySec->maxMemoryPages != 0 || config->sharedMemory) {
+ if (out.memorySec->maxMemoryPages != 0 || ctx.arg.sharedMemory) {
import.Memory.Flags |= WASM_LIMITS_FLAG_HAS_MAX;
import.Memory.Maximum = out.memorySec->maxMemoryPages;
}
- if (config->sharedMemory)
+ if (ctx.arg.sharedMemory)
import.Memory.Flags |= WASM_LIMITS_FLAG_IS_SHARED;
if (is64)
import.Memory.Flags |= WASM_LIMITS_FLAG_IS_64;
@@ -351,14 +351,14 @@ void TableSection::assignIndexes() {
void MemorySection::writeBody() {
raw_ostream &os = bodyOutputStream;
- bool hasMax = maxMemoryPages != 0 || config->sharedMemory;
+ bool hasMax = maxMemoryPages != 0 || ctx.arg.sharedMemory;
writeUleb128(os, 1, "memory count");
unsigned flags = 0;
if (hasMax)
flags |= WASM_LIMITS_FLAG_HAS_MAX;
- if (config->sharedMemory)
+ if (ctx.arg.sharedMemory)
flags |= WASM_LIMITS_FLAG_IS_SHARED;
- if (config->is64.value_or(false))
+ if (ctx.arg.is64.value_or(false))
flags |= WASM_LIMITS_FLAG_IS_64;
writeUleb128(os, flags, "memory limits flags");
writeUleb128(os, numMemoryPages, "initial pages");
@@ -415,8 +415,8 @@ void GlobalSection::addInternalGOTEntry(Symbol *sym) {
}
void GlobalSection::generateRelocationCode(raw_ostream &os, bool TLS) const {
- assert(!config->extendedConst);
- bool is64 = config->is64.value_or(false);
+ assert(!ctx.arg.extendedConst);
+ bool is64 = ctx.arg.is64.value_or(false);
unsigned opcode_ptr_const = is64 ? WASM_OPCODE_I64_CONST
: WASM_OPCODE_I32_CONST;
unsigned opcode_ptr_add = is64 ? WASM_OPCODE_I64_ADD
@@ -466,7 +466,7 @@ void GlobalSection::writeBody() {
writeGlobalType(os, g->getType());
writeInitExpr(os, g->getInitExpr());
}
- bool is64 = config->is64.value_or(false);
+ bool is64 = ctx.arg.is64.value_or(false);
uint8_t itype = is64 ? WASM_TYPE_I64 : WASM_TYPE_I32;
for (const Symbol *sym : internalGotSymbols) {
bool mutable_ = false;
@@ -474,11 +474,11 @@ void GlobalSection::writeBody() {
// In the case of dynamic linking, unless we have 'extended-const'
// available, these global must to be mutable since they get updated to
// the correct runtime value during `__wasm_apply_global_relocs`.
- if (!config->extendedConst && ctx.isPic && !sym->isTLS())
+ if (!ctx.arg.extendedConst && ctx.isPic && !sym->isTLS())
mutable_ = true;
// With multi-theadeding any TLS globals must be mutable since they get
// set during `__wasm_apply_global_tls_relocs`
- if (config->sharedMemory && sym->isTLS())
+ if (ctx.arg.sharedMemory && sym->isTLS())
mutable_ = true;
}
WasmGlobalType type{itype, mutable_};
@@ -487,7 +487,7 @@ void GlobalSection::writeBody() {
bool useExtendedConst = false;
uint32_t globalIdx;
int64_t offset;
- if (config->extendedConst && ctx.isPic) {
+ if (ctx.arg.extendedConst && ctx.isPic) {
if (auto *d = dyn_cast<DefinedData>(sym)) {
if (!sym->isTLS()) {
globalIdx = WasmSym::memoryBase->getGlobalIndex();
@@ -518,7 +518,7 @@ void GlobalSection::writeBody() {
// In the sharedMemory case TLS globals are set during
// `__wasm_apply_global_tls_relocs`, but in the non-shared case
// we know the absolute value at link time.
- initExpr = intConst(d->getVA(/*absolute=*/!config->sharedMemory), is64);
+ initExpr = intConst(d->getVA(/*absolute=*/!ctx.arg.sharedMemory), is64);
else if (auto *f = dyn_cast<FunctionSymbol>(sym))
initExpr = intConst(f->isStub ? 0 : f->getTableIndex(), is64);
else {
@@ -566,7 +566,7 @@ void ElemSection::addEntry(FunctionSymbol *sym) {
// They only exist so that the calls to missing functions can validate.
if (sym->hasTableIndex() || sym->isStub)
return;
- sym->setTableIndex(config->tableBase + indirectFunctions.size());
+ sym->setTableIndex(ctx.arg.tableBase + indirectFunctions.size());
indirectFunctions.emplace_back(sym);
}
@@ -589,8 +589,8 @@ void ElemSection::writeBody() {
initExpr.Inst.Opcode = WASM_OPCODE_GLOBAL_GET;
initExpr.Inst.Value.Global = WasmSym::tableBase->getGlobalIndex();
} else {
- bool is64 = config->is64.value_or(false);
- initExpr = intConst(config->tableBase, is64);
+ bool is64 = ctx.arg.is64.value_or(false);
+ initExpr = intConst(ctx.arg.tableBase, is64);
}
writeInitExpr(os, initExpr);
@@ -602,7 +602,7 @@ void ElemSection::writeBody() {
}
writeUleb128(os, indirectFunctions.size(), "elem count");
- uint32_t tableIndex = config->tableBase;
+ uint32_t tableIndex = ctx.arg.tableBase;
for (const FunctionSymbol *sym : indirectFunctions) {
assert(sym->getTableIndex() == tableIndex);
(void) tableIndex;
@@ -622,7 +622,7 @@ void DataCountSection::writeBody() {
}
bool DataCountSection::isNeeded() const {
- return numSegments && config->sharedMemory;
+ return numSegments && ctx.arg.sharedMemory;
}
void LinkingSection::writeBody() {
@@ -786,9 +786,9 @@ unsigned NameSection::numNamedDataSegments() const {
void NameSection::writeBody() {
{
SubSection sub(WASM_NAMES_MODULE);
- StringRef moduleName = config->soName;
- if (config->soName.empty())
- moduleName = llvm::sys::path::filename(config->outputFile);
+ StringRef moduleName = ctx.arg.soName;
+ if (ctx.arg.soName.empty())
+ moduleName = llvm::sys::path::filename(ctx.arg.outputFile);
writeStr(sub.os, moduleName, "module name");
sub.writeTo(bodyOutputStream);
}
@@ -917,14 +917,14 @@ void RelocSection::writeBody() {
}
static size_t getHashSize() {
- switch (config->buildId) {
+ switch (ctx.arg.buildId) {
case BuildIdKind::Fast:
case BuildIdKind::Uuid:
return 16;
case BuildIdKind::Sha1:
return 20;
case BuildIdKind::Hexstring:
- return config->buildIdVector.size();
+ return ctx.arg.buildIdVector.size();
case BuildIdKind::None:
return 0;
}