Arch/ARM64Common.cpp
Arch/ARM64_32.cpp
Arch/X86_64.cpp
- UnwindInfoSection.cpp
+ ConcatOutputSection.cpp
Driver.cpp
DriverUtils.cpp
Dwarf.cpp
InputFiles.cpp
InputSection.cpp
LTO.cpp
- MergedOutputSection.cpp
+ MapFile.cpp
ObjC.cpp
OutputSection.cpp
OutputSegment.cpp
Symbols.cpp
SyntheticSections.cpp
Target.cpp
- MapFile.cpp
+ UnwindInfoSection.cpp
Writer.cpp
LINK_COMPONENTS
-//===- OutputSection.cpp --------------------------------------------------===//
+//===- ConcatOutputSection.cpp --------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
//
//===----------------------------------------------------------------------===//
-#include "MergedOutputSection.h"
+#include "ConcatOutputSection.h"
#include "Config.h"
#include "OutputSegment.h"
#include "SymbolTable.h"
using namespace lld;
using namespace lld::macho;
-void MergedOutputSection::mergeInput(InputSection *input) {
+void ConcatOutputSection::addInput(InputSection *input) {
if (inputs.empty()) {
align = input->align;
flags = input->flags;
// instructions, whereas CISC (i.e., x86) generally doesn't. RISC only needs
// thunks for programs so large that branch source & destination addresses
// might differ more than the range of branch instruction(s).
-bool MergedOutputSection::needsThunks() const {
+bool ConcatOutputSection::needsThunks() const {
if (!target->usesThunks())
return false;
uint64_t isecAddr = addr;
auto *sym = r.referent.get<Symbol *>();
// Pre-populate the thunkMap and memoize call site counts for every
// InputSection and ThunkInfo. We do this for the benefit of
- // MergedOutputSection::estimateStubsInRangeVA()
+ // ConcatOutputSection::estimateStubsInRangeVA()
ThunkInfo &thunkInfo = thunkMap[sym];
// Knowing ThunkInfo call site count will help us know whether or not we
// might need to create more for this referent at the time we are
// Since __stubs is placed after __text, we must estimate the address
// beyond which stubs are within range of a simple forward branch.
-uint64_t MergedOutputSection::estimateStubsInRangeVA(size_t callIdx) const {
+uint64_t ConcatOutputSection::estimateStubsInRangeVA(size_t callIdx) const {
uint64_t branchRange = target->branchRange;
size_t endIdx = inputs.size();
InputSection *isec = inputs[callIdx];
return stubsInRangeVA;
}
-void MergedOutputSection::finalize() {
+void ConcatOutputSection::finalize() {
uint64_t isecAddr = addr;
uint64_t isecFileOff = fileOff;
auto finalizeOne = [&](InputSection *isec) {
", thunks = " + std::to_string(thunkCount));
}
-void MergedOutputSection::writeTo(uint8_t *buf) const {
+void ConcatOutputSection::writeTo(uint8_t *buf) const {
// Merge input sections from thunk & ordinary vectors
size_t i = 0, ie = inputs.size();
size_t t = 0, te = thunks.size();
// TODO: this is most likely wrong; reconsider how section flags
// are actually merged. The logic presented here was written without
// any form of informed research.
-void MergedOutputSection::mergeFlags(InputSection *input) {
+void ConcatOutputSection::mergeFlags(InputSection *input) {
uint8_t baseType = flags & SECTION_TYPE;
uint8_t inputType = input->flags & SECTION_TYPE;
if (baseType != inputType)
-//===- OutputSection.h ------------------------------------------*- C++ -*-===//
+//===- ConcatOutputSection.h ------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// files that are labeled with the same segment and section name. This class
// contains all such sections and writes the data from each section sequentially
// in the final binary.
-class MergedOutputSection : public OutputSection {
+class ConcatOutputSection : public OutputSection {
public:
- MergedOutputSection(StringRef name) : OutputSection(MergedKind, name) {}
+ explicit ConcatOutputSection(StringRef name)
+ : OutputSection(ConcatKind, name) {}
const InputSection *firstSection() const { return inputs.front(); }
const InputSection *lastSection() const { return inputs.back(); }
uint64_t getSize() const override { return size; }
uint64_t getFileSize() const override { return fileSize; }
- void mergeInput(InputSection *input);
+ void addInput(InputSection *input);
void finalize() override;
bool needsThunks() const;
uint64_t estimateStubsInRangeVA(size_t callIdx) const;
std::vector<InputSection *> thunks;
static bool classof(const OutputSection *sec) {
- return sec->kind() == MergedKind;
+ return sec->kind() == ConcatKind;
}
private:
class OutputSection {
public:
enum Kind {
- MergedKind,
+ ConcatKind,
SyntheticKind,
};
//===----------------------------------------------------------------------===//
#include "OutputSegment.h"
+#include "ConcatOutputSection.h"
#include "InputSection.h"
-#include "MergedOutputSection.h"
#include "SyntheticSections.h"
#include "lld/Common/ErrorHandler.h"
// the address of a function that has not yet been finalized.
assert(target->usesThunks());
- // MergedOutputSection::finalize() can seek the address of a
+ // ConcatOutputSection::finalize() can seek the address of a
// function before its address is assigned. The thunking algorithm
// knows that unfinalized functions will be out of range, so it is
// expedient to return a contrived out-of-range address.
//===----------------------------------------------------------------------===//
#include "SyntheticSections.h"
+#include "ConcatOutputSection.h"
#include "Config.h"
#include "ExportTrie.h"
#include "InputFiles.h"
#include "MachOStructs.h"
-#include "MergedOutputSection.h"
#include "OutputSegment.h"
#include "SymbolTable.h"
#include "Symbols.h"
// have a corresponding entry in the LazyPointerSection.
bool addEntry(Symbol *);
uint64_t getVA(uint32_t stubsIndex) const {
- // MergedOutputSection::finalize() can seek the address of a
+ // ConcatOutputSection::finalize() can seek the address of a
// stub before its address is assigned. Before __stubs is
// finalized, return a contrived out-of-range address.
return isFinal ? addr + stubsIndex * target->stubSize
//===----------------------------------------------------------------------===//
#include "UnwindInfoSection.h"
+#include "ConcatOutputSection.h"
#include "Config.h"
#include "InputSection.h"
-#include "MergedOutputSection.h"
#include "OutputSection.h"
#include "OutputSegment.h"
#include "SymbolTable.h"
// is no source address to make a relative location meaningful.
template <class Ptr>
static void
-relocateCompactUnwind(MergedOutputSection *compactUnwindSection,
+relocateCompactUnwind(ConcatOutputSection *compactUnwindSection,
std::vector<CompactUnwindEntry<Ptr>> &cuVector) {
for (const InputSection *isec : compactUnwindSection->inputs) {
assert(isec->parent == compactUnwindSection);
#ifndef LLD_MACHO_UNWIND_INFO_H
#define LLD_MACHO_UNWIND_INFO_H
-#include "MergedOutputSection.h"
+#include "ConcatOutputSection.h"
#include "SyntheticSections.h"
#include "mach-o/compact_unwind_encoding.h"
uint64_t getSize() const override { return unwindInfoSize; }
virtual void prepareRelocations(InputSection *) = 0;
- void setCompactUnwindSection(MergedOutputSection *cuSection) {
+ void setCompactUnwindSection(ConcatOutputSection *cuSection) {
compactUnwindSection = cuSection;
}
align = 4;
}
- MergedOutputSection *compactUnwindSection = nullptr;
+ ConcatOutputSection *compactUnwindSection = nullptr;
uint64_t unwindInfoSize = 0;
};
//===----------------------------------------------------------------------===//
#include "Writer.h"
+#include "ConcatOutputSection.h"
#include "Config.h"
#include "InputFiles.h"
#include "InputSection.h"
#include "MapFile.h"
-#include "MergedOutputSection.h"
#include "OutputSection.h"
#include "OutputSegment.h"
#include "SymbolTable.h"
firstTLVDataSection = osec;
if (!isecPriorities.empty()) {
- if (auto *merged = dyn_cast<MergedOutputSection>(osec)) {
+ if (auto *merged = dyn_cast<ConcatOutputSection>(osec)) {
llvm::stable_sort(merged->inputs,
[&](InputSection *a, InputSection *b) {
return isecPriorities[a] > isecPriorities[b];
llvm_unreachable("unhandled output file type");
}
- // Then merge input sections into output sections.
- MapVector<NamePair, MergedOutputSection *> mergedOutputSections;
+ // Then add input sections to output sections.
+ MapVector<NamePair, ConcatOutputSection *> concatOutputSections;
for (InputSection *isec : inputSections) {
if (isec->shouldOmitFromOutput())
continue;
NamePair names = maybeRenameSection({isec->segname, isec->name});
- MergedOutputSection *&osec = mergedOutputSections[names];
+ ConcatOutputSection *&osec = concatOutputSections[names];
if (osec == nullptr)
- osec = make<MergedOutputSection>(names.second);
- osec->mergeInput(isec);
+ osec = make<ConcatOutputSection>(names.second);
+ osec->addInput(isec);
}
- for (const auto &it : mergedOutputSections) {
+ for (const auto &it : concatOutputSections) {
StringRef segname = it.first.first;
- MergedOutputSection *osec = it.second;
+ ConcatOutputSection *osec = it.second;
if (segname == segment_names::ld) {
assert(osec->name == section_names::compactUnwind);
in.unwindInfo->setCompactUnwindSection(osec);
}
for (SyntheticSection *ssec : syntheticSections) {
- auto it = mergedOutputSections.find({ssec->segname, ssec->name});
- if (it == mergedOutputSections.end()) {
+ auto it = concatOutputSections.find({ssec->segname, ssec->name});
+ if (it == concatOutputSections.end()) {
if (ssec->isNeeded())
getOrCreateOutputSegment(ssec->segname)->addOutputSection(ssec);
} else {