#include "LinkerScript.h"
#include "Config.h"
#include "InputFiles.h"
#include "InputSection.h"
#include "OutputSections.h"
#include "SymbolTable.h"
#include "Symbols.h"
#include "SyntheticSections.h"
#include "Target.h"
#include "Writer.h"
#include "lld/Common/CommonLinkerContext.h"
#include "lld/Common/Strings.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/BinaryFormat/ELF.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Endian.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/TimeProfiler.h"
#include <algorithm>
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <limits>
#include <string>
#include <vector>
usingnamespacellvm;
usingnamespacellvm::ELF;
usingnamespacellvm::object;
usingnamespacellvm::support::endian;
usingnamespacelld;
usingnamespacelld::elf;
static bool isSectionPrefix(StringRef prefix, StringRef name) { … }
StringRef LinkerScript::getOutputSectionName(const InputSectionBase *s) const { … }
uint64_t ExprValue::getValue() const { … }
uint64_t ExprValue::getSecAddr() const { … }
uint64_t ExprValue::getSectionOffset() const { … }
OutputDesc *LinkerScript::createOutputSection(StringRef name,
StringRef location) { … }
OutputDesc *LinkerScript::getOrCreateOutputSection(StringRef name) { … }
static void expandMemoryRegion(MemoryRegion *memRegion, uint64_t size,
StringRef secName) { … }
void LinkerScript::expandMemoryRegions(uint64_t size) { … }
void LinkerScript::expandOutputSection(uint64_t size) { … }
void LinkerScript::setDot(Expr e, const Twine &loc, bool inSec) { … }
static bool shouldDefineSym(SymbolAssignment *cmd) { … }
void LinkerScript::addSymbol(SymbolAssignment *cmd) { … }
static void declareSymbol(SymbolAssignment *cmd) { … }
SymbolAssignmentMap;
static SymbolAssignmentMap
getSymbolAssignmentValues(ArrayRef<SectionCommand *> sectionCommands) { … }
static const Defined *
getChangedSymbolAssignment(const SymbolAssignmentMap &oldValues) { … }
void LinkerScript::processInsertCommands() { … }
void LinkerScript::declareSymbols() { … }
void LinkerScript::assignSymbol(SymbolAssignment *cmd, bool inSec) { … }
static inline StringRef getFilename(const InputFile *file) { … }
bool InputSectionDescription::matchesFile(const InputFile *file) const { … }
bool SectionPattern::excludesFile(const InputFile *file) const { … }
bool LinkerScript::shouldKeep(InputSectionBase *s) { … }
static bool matchConstraints(ArrayRef<InputSectionBase *> sections,
ConstraintKind kind) { … }
static void sortSections(MutableArrayRef<InputSectionBase *> vec,
SortSectionPolicy k) { … }
static void sortInputSections(MutableArrayRef<InputSectionBase *> vec,
SortSectionPolicy outer,
SortSectionPolicy inner) { … }
SmallVector<InputSectionBase *, 0>
LinkerScript::computeInputSections(const InputSectionDescription *cmd,
ArrayRef<InputSectionBase *> sections,
const SectionBase &outCmd) { … }
void LinkerScript::discard(InputSectionBase &s) { … }
void LinkerScript::discardSynthetic(OutputSection &outCmd) { … }
SmallVector<InputSectionBase *, 0>
LinkerScript::createInputSectionList(OutputSection &outCmd) { … }
void LinkerScript::processSectionCommands() { … }
void LinkerScript::processSymbolAssignments() { … }
static OutputSection *findByName(ArrayRef<SectionCommand *> vec,
StringRef name) { … }
static OutputDesc *createSection(InputSectionBase *isec, StringRef outsecName) { … }
static OutputDesc *addInputSec(StringMap<TinyPtrVector<OutputSection *>> &map,
InputSectionBase *isec, StringRef outsecName) { … }
void LinkerScript::addOrphanSections() { … }
void LinkerScript::diagnoseOrphanHandling() const { … }
void LinkerScript::diagnoseMissingSGSectionAddress() const { … }
std::pair<MemoryRegion *, MemoryRegion *>
LinkerScript::findMemoryRegion(OutputSection *sec, MemoryRegion *hint) { … }
static OutputSection *findFirstSection(PhdrEntry *load) { … }
bool LinkerScript::assignOffsets(OutputSection *sec) { … }
static bool isDiscardable(const OutputSection &sec) { … }
static void maybePropagatePhdrs(OutputSection &sec,
SmallVector<StringRef, 0> &phdrs) { … }
void LinkerScript::adjustOutputSections() { … }
void LinkerScript::adjustSectionsAfterSorting() { … }
void LinkerScript::allocateHeaders(SmallVector<PhdrEntry *, 0> &phdrs) { … }
LinkerScript::AddressState::AddressState(const LinkerScript &script) { … }
std::pair<const OutputSection *, const Defined *>
LinkerScript::assignAddresses() { … }
static bool hasRegionOverflowed(MemoryRegion *mr) { … }
bool LinkerScript::spillSections() { … }
void LinkerScript::erasePotentialSpillSections() { … }
SmallVector<PhdrEntry *, 0> LinkerScript::createPhdrs() { … }
bool LinkerScript::needsInterpSection() { … }
ExprValue LinkerScript::getSymbolValue(StringRef name, const Twine &loc) { … }
static std::optional<size_t> getPhdrIndex(ArrayRef<PhdrsCommand> vec,
StringRef name) { … }
SmallVector<size_t, 0> LinkerScript::getPhdrIndices(OutputSection *cmd) { … }
void LinkerScript::printMemoryUsage(raw_ostream& os) { … }
void LinkerScript::recordError(const Twine &msg) { … }
static void checkMemoryRegion(const MemoryRegion *region,
const OutputSection *osec, uint64_t addr) { … }
void LinkerScript::checkFinalScriptConditions() const { … }
void LinkerScript::addScriptReferencedSymbolsToSymTable() { … }
bool LinkerScript::shouldAddProvideSym(StringRef symName) { … }