}
std::error_code AArch64TargetRelocationHandler::applyRelocation(
- ELFWriter &writer, llvm::FileOutputBuffer &buf, const lld::AtomLayout &atom,
+ ELFWriter &writer, llvm::FileOutputBuffer &buf, const AtomLayout &atom,
const Reference &ref) const {
uint8_t *atomContent = buf.getBufferStart() + atom._fileOffset;
uint8_t *loc = atomContent + ref.offsetInAtom();
class AArch64TargetRelocationHandler final : public TargetRelocationHandler {
public:
std::error_code applyRelocation(ELFWriter &, llvm::FileOutputBuffer &,
- const lld::AtomLayout &,
+ const AtomLayout &,
const Reference &) const override;
};
}
std::error_code ARMTargetRelocationHandler::applyRelocation(
- ELFWriter &writer, llvm::FileOutputBuffer &buf, const lld::AtomLayout &atom,
+ ELFWriter &writer, llvm::FileOutputBuffer &buf, const AtomLayout &atom,
const Reference &ref) const {
uint8_t *atomContent = buf.getBufferStart() + atom._fileOffset;
uint8_t *loc = atomContent + ref.offsetInAtom();
ARMTargetRelocationHandler(ARMTargetLayout &layout) : _armLayout(layout) {}
std::error_code applyRelocation(ELFWriter &, llvm::FileOutputBuffer &,
- const lld::AtomLayout &,
+ const AtomLayout &,
const Reference &) const override;
private:
/// \brief ELFUndefinedAtom: These atoms store undefined symbols and are place
/// holders that will be replaced by defined atoms later in the linking process.
-template <class ELFT> class ELFUndefinedAtom : public lld::UndefinedAtom {
+template <class ELFT> class ELFUndefinedAtom : public UndefinedAtom {
typedef llvm::object::Elf_Sym_Impl<ELFT> Elf_Sym;
public:
template <typename ELFT>
std::error_code DynamicFile<ELFT>::isCompatible(const MemoryBuffer &mb,
ELFLinkingContext &ctx) {
- return lld::elf::isCompatible<ELFT>(mb, ctx);
+ return elf::isCompatible<ELFT>(mb, ctx);
}
template <class ELFT>
template <class ELFT>
void DynamicLibraryWriter<ELFT>::finalizeDefaultAtomValues() {
OutputELFWriter<ELFT>::finalizeDefaultAtomValues();
- lld::AtomLayout *underScoreEndAtom = this->_layout.findAbsoluteAtom("_end");
+ AtomLayout *underScoreEndAtom = this->_layout.findAbsoluteAtom("_end");
assert(underScoreEndAtom);
if (auto bssSection = this->_layout.findOutputSection(".bss")) {
template <typename ELFT>
std::error_code ELFFile<ELFT>::isCompatible(const MemoryBuffer &mb,
ELFLinkingContext &ctx) {
- return lld::elf::isCompatible<ELFT>(mb, ctx);
+ return elf::isCompatible<ELFT>(mb, ctx);
}
template <typename ELFT>
followOn = anonFollowedBy;
} else {
followOn = new (_readerStorage)
- ELFReference<ELFT>(lld::Reference::kindLayoutAfter);
+ ELFReference<ELFT>(Reference::kindLayoutAfter);
previousAtom->addReference(followOn);
}
}
// If this is the last atom, let's not create a followon reference.
if (anonAtom && (si + 1) != se) {
anonFollowedBy = new (_readerStorage)
- ELFReference<ELFT>(lld::Reference::kindLayoutAfter);
+ ELFReference<ELFT>(Reference::kindLayoutAfter);
anonAtom->addReference(anonFollowedBy);
}
}
for (auto ha : atomsForSection[*sectionName]) {
_groupChild[ha->symbol()] = std::make_pair(*sectionName, section);
ELFReference<ELFT> *ref =
- new (_readerStorage) ELFReference<ELFT>(lld::Reference::kindGroupChild);
+ new (_readerStorage) ELFReference<ELFT>(Reference::kindGroupChild);
ref->setTarget(ha);
refs.push_back(ref);
}
for (auto name : sectionNames) {
for (auto ha : atomsForSection[name]) {
_groupChild[ha->symbol()] = std::make_pair(*symbolName, section);
- ELFReference<ELFT> *ref = new (_readerStorage)
- ELFReference<ELFT>(lld::Reference::kindGroupChild);
+ ELFReference<ELFT> *ref =
+ new (_readerStorage) ELFReference<ELFT>(Reference::kindGroupChild);
ref->setTarget(ha);
refs.push_back(ref);
}
template <class ELFT> void ELFFile<ELFT>::updateReferences() {
for (auto &ri : _references) {
- if (ri->kindNamespace() != lld::Reference::KindNamespace::ELF)
+ if (ri->kindNamespace() != Reference::KindNamespace::ELF)
continue;
const Elf_Sym *symbol = _objFile->getSymbol(ri->targetSymbolIndex());
const Elf_Shdr *shdr = _objFile->getSection(symbol);
namespace lld {
namespace elf {
-std::unique_ptr<lld::ELFLinkingContext>
+std::unique_ptr<ELFLinkingContext>
createHexagonLinkingContext(llvm::Triple triple) {
if (triple.getArch() == llvm::Triple::hexagon)
return llvm::make_unique<HexagonLinkingContext>(triple);
}
std::error_code HexagonTargetRelocationHandler::applyRelocation(
- ELFWriter &writer, llvm::FileOutputBuffer &buf, const lld::AtomLayout &atom,
+ ELFWriter &writer, llvm::FileOutputBuffer &buf, const AtomLayout &atom,
const Reference &ref) const {
uint8_t *atomContent = buf.getBufferStart() + atom._fileOffset;
uint8_t *loc = atomContent + ref.offsetInAtom();
: _targetLayout(layout) {}
std::error_code applyRelocation(ELFWriter &, llvm::FileOutputBuffer &,
- const lld::AtomLayout &,
+ const AtomLayout &,
const Reference &) const override;
private:
void SDataSection::doPreFlight() {
// sort the atoms on the alignments they have been set
- std::stable_sort(_atoms.begin(), _atoms.end(), [](const lld::AtomLayout *A,
- const lld::AtomLayout *B) {
+ std::stable_sort(_atoms.begin(), _atoms.end(), [](const AtomLayout *A,
+ const AtomLayout *B) {
const DefinedAtom *definedAtomA = cast<DefinedAtom>(A->_atom);
const DefinedAtom *definedAtomB = cast<DefinedAtom>(B->_atom);
int64_t alignmentA = definedAtomA->alignment().value;
const DefinedAtom *definedAtom = cast<DefinedAtom>(atom);
DefinedAtom::Alignment atomAlign = definedAtom->alignment();
uint64_t alignment = atomAlign.value;
- _atoms.push_back(new (_alloc) lld::AtomLayout(atom, 0, 0));
+ _atoms.push_back(new (_alloc) AtomLayout(atom, 0, 0));
// Set the section alignment to the largest alignment
// std::max doesn't support uint64_t
if (_alignment < alignment)
/// \brief Does this section have an output segment.
bool hasOutputSegment() const override { return true; }
- const lld::AtomLayout *appendAtom(const Atom *atom) override;
+ const AtomLayout *appendAtom(const Atom *atom) override;
};
/// \brief TargetLayout for Hexagon
std::error_code applyRelocation(ELFWriter &writer,
llvm::FileOutputBuffer &buf,
- const lld::AtomLayout &atom,
+ const AtomLayout &atom,
const Reference &ref) const override;
private:
template <class ELFT>
std::error_code RelocationHandler<ELFT>::applyRelocation(
- ELFWriter &writer, llvm::FileOutputBuffer &buf, const lld::AtomLayout &atom,
+ ELFWriter &writer, llvm::FileOutputBuffer &buf, const AtomLayout &atom,
const Reference &ref) const {
- if (ref.kindNamespace() != lld::Reference::KindNamespace::ELF)
+ if (ref.kindNamespace() != Reference::KindNamespace::ELF)
return std::error_code();
assert(ref.kindArch() == Reference::KindArch::Mips);
Reference &ref) {
if (!ref.target())
return;
- if (ref.kindNamespace() != lld::Reference::KindNamespace::ELF)
+ if (ref.kindNamespace() != Reference::KindNamespace::ELF)
return;
assert(ref.kindArch() == Reference::KindArch::Mips);
switch (ref.kindValue()) {
const MipsELFDefinedAtom<ELFT> &atom, Reference &ref) {
if (!ref.target())
return;
- if (ref.kindNamespace() != lld::Reference::KindNamespace::ELF)
+ if (ref.kindNamespace() != Reference::KindNamespace::ELF)
return;
auto refKind = ref.kindValue();
return ia == _posMap.end() && ib != _posMap.end();
}
- const lld::AtomLayout *appendAtom(const Atom *atom) override {
+ const AtomLayout *appendAtom(const Atom *atom) override {
const DefinedAtom *da = dyn_cast<DefinedAtom>(atom);
for (const auto &r : *da) {
- if (r->kindNamespace() != lld::Reference::KindNamespace::ELF)
+ if (r->kindNamespace() != Reference::KindNamespace::ELF)
continue;
assert(r->kindArch() == Reference::KindArch::Mips);
switch (r->kindValue()) {
return it != _pltLayoutMap.end() ? it->second : nullptr;
}
- const lld::AtomLayout *appendAtom(const Atom *atom) override {
+ const AtomLayout *appendAtom(const Atom *atom) override {
const auto *layout = AtomSection<ELFT>::appendAtom(atom);
const DefinedAtom *da = cast<DefinedAtom>(atom);
for (const auto &r : *da) {
- if (r->kindNamespace() != lld::Reference::KindNamespace::ELF)
+ if (r->kindNamespace() != Reference::KindNamespace::ELF)
continue;
assert(r->kindArch() == Reference::KindArch::Mips);
if (r->kindValue() == LLD_R_MIPS_STO_PLT) {
// contains the atom, the atom file offset, the atom virtual address
// the atom file offset is aligned appropriately as set by the Reader
template <class ELFT>
-const lld::AtomLayout *AtomSection<ELFT>::appendAtom(const Atom *atom) {
+const AtomLayout *AtomSection<ELFT>::appendAtom(const Atom *atom) {
const DefinedAtom *definedAtom = cast<DefinedAtom>(atom);
DefinedAtom::Alignment atomAlign = definedAtom->alignment();
case DefinedAtom::typeThreadData:
case DefinedAtom::typeRONote:
case DefinedAtom::typeRWNote:
- _atoms.push_back(new (_alloc) lld::AtomLayout(atom, fOffset, 0));
+ _atoms.push_back(new (_alloc) AtomLayout(atom, fOffset, 0));
this->_fsize = fOffset + definedAtom->size();
this->_msize = mOffset + definedAtom->size();
DEBUG_WITH_TYPE("Section", llvm::dbgs()
<< fOffset << "\n");
break;
case DefinedAtom::typeNoAlloc:
- _atoms.push_back(new (_alloc) lld::AtomLayout(atom, fOffset, 0));
+ _atoms.push_back(new (_alloc) AtomLayout(atom, fOffset, 0));
this->_fsize = fOffset + definedAtom->size();
DEBUG_WITH_TYPE("Section", llvm::dbgs()
<< "[" << this->name() << " " << this << "] "
break;
case DefinedAtom::typeThreadZeroFill:
case DefinedAtom::typeZeroFill:
- _atoms.push_back(new (_alloc) lld::AtomLayout(atom, mOffset, 0));
+ _atoms.push_back(new (_alloc) AtomLayout(atom, mOffset, 0));
this->_msize = mOffset + definedAtom->size();
break;
default:
llvm::FileOutputBuffer &buffer) {
uint8_t *chunkBuffer = buffer.getBufferStart();
bool success = true;
- parallel_for_each(_atoms.begin(), _atoms.end(), [&](lld::AtomLayout *ai) {
+ parallel_for_each(_atoms.begin(), _atoms.end(), [&](AtomLayout *ai) {
DEBUG_WITH_TYPE("Section", llvm::dbgs()
<< "Writing atom: " << ai->_atom->name()
<< " | " << ai->_fileOffset << "\n");
/// information
template <class ELFT>
void SymbolTable<ELFT>::addSymbol(const Atom *atom, int32_t sectionIndex,
- uint64_t addr,
- const lld::AtomLayout *atomLayout) {
+ uint64_t addr, const AtomLayout *atomLayout) {
Elf_Sym symbol;
if (atom->name().empty())
// don't have their addresses known until addresses have been assigned
// so let's update the symbol values after they have got assigned
for (auto &ste : this->_symbolTable) {
- const lld::AtomLayout *atomLayout = ste._atomLayout;
+ const AtomLayout *atomLayout = ste._atomLayout;
if (!atomLayout)
continue;
ste._symbol.st_value = atomLayout->_virtualAddr;
// \brief Append an atom to a Section. The atom gets pushed into a vector
// contains the atom, the atom file offset, the atom virtual address
// the atom file offset is aligned appropriately as set by the Reader
- virtual const lld::AtomLayout *appendAtom(const Atom *atom);
+ virtual const AtomLayout *appendAtom(const Atom *atom);
/// \brief Set the virtual address of each Atom in the Section. This
/// routine gets called after the linker fixes up the virtual address
int64_t atomflags() const { return _contentPermissions; }
/// Atom Iterators
- typedef typename std::vector<lld::AtomLayout *>::iterator atom_iter;
+ typedef typename std::vector<AtomLayout *>::iterator atom_iter;
range<atom_iter> atoms() { return _atoms; }
int32_t _contentType;
int32_t _contentPermissions;
bool _isLoadedInMemory = true;
- std::vector<lld::AtomLayout *> _atoms;
+ std::vector<AtomLayout *> _atoms;
mutable std::mutex _outputMutex;
void printError(const std::string &errorStr, const AtomLayout &atom,
std::size_t size() const { return _symbolTable.size(); }
void addSymbol(const Atom *atom, int32_t sectionIndex, uint64_t addr = 0,
- const lld::AtomLayout *layout = nullptr);
+ const AtomLayout *layout = nullptr);
/// \brief Get the symbol table index for an Atom. If it's not in the symbol
/// table, return STN_UNDEF.
protected:
struct SymbolEntry {
- SymbolEntry(const Atom *a, const Elf_Sym &sym,
- const lld::AtomLayout *layout)
+ SymbolEntry(const Atom *a, const Elf_Sym &sym, const AtomLayout *layout)
: _atom(a), _atomLayout(layout), _symbol(sym) {}
const Atom *_atom;
- const lld::AtomLayout *_atomLayout;
+ const AtomLayout *_atomLayout;
Elf_Sym _symbol;
};
}
template <class ELFT>
-ErrorOr<const lld::AtomLayout *> TargetLayout<ELFT>::addAtom(const Atom *atom) {
+ErrorOr<const AtomLayout *> TargetLayout<ELFT>::addAtom(const Atom *atom) {
if (const DefinedAtom *definedAtom = dyn_cast<DefinedAtom>(atom)) {
// HACK: Ignore undefined atoms. We need to adjust the interface so that
// undefined atoms can still be included in the output symbol table for
// Absolute atoms are not part of any section, they are global for the whole
// link
_absoluteAtoms.push_back(
- new (_allocator) lld::AtomLayout(absoluteAtom, 0, absoluteAtom->value()));
+ new (_allocator) AtomLayout(absoluteAtom, 0, absoluteAtom->value()));
return _absoluteAtoms.back();
}
typedef std::unordered_map<SegmentKey, Segment<ELFT> *, SegmentHashKey>
SegmentMapT;
- typedef typename std::vector<lld::AtomLayout *>::iterator AbsoluteAtomIterT;
+ typedef typename std::vector<AtomLayout *>::iterator AbsoluteAtomIterT;
typedef llvm::DenseSet<const Atom *> AtomSetT;
/// \brief Append the Atom to the layout and create appropriate sections.
/// \returns A reference to the atom layout or an error. The atom layout will
/// be updated as linking progresses.
- virtual ErrorOr<const lld::AtomLayout *> addAtom(const Atom *atom);
+ virtual ErrorOr<const AtomLayout *> addAtom(const Atom *atom);
/// \brief Find an output Section given a section name.
OutputSection<ELFT> *findOutputSection(StringRef name) {
}
/// \brief find a absolute atom given a name
- lld::AtomLayout *findAbsoluteAtom(StringRef name) {
+ AtomLayout *findAbsoluteAtom(StringRef name) {
auto iter = std::find_if(
_absoluteAtoms.begin(), _absoluteAtoms.end(),
[=](const AtomLayout *a) { return a->_atom->name() == name; });
ProgramHeader<ELFT> *_programHeader;
unique_bump_ptr<RelocationTable<ELFT>> _dynamicRelocationTable;
unique_bump_ptr<RelocationTable<ELFT>> _pltRelocationTable;
- std::vector<lld::AtomLayout *> _absoluteAtoms;
+ std::vector<AtomLayout *> _absoluteAtoms;
AtomSetT _referencedDynAtoms;
llvm::StringSet<> _copiedDynSymNames;
ELFLinkingContext &_ctx;
}
std::error_code X86TargetRelocationHandler::applyRelocation(
- ELFWriter &writer, llvm::FileOutputBuffer &buf, const lld::AtomLayout &atom,
+ ELFWriter &writer, llvm::FileOutputBuffer &buf, const AtomLayout &atom,
const Reference &ref) const {
uint8_t *atomContent = buf.getBufferStart() + atom._fileOffset;
uint8_t *loc = atomContent + ref.offsetInAtom();
class X86TargetRelocationHandler final : public TargetRelocationHandler {
public:
std::error_code applyRelocation(ELFWriter &, llvm::FileOutputBuffer &,
- const lld::AtomLayout &,
+ const AtomLayout &,
const Reference &) const override;
};
}
std::error_code X86_64TargetRelocationHandler::applyRelocation(
- ELFWriter &writer, llvm::FileOutputBuffer &buf, const lld::AtomLayout &atom,
+ ELFWriter &writer, llvm::FileOutputBuffer &buf, const AtomLayout &atom,
const Reference &ref) const {
uint8_t *atomContent = buf.getBufferStart() + atom._fileOffset;
uint8_t *loc = atomContent + ref.offsetInAtom();
: _tlsSize(0), _layout(layout) {}
std::error_code applyRelocation(ELFWriter &, llvm::FileOutputBuffer &,
- const lld::AtomLayout &,
+ const AtomLayout &,
const Reference &) const override;
private: