[ELF] Replace [...] x_{begin,end}() with range<[...]> x().

llvm-svn: 172513
This commit is contained in:
Michael J. Spencer 2013-01-15 06:55:37 +00:00
parent aa3aa570dc
commit bb78a04088
1 changed files with 112 additions and 170 deletions

View File

@ -13,6 +13,7 @@
#include "lld/Core/DefinedAtom.h" #include "lld/Core/DefinedAtom.h"
#include "lld/Core/File.h" #include "lld/Core/File.h"
#include "lld/Core/InputFiles.h" #include "lld/Core/InputFiles.h"
#include "lld/Core/range.h"
#include "lld/Core/Reference.h" #include "lld/Core/Reference.h"
#include "lld/Core/SharedLibraryAtom.h" #include "lld/Core/SharedLibraryAtom.h"
#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/ArrayRef.h"
@ -478,7 +479,7 @@ public:
continue; continue;
uint8_t *atomContent = chunkBuffer + ai._fileOffset; uint8_t *atomContent = chunkBuffer + ai._fileOffset;
std::copy_n(content.data(), contentSize, atomContent); std::copy_n(content.data(), contentSize, atomContent);
for (auto ref = definedAtom->begin(); ref != definedAtom->end(); ++ref) { for (const auto ref : *definedAtom) {
uint32_t offset = ref->offsetInAtom(); uint32_t offset = ref->offsetInAtom();
uint64_t targetAddress = 0; uint64_t targetAddress = 0;
assert(ref->target() != nullptr && "Found the target to be NULL"); assert(ref->target() != nullptr && "Found the target to be NULL");
@ -497,9 +498,7 @@ public:
/// Atom Iterators /// Atom Iterators
typedef typename std::vector<AtomLayout>::iterator atom_iter; typedef typename std::vector<AtomLayout>::iterator atom_iter;
atom_iter atoms_begin() { return _atoms.begin(); } range<atom_iter> atoms() { return _atoms; }
atom_iter atoms_end() { return _atoms.end(); }
protected: protected:
int32_t _contentType; int32_t _contentType;
@ -587,9 +586,7 @@ public:
typedef typename std::vector< typedef typename std::vector<
Chunk<target_endianness, max_align, is64Bits> *>::iterator ChunkIter; Chunk<target_endianness, max_align, is64Bits> *>::iterator ChunkIter;
ChunkIter begin_sections() { return _sections.begin(); } range<ChunkIter> sections() { return _sections; }
ChunkIter end_sections() { return _sections.end(); }
// The below functions returns the properties of the MergeSection // The below functions returns the properties of the MergeSection
bool hasSegment() const { return _hasSegment; } bool hasSegment() const { return _hasSegment; }
@ -646,7 +643,7 @@ template<support::endianness target_endianness,
class SegmentSlice { class SegmentSlice {
public: public:
typedef typename std::vector< typedef typename std::vector<
Chunk<target_endianness, max_align, is64Bits> *>::iterator sectionIter; Chunk<target_endianness, max_align, is64Bits> *>::iterator SectionIter;
SegmentSlice() { } SegmentSlice() { }
@ -661,9 +658,8 @@ public:
// Set the segment slice start and end iterators. This is used to walk through // Set the segment slice start and end iterators. This is used to walk through
// the sections that are part of the Segment slice // the sections that are part of the Segment slice
void setSections(sectionIter start, sectionIter end) { void setSections(range<SectionIter> sections) {
_startSectionIter = start; _sections = sections;
_endSectionIter = end;
} }
// Return the fileOffset of the slice // Return the fileOffset of the slice
@ -698,16 +694,14 @@ public:
return (a->startSection() < b->startSection()); return (a->startSection() < b->startSection());
} }
// Functions to run through the slice range<SectionIter> sections() {
sectionIter sections_begin() { return _startSectionIter; } return _sections;
}
sectionIter sections_end() { return _endSectionIter; }
private: private:
int32_t _startSection; int32_t _startSection;
int32_t _endSection; int32_t _endSection;
sectionIter _startSectionIter; range<SectionIter> _sections;
sectionIter _endSectionIter;
uint64_t _addr; uint64_t _addr;
uint64_t _offset; uint64_t _offset;
uint64_t _size; uint64_t _size;
@ -724,7 +718,7 @@ template<support::endianness target_endianness,
class Segment : public Chunk<target_endianness, max_align, is64Bits> { class Segment : public Chunk<target_endianness, max_align, is64Bits> {
public: public:
typedef typename std::vector<SegmentSlice< typedef typename std::vector<SegmentSlice<
target_endianness, max_align, is64Bits> *>::iterator slice_iter; target_endianness, max_align, is64Bits> *>::iterator SliceIter;
typedef typename std::vector< typedef typename std::vector<
Chunk<target_endianness, max_align, is64Bits> *>::iterator SectionIter; Chunk<target_endianness, max_align, is64Bits> *>::iterator SectionIter;
@ -819,9 +813,9 @@ public:
// a seperate segment, so that memory is not used up while running // a seperate segment, so that memory is not used up while running
if ((newOffset - curOffset) > _options.pageSize()) { if ((newOffset - curOffset) > _options.pageSize()) {
// TODO: use std::find here // TODO: use std::find here
for (auto sei = slices_begin(); sei != slices_end(); ++sei) { for (auto s : slices()) {
if ((*sei)->startSection() == startSection) { if (s->startSection() == startSection) {
slice = *sei; slice = s;
break; break;
} }
} }
@ -832,7 +826,7 @@ public:
_segmentSlices.push_back(slice); _segmentSlices.push_back(slice);
} }
slice->set(curSliceFileOffset, startSection, currSection); slice->set(curSliceFileOffset, startSection, currSection);
slice->setSections(startSectionIter, endSectionIter); slice->setSections(make_range(startSectionIter, endSectionIter));
slice->setSize(curSliceSize); slice->setSize(curSliceSize);
slice->setAlign(sliceAlign); slice->setAlign(sliceAlign);
uint64_t newPageOffset = uint64_t newPageOffset =
@ -855,10 +849,10 @@ public:
endSectionIter = si; endSectionIter = si;
} }
SegmentSlice<target_endianness, max_align, is64Bits> *slice = nullptr; SegmentSlice<target_endianness, max_align, is64Bits> *slice = nullptr;
for (auto sei = slices_begin(); sei != slices_end(); ++sei) { for (auto s : slices()) {
// TODO: add std::find // TODO: add std::find
if ((*sei)->startSection() == startSection) { if (s->startSection() == startSection) {
slice = *sei; slice = s;
break; break;
} }
} }
@ -869,7 +863,7 @@ public:
_segmentSlices.push_back(slice); _segmentSlices.push_back(slice);
} }
slice->set(curSliceFileOffset, startSection, currSection); slice->set(curSliceFileOffset, startSection, currSection);
slice->setSections(startSectionIter, _sections.end()); slice->setSections(make_range(startSectionIter, _sections.end()));
slice->setSize(curSliceSize); slice->setSize(curSliceSize);
slice->setAlign(sliceAlign); slice->setAlign(sliceAlign);
this->_fsize = curSliceFileOffset - startOffset + curSliceSize; this->_fsize = curSliceFileOffset - startOffset + curSliceSize;
@ -879,49 +873,49 @@ public:
/// \brief Assign virtual addresses to the slices /// \brief Assign virtual addresses to the slices
void assignVirtualAddress(uint64_t &addr) { void assignVirtualAddress(uint64_t &addr) {
for (auto sei = slices_begin(), see = slices_end(); sei != see; ++sei) { for (auto slice : slices()) {
// Align to a page // Align to a page
addr = llvm::RoundUpToAlignment(addr, _options.pageSize()); addr = llvm::RoundUpToAlignment(addr, _options.pageSize());
// Align to the slice alignment // Align to the slice alignment
addr = llvm::RoundUpToAlignment(addr, (*sei)->align2()); addr = llvm::RoundUpToAlignment(addr, slice->align2());
bool virtualAddressSet = false; bool virtualAddressSet = false;
for (auto si = (*sei)->sections_begin(), se = (*sei)->sections_end(); for (auto section : slice->sections()) {
si != se; ++si) {
// Align the section address // Align the section address
addr = llvm::RoundUpToAlignment(addr, (*si)->align2()); addr = llvm::RoundUpToAlignment(addr, section->align2());
if (!virtualAddressSet) { if (!virtualAddressSet) {
(*sei)->setVAddr(addr); slice->setVAddr(addr);
virtualAddressSet = true; virtualAddressSet = true;
} }
(*si)->setVAddr(addr); section->setVAddr(addr);
if (auto s = if (auto s = dyn_cast<Section<target_endianness, max_align, is64Bits>>(
dyn_cast<Section<target_endianness, max_align, is64Bits>>(*si)) section))
s->assignVirtualAddress(addr); s->assignVirtualAddress(addr);
else else
addr += (*si)->memSize(); addr += section->memSize();
(*si)->setMemSize(addr - (*si)->virtualAddr()); section->setMemSize(addr - section->virtualAddr());
} }
(*sei)->setMemSize(addr - (*sei)->virtualAddr()); slice->setMemSize(addr - slice->virtualAddr());
} }
} }
slice_iter slices_begin() { range<SliceIter> slices() { return _segmentSlices; }
// These two accessors are still needed for a call to std::stable_sort.
// Consider adding wrappers for two iterator algorithms.
SliceIter slices_begin() {
return _segmentSlices.begin(); return _segmentSlices.begin();
} }
slice_iter slices_end() { SliceIter slices_end() {
return _segmentSlices.end(); return _segmentSlices.end();
} }
// Write the Segment // Write the Segment
void write(ELFWriter *writer, OwningPtr<FileOutputBuffer> &buffer) { void write(ELFWriter *writer, OwningPtr<FileOutputBuffer> &buffer) {
for (auto sei = slices_begin(), see = slices_end(); sei != see; ++sei) { for (auto slice : slices())
for (auto si = (*sei)->sections_begin(), se = (*sei)->sections_end(); for (auto section : slice->sections())
si != se; ++si) { section->write(writer, buffer);
(*si)->write(writer, buffer);
}
}
} }
// Finalize the segment, before we want to write to the output file // Finalize the segment, before we want to write to the output file
@ -1252,8 +1246,7 @@ public:
Elf_Phdr *phdr = nullptr; Elf_Phdr *phdr = nullptr;
bool ret = false; bool ret = false;
for (auto sei = segment->slices_begin(), see = segment->slices_end(); for (auto slice : segment->slices()) {
sei != see; ++sei) {
if (_phi == _ph.end()) { if (_phi == _ph.end()) {
phdr = new(_allocator.Allocate<Elf_Phdr>()) Elf_Phdr; phdr = new(_allocator.Allocate<Elf_Phdr>()) Elf_Phdr;
_ph.push_back(phdr); _ph.push_back(phdr);
@ -1264,14 +1257,14 @@ public:
++_phi; ++_phi;
} }
phdr->p_type = segment->segmentType(); phdr->p_type = segment->segmentType();
phdr->p_offset = (*sei)->fileOffset(); phdr->p_offset = slice->fileOffset();
phdr->p_vaddr = (*sei)->virtualAddr(); phdr->p_vaddr = slice->virtualAddr();
phdr->p_paddr = (*sei)->virtualAddr(); phdr->p_paddr = slice->virtualAddr();
phdr->p_filesz = (*sei)->fileSize(); phdr->p_filesz = slice->fileSize();
phdr->p_memsz = (*sei)->memSize(); phdr->p_memsz = slice->memSize();
phdr->p_flags = segment->flags(); phdr->p_flags = segment->flags();
phdr->p_align = (phdr->p_type == llvm::ELF::PT_LOAD) ? phdr->p_align = (phdr->p_type == llvm::ELF::PT_LOAD) ?
segment->pageSize() : (*sei)->align2(); segment->pageSize() : slice->align2();
} }
this->_fsize = fileSize(); this->_fsize = fileSize();
@ -1732,14 +1725,7 @@ public:
FindByName(name)); FindByName(name));
} }
/// \bried Begin/End iterators range<AbsoluteAtomIterT> absoluteAtoms() { return _absoluteAtoms; }
AbsoluteAtomIterT absAtomsBegin() {
return _absoluteAtoms.begin();
}
AbsoluteAtomIterT absAtomsEnd() {
return _absoluteAtoms.end();
}
// Merge sections with the same name into a MergedSections // Merge sections with the same name into a MergedSections
void mergeSimiliarSections() { void mergeSimiliarSections() {
@ -1776,27 +1762,24 @@ public:
mergeSimiliarSections(); mergeSimiliarSections();
// Set the ordinal after sorting the sections // Set the ordinal after sorting the sections
int ordinal = 1; int ordinal = 1;
for (auto &msi : _mergedSections) { for (auto msi : _mergedSections) {
(*msi).setOrdinal(ordinal); msi->setOrdinal(ordinal);
for (auto ai = (*msi).begin_sections(), ae = (*msi).end_sections(); for (auto ai : msi->sections()) {
ai != ae; ++ai) { ai->setOrdinal(ordinal);
(*ai)->setOrdinal(ordinal);
} }
++ordinal; ++ordinal;
} }
for (auto msi = merged_sections_begin(), mse = merged_sections_end(); for (auto msi : _mergedSections) {
msi != mse; ++msi) { for (auto ai : msi->sections()) {
for (auto ai = (*msi)->begin_sections(), ae = (*msi)->end_sections();
ai != ae; ++ai) {
if (auto section = if (auto section =
dyn_cast<Section<target_endianness, max_align, is64Bits>>(*ai)) { dyn_cast<Section<target_endianness, max_align, is64Bits>>(ai)) {
if (!hasOutputSegment(section)) if (!hasOutputSegment(section))
continue; continue;
(*msi)->setHasSegment(); msi->setHasSegment();
section->setSegment(getSegmentType(section)); section->setSegment(getSegmentType(section));
const StringRef segmentName = section->segmentKindToStr(); const StringRef segmentName = section->segmentKindToStr();
// Use the flags of the merged Section for the segment // Use the flags of the merged Section for the segment
const SegmentKey key(segmentName, (*msi)->flags()); const SegmentKey key(segmentName, msi->flags());
const std::pair<SegmentKey, const std::pair<SegmentKey,
Segment<target_endianness, max_align, is64Bits> *> Segment<target_endianness, max_align, is64Bits> *>
currentSegment(key, nullptr); currentSegment(key, nullptr);
@ -1900,44 +1883,40 @@ public:
section->assignOffsets(section->fileOffset()); section->assignOffsets(section->fileOffset());
} }
// Set the size of the merged Sections // Set the size of the merged Sections
for (auto msi = merged_sections_begin(), mse = merged_sections_end(); for (auto msi : _mergedSections) {
msi != mse; ++msi) {
uint64_t sectionfileoffset = 0; uint64_t sectionfileoffset = 0;
uint64_t startFileOffset = 0; uint64_t startFileOffset = 0;
uint64_t sectionsize = 0; uint64_t sectionsize = 0;
bool isFirstSection = true; bool isFirstSection = true;
for (auto si = (*msi)->begin_sections(); si != (*msi)->end_sections(); for (auto si : msi->sections()) {
++si) {
if (isFirstSection) { if (isFirstSection) {
startFileOffset = (*si)->fileOffset(); startFileOffset = si->fileOffset();
isFirstSection = false; isFirstSection = false;
} }
sectionfileoffset = (*si)->fileOffset(); sectionfileoffset = si->fileOffset();
sectionsize = (*si)->fileSize(); sectionsize = si->fileSize();
} }
sectionsize = (sectionfileoffset - startFileOffset) + sectionsize; sectionsize = (sectionfileoffset - startFileOffset) + sectionsize;
(*msi)->setFileOffset(startFileOffset); msi->setFileOffset(startFileOffset);
(*msi)->setSize(sectionsize); msi->setSize(sectionsize);
} }
// Set the virtual addr of the merged Sections // Set the virtual addr of the merged Sections
for (auto msi = merged_sections_begin(), mse = merged_sections_end(); for (auto msi : _mergedSections) {
msi != mse; ++msi) {
uint64_t sectionstartaddr = 0; uint64_t sectionstartaddr = 0;
uint64_t startaddr = 0; uint64_t startaddr = 0;
uint64_t sectionsize = 0; uint64_t sectionsize = 0;
bool isFirstSection = true; bool isFirstSection = true;
for (auto si = (*msi)->begin_sections(), se = (*msi)->end_sections(); for (auto si : msi->sections()) {
si != se; ++si) {
if (isFirstSection) { if (isFirstSection) {
startaddr = (*si)->virtualAddr(); startaddr = si->virtualAddr();
isFirstSection = false; isFirstSection = false;
} }
sectionstartaddr = (*si)->virtualAddr(); sectionstartaddr = si->virtualAddr();
sectionsize = (*si)->memSize(); sectionsize = si->memSize();
} }
sectionsize = (sectionstartaddr - startaddr) + sectionsize; sectionsize = (sectionstartaddr - startaddr) + sectionsize;
(*msi)->setMemSize(sectionsize); msi->setMemSize(sectionsize);
(*msi)->setAddr(startaddr); msi->setAddr(startaddr);
} }
} }
@ -1964,44 +1943,24 @@ public:
} }
void finalize() { void finalize() {
for (auto &si : _sections) { for (auto &si : _sections)
si->finalize(); si->finalize();
} }
}
bool findAtomAddrByName(const StringRef name, uint64_t &addr) { bool findAtomAddrByName(const StringRef name, uint64_t &addr) {
for (auto ai = _sections.begin(); ai != _sections.end(); ++ai) { for (auto sec : _sections)
if (auto section = if (auto section =
dyn_cast<Section<target_endianness, max_align, is64Bits>>(*ai)) { dyn_cast<Section<target_endianness, max_align, is64Bits>>(sec))
if (section->findAtomAddrByName(name, addr)) if (section->findAtomAddrByName(name, addr))
return true; return true;
}
}
return false; return false;
} }
MergedSectionIter merged_sections_begin() { range<MergedSectionIter> mergedSections() { return _mergedSections; }
return _mergedSections.begin();
}
MergedSectionIter merged_sections_end() { range<ChunkIter> sections() { return _sections; }
return _mergedSections.end();
}
ChunkIter sections_begin() { range<ChunkIter> segments() { return _segments; }
return _sections.begin();
}
ChunkIter sections_end() {
return _sections.end();
}
ChunkIter segments_begin() {
return _segments.begin();
}
ChunkIter segments_end() {
return _segments.end();
}
ELFHeader<target_endianness, max_align, is64Bits> *elfHeader() { ELFHeader<target_endianness, max_align, is64Bits> *elfHeader() {
return _elfHeader; return _elfHeader;
@ -2111,16 +2070,11 @@ template<support::endianness target_endianness,
bool is64Bits> bool is64Bits>
void ELFExecutableWriter<target_endianness, max_align, is64Bits> void ELFExecutableWriter<target_endianness, max_align, is64Bits>
::buildSymbolTable () { ::buildSymbolTable () {
Section<target_endianness, max_align, is64Bits> *section; for (auto sec : _layout->sections())
for (auto si = _layout->sections_begin(); si != _layout->sections_end();
++si) {
if (auto section = if (auto section =
dyn_cast<Section<target_endianness, max_align, is64Bits>>(*si)) { dyn_cast<Section<target_endianness, max_align, is64Bits>>(sec))
for (auto ai = section->atoms_begin(); ai != section->atoms_end(); ++ai) { for (const auto &atom : section->atoms())
_symtab->addSymbol(ai->_atom, section->ordinal(), ai->_virtualAddr); _symtab->addSymbol(atom._atom, section->ordinal(), atom._virtualAddr);
}
}
}
} }
template<support::endianness target_endianness, template<support::endianness target_endianness,
@ -2128,35 +2082,27 @@ template<support::endianness target_endianness,
bool is64Bits> bool is64Bits>
void ELFExecutableWriter<target_endianness, max_align, is64Bits> void ELFExecutableWriter<target_endianness, max_align, is64Bits>
::addAbsoluteUndefinedSymbols(const lld::File &file) { ::addAbsoluteUndefinedSymbols(const lld::File &file) {
/// add all the absolute symbols that the layout contains to the output symbol // add all the absolute symbols that the layout contains to the output symbol
/// table // table
for (auto absi = _layout->absAtomsBegin(), abse = _layout->absAtomsEnd(); for (auto &atom : _layout->absoluteAtoms())
absi != abse; ++absi) { _symtab->addSymbol(atom.absoluteAtom(), ELF::SHN_ABS, atom.value());
_symtab->addSymbol(absi->absoluteAtom(), ELF::SHN_ABS, absi->value()); for (const UndefinedAtom *a : file.undefined())
}
for (const UndefinedAtom *a : file.undefined()) {
_symtab->addSymbol(a, ELF::SHN_UNDEF); _symtab->addSymbol(a, ELF::SHN_UNDEF);
} }
}
template<support::endianness target_endianness, template<support::endianness target_endianness,
std::size_t max_align, std::size_t max_align,
bool is64Bits> bool is64Bits>
void ELFExecutableWriter<target_endianness, max_align, is64Bits> void ELFExecutableWriter<target_endianness, max_align, is64Bits>
::buildAtomToAddressMap () { ::buildAtomToAddressMap () {
for (auto si = _layout->sections_begin(); for (auto sec : _layout->sections())
si != _layout->sections_end(); ++si) {
if (auto section = if (auto section =
dyn_cast<Section<target_endianness, max_align, is64Bits>>(*si)) dyn_cast<Section<target_endianness, max_align, is64Bits>>(sec))
for (auto ai = section->atoms_begin(); ai != section->atoms_end(); ++ai) { for (const auto &atom : section->atoms())
_atomToAddressMap[ai->_atom] = (ai)->_virtualAddr; _atomToAddressMap[atom._atom] = atom._virtualAddr;
} // build the atomToAddressMap that contains absolute symbols too
} for (auto &atom : _layout->absoluteAtoms())
/// build the atomToAddressMap that contains absolute symbols too _atomToAddressMap[atom.absoluteAtom()] = atom.value();
for (auto absi = _layout->absAtomsBegin(), abse = _layout->absAtomsEnd();
absi != abse; ++absi) {
_atomToAddressMap[absi->absoluteAtom()] = absi->value();
}
} }
template<support::endianness target_endianness, template<support::endianness target_endianness,
@ -2164,13 +2110,12 @@ template<support::endianness target_endianness,
bool is64Bits> bool is64Bits>
void ELFExecutableWriter<target_endianness, max_align, is64Bits> void ELFExecutableWriter<target_endianness, max_align, is64Bits>
::buildSectionHeaderTable() { ::buildSectionHeaderTable() {
for (auto msi = _layout->merged_sections_begin(); for (auto mergedSec : _layout->mergedSections()) {
msi != _layout->merged_sections_end(); ++msi) { if (mergedSec->kind() !=
if ((*msi)->kind() !=
Chunk<target_endianness, max_align, is64Bits>::K_ELFSection) Chunk<target_endianness, max_align, is64Bits>::K_ELFSection)
continue; continue;
if ((*msi)->hasSegment()) if (mergedSec->hasSegment())
_shdrtab->appendSection(*msi); _shdrtab->appendSection(mergedSec);
} }
} }
@ -2179,24 +2124,21 @@ template<support::endianness target_endianness,
bool is64Bits> bool is64Bits>
void ELFExecutableWriter<target_endianness, max_align, is64Bits> void ELFExecutableWriter<target_endianness, max_align, is64Bits>
::assignSectionsWithNoSegments() { ::assignSectionsWithNoSegments() {
for (auto msi = _layout->merged_sections_begin(); for (auto mergedSec : _layout->mergedSections()) {
msi != _layout->merged_sections_end(); ++msi) { if (mergedSec->kind() !=
if ((*msi)->kind() !=
Chunk<target_endianness, max_align, is64Bits>::K_ELFSection) Chunk<target_endianness, max_align, is64Bits>::K_ELFSection)
continue; continue;
if (!(*msi)->hasSegment()) if (!mergedSec->hasSegment())
_shdrtab->appendSection(*msi); _shdrtab->appendSection(mergedSec);
} }
_layout->assignOffsetsForMiscSections(); _layout->assignOffsetsForMiscSections();
for (auto si = _layout->sections_begin(); for (auto sec : _layout->sections())
si != _layout->sections_end(); ++si) {
if (auto section = if (auto section =
dyn_cast<Section<target_endianness, max_align, is64Bits>>(*si)) dyn_cast<Section<target_endianness, max_align, is64Bits>>(sec))
if (!DefaultELFLayout<target_endianness, max_align, is64Bits> if (!DefaultELFLayout<target_endianness, max_align, is64Bits>
::hasOutputSegment(section)) ::hasOutputSegment(section))
_shdrtab->updateSection(section); _shdrtab->updateSection(section);
} }
}
/// \brief Add absolute symbols by default. These are linker added /// \brief Add absolute symbols by default. These are linker added
/// absolute symbols /// absolute symbols
@ -2248,10 +2190,10 @@ void ELFExecutableWriter<target_endianness, max_align, is64Bits>
initArrayEndIter->setValue(0); initArrayEndIter->setValue(0);
} }
assert(!(bssStartAtomIter == _layout->absAtomsEnd() || assert(!(bssStartAtomIter == _layout->absoluteAtoms().end() ||
bssEndAtomIter == _layout->absAtomsEnd() || bssEndAtomIter == _layout->absoluteAtoms().end() ||
underScoreEndAtomIter == _layout->absAtomsEnd() || underScoreEndAtomIter == _layout->absoluteAtoms().end() ||
endAtomIter == _layout->absAtomsEnd()) && endAtomIter == _layout->absoluteAtoms().end()) &&
"Unable to find the absolute atoms that have been added by lld"); "Unable to find the absolute atoms that have been added by lld");
auto phe = _programHeader->findProgramHeader( auto phe = _programHeader->findProgramHeader(
@ -2341,8 +2283,8 @@ error_code ELFExecutableWriter<target_endianness, max_align, is64Bits>
_elfHeader->write(this, buffer); _elfHeader->write(this, buffer);
_programHeader->write(this, buffer); _programHeader->write(this, buffer);
for (auto si = _layout->sections_begin(); si != _layout->sections_end(); ++si) for (auto section : _layout->sections())
(*si)->write(this, buffer); section->write(this, buffer);
return buffer->commit(); return buffer->commit();
} }