llvm/lld/wasm/InputFiles.cpp

//===- InputFiles.cpp -----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "InputFiles.h"
#include "Config.h"
#include "InputChunks.h"
#include "InputElement.h"
#include "OutputSegment.h"
#include "SymbolTable.h"
#include "lld/Common/Args.h"
#include "lld/Common/CommonLinkerContext.h"
#include "lld/Common/Reproduce.h"
#include "llvm/BinaryFormat/Wasm.h"
#include "llvm/Object/Binary.h"
#include "llvm/Object/Wasm.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/TarWriter.h"
#include "llvm/Support/raw_ostream.h"
#include <optional>

#define DEBUG_TYPE

usingnamespacellvm;
usingnamespacellvm::object;
usingnamespacellvm::wasm;
usingnamespacellvm::sys;

namespace lld {

// Returns a string in the format of "foo.o" or "foo.a(bar.o)".
std::string toString(const wasm::InputFile *file) {}

namespace wasm {

void InputFile::checkArch(Triple::ArchType arch) const {}

std::unique_ptr<llvm::TarWriter> tar;

std::optional<MemoryBufferRef> readFile(StringRef path) {}

InputFile *createObjectFile(MemoryBufferRef mb, StringRef archiveName,
                            uint64_t offsetInArchive, bool lazy) {}

// Relocations contain either symbol or type indices.  This function takes a
// relocation and returns relocated index (i.e. translates from the input
// symbol/type space to the output symbol/type space).
uint32_t ObjFile::calcNewIndex(const WasmRelocation &reloc) const {}

// Relocations can contain addend for combined sections. This function takes a
// relocation and returns updated addend by offset in the output section.
int64_t ObjFile::calcNewAddend(const WasmRelocation &reloc) const {}

// Translate from the relocation's index into the final linked output value.
uint64_t ObjFile::calcNewValue(const WasmRelocation &reloc, uint64_t tombstone,
                               const InputChunk *chunk) const {}

template <class T>
static void setRelocs(const std::vector<T *> &chunks,
                      const WasmSection *section) {}

// An object file can have two approaches to tables.  With the reference-types
// feature enabled, input files that define or use tables declare the tables
// using symbols, and record each use with a relocation.  This way when the
// linker combines inputs, it can collate the tables used by the inputs,
// assigning them distinct table numbers, and renumber all the uses as
// appropriate.  At the same time, the linker has special logic to build the
// indirect function table if it is needed.
//
// However, MVP object files (those that target WebAssembly 1.0, the "minimum
// viable product" version of WebAssembly) neither write table symbols nor
// record relocations.  These files can have at most one table, the indirect
// function table used by call_indirect and which is the address space for
// function pointers.  If this table is present, it is always an import.  If we
// have a file with a table import but no table symbols, it is an MVP object
// file.  synthesizeMVPIndirectFunctionTableSymbolIfNeeded serves as a shim when
// loading these input files, defining the missing symbol to allow the indirect
// function table to be built.
//
// As indirect function table table usage in MVP objects cannot be relocated,
// the linker must ensure that this table gets assigned index zero.
void ObjFile::addLegacyIndirectFunctionTableIfNeeded(
    uint32_t tableSymbolCount) {}

static bool shouldMerge(const WasmSection &sec) {}

static bool shouldMerge(const WasmSegment &seg) {}

void ObjFile::parseLazy() {}

ObjFile::ObjFile(MemoryBufferRef m, StringRef archiveName, bool lazy)
    :{}

void SharedFile::parse() {}

WasmFileBase::WasmFileBase(Kind k, MemoryBufferRef m) :{}

void ObjFile::parse(bool ignoreComdats) {}

bool ObjFile::isExcludedByComdat(const InputChunk *chunk) const {}

FunctionSymbol *ObjFile::getFunctionSymbol(uint32_t index) const {}

GlobalSymbol *ObjFile::getGlobalSymbol(uint32_t index) const {}

TagSymbol *ObjFile::getTagSymbol(uint32_t index) const {}

TableSymbol *ObjFile::getTableSymbol(uint32_t index) const {}

SectionSymbol *ObjFile::getSectionSymbol(uint32_t index) const {}

DataSymbol *ObjFile::getDataSymbol(uint32_t index) const {}

Symbol *ObjFile::createDefined(const WasmSymbol &sym) {}

Symbol *ObjFile::createUndefined(const WasmSymbol &sym, bool isCalledDirectly) {}

static StringRef strip(StringRef s) {}

void StubFile::parse() {}

static uint8_t mapVisibility(GlobalValue::VisibilityTypes gvVisibility) {}

static Symbol *createBitcodeSymbol(const std::vector<bool> &keptComdats,
                                   const lto::InputFile::Symbol &objSym,
                                   BitcodeFile &f) {}

BitcodeFile::BitcodeFile(MemoryBufferRef m, StringRef archiveName,
                         uint64_t offsetInArchive, bool lazy)
    :{}

bool BitcodeFile::doneLTO =;

void BitcodeFile::parseLazy() {}

void BitcodeFile::parse(StringRef symName) {}

} // namespace wasm
} // namespace lld