#include "ScriptParser.h"
#include "Config.h"
#include "Driver.h"
#include "InputFiles.h"
#include "LinkerScript.h"
#include "OutputSections.h"
#include "ScriptLexer.h"
#include "SymbolTable.h"
#include "Symbols.h"
#include "Target.h"
#include "lld/Common/CommonLinkerContext.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/BinaryFormat/ELF.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/SaveAndRestore.h"
#include "llvm/Support/TimeProfiler.h"
#include <cassert>
#include <limits>
#include <optional>
#include <vector>
usingnamespacellvm;
usingnamespacellvm::ELF;
usingnamespacellvm::support::endian;
usingnamespacelld;
usingnamespacelld::elf;
namespace {
class ScriptParser final : ScriptLexer { … };
}
static StringRef unquote(StringRef s) { … }
static void moveAbsRight(LinkerScript &s, ExprValue &a, ExprValue &b) { … }
static ExprValue add(LinkerScript &s, ExprValue a, ExprValue b) { … }
static ExprValue sub(ExprValue a, ExprValue b) { … }
static ExprValue bitAnd(LinkerScript &s, ExprValue a, ExprValue b) { … }
static ExprValue bitXor(LinkerScript &s, ExprValue a, ExprValue b) { … }
static ExprValue bitOr(LinkerScript &s, ExprValue a, ExprValue b) { … }
void ScriptParser::readDynamicList() { … }
void ScriptParser::readVersionScript() { … }
void ScriptParser::readVersionScriptCommand() { … }
void ScriptParser::readVersion() { … }
void ScriptParser::readLinkerScript() { … }
void ScriptParser::readDefsym() { … }
void ScriptParser::readNoCrossRefs(bool to) { … }
void ScriptParser::addFile(StringRef s) { … }
void ScriptParser::readAsNeeded() { … }
void ScriptParser::readEntry() { … }
void ScriptParser::readExtern() { … }
void ScriptParser::readGroup() { … }
void ScriptParser::readInclude() { … }
void ScriptParser::readInput() { … }
void ScriptParser::readOutput() { … }
void ScriptParser::readOutputArch() { … }
static std::pair<ELFKind, uint16_t> parseBfdName(StringRef s) { … }
void ScriptParser::readOutputFormat() { … }
void ScriptParser::readPhdrs() { … }
void ScriptParser::readRegionAlias() { … }
void ScriptParser::readSearchDir() { … }
SmallVector<SectionCommand *, 0> ScriptParser::readOverlay() { … }
SectionClassDesc *ScriptParser::readSectionClassDescription() { … }
StringRef ScriptParser::readSectionClassName() { … }
void ScriptParser::readOverwriteSections() { … }
void ScriptParser::readSections() { … }
void ScriptParser::readTarget() { … }
static int precedence(StringRef op) { … }
StringMatcher ScriptParser::readFilePatterns() { … }
SortSectionPolicy ScriptParser::peekSortKind() { … }
SortSectionPolicy ScriptParser::readSortKind() { … }
SmallVector<SectionPattern, 0> ScriptParser::readInputSectionsList() { … }
InputSectionDescription *
ScriptParser::readInputSectionRules(StringRef filePattern, uint64_t withFlags,
uint64_t withoutFlags) { … }
InputSectionDescription *
ScriptParser::readInputSectionDescription(StringRef tok) { … }
void ScriptParser::readSort() { … }
Expr ScriptParser::readAssert() { … }
#define ECase …
constexpr std::pair<const char *, unsigned> typeMap[] = …;
#undef ECase
bool ScriptParser::readSectionDirective(OutputSection *cmd, StringRef tok) { … }
void ScriptParser::readSectionAddressType(OutputSection *cmd) { … }
static Expr checkAlignment(Expr e, std::string &loc) { … }
OutputDesc *ScriptParser::readOverlaySectionDescription() { … }
OutputDesc *ScriptParser::readOutputSectionDescription(StringRef outSec) { … }
std::array<uint8_t, 4> ScriptParser::readFill() { … }
SymbolAssignment *ScriptParser::readProvideHidden(bool provide, bool hidden) { … }
static void squeezeSpaces(std::string &str) { … }
SymbolAssignment *ScriptParser::readAssignment(StringRef tok) { … }
StringRef ScriptParser::readName() { … }
SymbolAssignment *ScriptParser::readSymbolAssignment(StringRef name) { … }
Expr ScriptParser::readExpr() { … }
Expr ScriptParser::combine(StringRef op, Expr l, Expr r) { … }
Expr ScriptParser::readExpr1(Expr lhs, int minPrec) { … }
Expr ScriptParser::getPageSize() { … }
Expr ScriptParser::readConstant() { … }
static std::optional<uint64_t> parseInt(StringRef tok) { … }
ByteCommand *ScriptParser::readByteCommand(StringRef tok) { … }
static std::optional<uint64_t> parseFlag(StringRef tok) { … }
std::pair<uint64_t, uint64_t> ScriptParser::readInputSectionFlags() { … }
StringRef ScriptParser::readParenName() { … }
static void checkIfExists(LinkerScript &script, const OutputSection &osec,
StringRef location) { … }
static bool isValidSymbolName(StringRef s) { … }
Expr ScriptParser::readPrimary() { … }
Expr ScriptParser::readTernary(Expr cond) { … }
Expr ScriptParser::readParenExpr() { … }
SmallVector<StringRef, 0> ScriptParser::readOutputSectionPhdrs() { … }
unsigned ScriptParser::readPhdrType() { … }
void ScriptParser::readAnonymousDeclaration() { … }
void ScriptParser::readVersionDeclaration(StringRef verStr) { … }
bool elf::hasWildcard(StringRef s) { … }
std::pair<SmallVector<SymbolVersion, 0>, SmallVector<SymbolVersion, 0>>
ScriptParser::readSymbols() { … }
SmallVector<SymbolVersion, 0> ScriptParser::readVersionExtern() { … }
Expr ScriptParser::readMemoryAssignment(StringRef s1, StringRef s2,
StringRef s3) { … }
void ScriptParser::readMemory() { … }
void ScriptParser::readMemoryAttributes(uint32_t &flags, uint32_t &invFlags,
uint32_t &negFlags,
uint32_t &negInvFlags) { … }
void elf::readLinkerScript(Ctx &ctx, MemoryBufferRef mb) { … }
void elf::readVersionScript(Ctx &ctx, MemoryBufferRef mb) { … }
void elf::readDynamicList(Ctx &ctx, MemoryBufferRef mb) { … }
void elf::readDefsym(Ctx &ctx, MemoryBufferRef mb) { … }