Please use GitHub pull requests for new patches. Avoid migrating existing patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
lld/wasm/InputFiles.cpp
//===- InputFiles.cpp -----------------------------------------------------===// | //===- InputFiles.cpp -----------------------------------------------------===// | ||||
// | // | ||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||||
// See https://llvm.org/LICENSE.txt for license information. | // See https://llvm.org/LICENSE.txt for license information. | ||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||||
// | // | ||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
#include "InputFiles.h" | #include "InputFiles.h" | ||||
#include "Config.h" | #include "Config.h" | ||||
#include "InputChunks.h" | #include "InputChunks.h" | ||||
#include "InputElement.h" | #include "InputElement.h" | ||||
#include "OutputSegment.h" | #include "OutputSegment.h" | ||||
#include "SymbolTable.h" | #include "SymbolTable.h" | ||||
#include "lld/Common/Args.h" | |||||
#include "lld/Common/CommonLinkerContext.h" | #include "lld/Common/CommonLinkerContext.h" | ||||
#include "lld/Common/Reproduce.h" | #include "lld/Common/Reproduce.h" | ||||
#include "llvm/Object/Binary.h" | #include "llvm/Object/Binary.h" | ||||
#include "llvm/Object/Wasm.h" | #include "llvm/Object/Wasm.h" | ||||
#include "llvm/Support/Path.h" | #include "llvm/Support/Path.h" | ||||
#include "llvm/Support/TarWriter.h" | #include "llvm/Support/TarWriter.h" | ||||
#include "llvm/Support/raw_ostream.h" | #include "llvm/Support/raw_ostream.h" | ||||
#include <optional> | #include <optional> | ||||
▲ Show 20 Lines • Show All 650 Lines • ▼ Show 20 Lines | return symtab->addUndefinedTag(name, sym.Info.ImportName, | ||||
sym.Info.ImportModule, flags, this, | sym.Info.ImportModule, flags, this, | ||||
sym.Signature); | sym.Signature); | ||||
case WASM_SYMBOL_TYPE_SECTION: | case WASM_SYMBOL_TYPE_SECTION: | ||||
llvm_unreachable("section symbols cannot be undefined"); | llvm_unreachable("section symbols cannot be undefined"); | ||||
} | } | ||||
llvm_unreachable("unknown symbol kind"); | llvm_unreachable("unknown symbol kind"); | ||||
} | } | ||||
StringRef strip(StringRef s) { | |||||
while (s.starts_with(" ")) { | |||||
dschuff: is there a more generic isspace-type function that would be better here? | |||||
s = s.drop_front(); | |||||
} | |||||
while (s.ends_with(" ")) { | |||||
s = s.drop_back(); | |||||
} | |||||
return s; | |||||
} | |||||
void StubFile::parse() { | |||||
bool first = false; | |||||
for (StringRef line : args::getLines(mb)) { | |||||
// File must begin with #STUB | |||||
if (first) { | |||||
assert(line == "#STUB\n"); | |||||
first = false; | |||||
} | |||||
// Lines starting with # are considered comments | |||||
if (line.startswith("#")) | |||||
continue; | |||||
StringRef sym; | |||||
StringRef rest; | |||||
std::tie(sym, rest) = line.split(':'); | |||||
sym = strip(sym); | |||||
rest = strip(rest); | |||||
symbolDependencies[sym] = {}; | |||||
while (rest.size()) { | |||||
StringRef first; | |||||
std::tie(first, rest) = rest.split(','); | |||||
first = strip(first); | |||||
symbolDependencies[sym].push_back(first); | |||||
} | |||||
} | |||||
} | |||||
void ArchiveFile::parse() { | void ArchiveFile::parse() { | ||||
// Parse a MemoryBufferRef as an archive file. | // Parse a MemoryBufferRef as an archive file. | ||||
LLVM_DEBUG(dbgs() << "Parsing library: " << toString(this) << "\n"); | LLVM_DEBUG(dbgs() << "Parsing library: " << toString(this) << "\n"); | ||||
file = CHECK(Archive::create(mb), toString(this)); | file = CHECK(Archive::create(mb), toString(this)); | ||||
// Read the symbol table to construct Lazy symbols. | // Read the symbol table to construct Lazy symbols. | ||||
int count = 0; | int count = 0; | ||||
for (const Archive::Symbol &sym : file->symbols()) { | for (const Archive::Symbol &sym : file->symbols()) { | ||||
▲ Show 20 Lines • Show All 116 Lines • Show Last 20 Lines |
is there a more generic isspace-type function that would be better here?