[ELF] NMAGIC support : Find the BSS section to setup the virtual address of _end.

llvm-svn: 183816
This commit is contained in:
Shankar Easwaran 2013-06-12 00:32:35 +00:00
parent d5ff08ca5f
commit 79dbc5b5d1
1 changed files with 6 additions and 9 deletions

View File

@ -118,16 +118,13 @@ template <class ELFT> void ExecutableWriter<ELFT>::finalizeDefaultAtomValues() {
endAtomIter == this->_layout->absoluteAtoms().end()) &&
"Unable to find the absolute atoms that have been added by lld");
auto phe = this->_programHeader
->findProgramHeader(llvm::ELF::PT_LOAD, llvm::ELF::PF_W, llvm::ELF::PF_X);
auto bssSection = this->_layout->findOutputSection(".bss");
assert(!(phe == this->_programHeader->rend()) &&
"Can't find a data segment in the program header!");
(*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;
(*bssStartAtomIter)->_virtualAddr = bssSection->virtualAddr();
(*bssEndAtomIter)->_virtualAddr =
bssSection->virtualAddr() + bssSection->memSize();
(*underScoreEndAtomIter)->_virtualAddr = (*bssEndAtomIter)->_virtualAddr;
(*endAtomIter)->_virtualAddr = (*bssEndAtomIter)->_virtualAddr;
// Give a chance for the target to finalize its atom values
this->_targetHandler.finalizeSymbolValues();