From 4260657fabc69cfc8806e6057948a2e6a3ebcefa Mon Sep 17 00:00:00 2001 From: "Michael J. Spencer" Date: Wed, 30 Jan 2013 01:25:06 +0000 Subject: [ELF] Make AtomLayout more accessible. This is needed to allow constant time access to the final layout of atoms. llvm-svn: 173874 --- lld/lib/ReaderWriter/ELF/Writer.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'lld/lib/ReaderWriter/ELF/Writer.cpp') diff --git a/lld/lib/ReaderWriter/ELF/Writer.cpp b/lld/lib/ReaderWriter/ELF/Writer.cpp index 2318cd8ebef..6e3bc438e49 100644 --- a/lld/lib/ReaderWriter/ELF/Writer.cpp +++ b/lld/lib/ReaderWriter/ELF/Writer.cpp @@ -97,7 +97,7 @@ void ExecutableWriter::buildSymbolTable () { for (auto sec : _layout->sections()) if (auto section = dyn_cast>(sec)) for (const auto &atom : section->atoms()) - _symtab->addSymbol(atom._atom, section->ordinal(), atom._virtualAddr); + _symtab->addSymbol(atom->_atom, section->ordinal(), atom->_virtualAddr); } template @@ -106,7 +106,7 @@ ExecutableWriter::addAbsoluteUndefinedSymbols(const File &file) { // add all the absolute symbols that the layout contains to the output symbol // table for (auto &atom : _layout->absoluteAtoms()) - _symtab->addSymbol(atom.absoluteAtom(), ELF::SHN_ABS, atom.value()); + _symtab->addSymbol(atom->_atom, ELF::SHN_ABS, atom->_virtualAddr); for (const UndefinedAtom *a : file.undefined()) _symtab->addSymbol(a, ELF::SHN_UNDEF); } @@ -116,10 +116,10 @@ void ExecutableWriter::buildAtomToAddressMap () { for (auto sec : _layout->sections()) if (auto section = dyn_cast>(sec)) for (const auto &atom : section->atoms()) - _atomToAddressMap[atom._atom] = atom._virtualAddr; + _atomToAddressMap[atom->_atom] = atom->_virtualAddr; // build the atomToAddressMap that contains absolute symbols too for (auto &atom : _layout->absoluteAtoms()) - _atomToAddressMap[atom.absoluteAtom()] = atom.value(); + _atomToAddressMap[atom->_atom] = atom->_virtualAddr; } template @@ -187,11 +187,11 @@ void ExecutableWriter::finalizeDefaultAtomValues() { StringRef sec) -> void { auto section = _layout->findOutputSection(sec); if (section) { - start->setValue(section->virtualAddr()); - end->setValue(section->virtualAddr() + section->memSize()); + (*start)->_virtualAddr = section->virtualAddr(); + (*end)->_virtualAddr = section->virtualAddr() + section->memSize(); } else { - start->setValue(0); - end->setValue(0); + (*start)->_virtualAddr = 0; + (*end)->_virtualAddr = 0; } }; @@ -210,10 +210,10 @@ void ExecutableWriter::finalizeDefaultAtomValues() { assert(!(phe == _programHeader->end()) && "Can't find a data segment in the program header!"); - bssStartAtomIter->setValue((*phe)->p_vaddr + (*phe)->p_filesz); - bssEndAtomIter->setValue((*phe)->p_vaddr + (*phe)->p_memsz); - underScoreEndAtomIter->setValue((*phe)->p_vaddr + (*phe)->p_memsz); - endAtomIter->setValue((*phe)->p_vaddr + (*phe)->p_memsz); + (*bssStartAtomIter)->_virtualAddr = (*phe)->p_vaddr + (*phe)->p_filesz; + (*bssEndAtomIter)->_virtualAddr = (*phe)->p_vaddr + (*phe)->p_memsz; + (*underScoreEndAtomIter)->_virtualAddr = (*phe)->p_vaddr + (*phe)->p_memsz; + (*endAtomIter)->_virtualAddr = (*phe)->p_vaddr + (*phe)->p_memsz; } template -- cgit v1.2.3