[lld] r176795 - [ELF] Set values for bss_start and end symbols properly, If there are two load segments with RW permissions, bss_start and end may get set inappropriate
Shankar Easwaran
shankare at codeaurora.org
Sun Mar 10 18:38:22 PDT 2013
Author: shankare
Date: Sun Mar 10 20:38:22 2013
New Revision: 176795
URL: http://llvm.org/viewvc/llvm-project?rev=176795&view=rev
Log:
[ELF] Set values for bss_start and end symbols properly, If there are two load segments with RW permissions, bss_start and end may get set inappropriate
Modified:
lld/trunk/lib/ReaderWriter/ELF/ExecutableWriter.h
lld/trunk/lib/ReaderWriter/ELF/HeaderChunks.h
Modified: lld/trunk/lib/ReaderWriter/ELF/ExecutableWriter.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ExecutableWriter.h?rev=176795&r1=176794&r2=176795&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/ExecutableWriter.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/ExecutableWriter.h Sun Mar 10 20:38:22 2013
@@ -108,10 +108,10 @@ void ExecutableWriter<ELFT>::finalizeDef
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 phe = this->_programHeader
+ ->findProgramHeader(llvm::ELF::PT_LOAD, llvm::ELF::PF_W, llvm::ELF::PF_X);
- assert(!(phe == this->_programHeader->end()) &&
+ assert(!(phe == this->_programHeader->rend()) &&
"Can't find a data segment in the program header!");
(*bssStartAtomIter)->_virtualAddr = (*phe)->p_vaddr + (*phe)->p_filesz;
Modified: lld/trunk/lib/ReaderWriter/ELF/HeaderChunks.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/HeaderChunks.h?rev=176795&r1=176794&r2=176795&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/HeaderChunks.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/HeaderChunks.h Sun Mar 10 20:38:22 2013
@@ -89,6 +89,7 @@ class ProgramHeader : public Chunk<ELFT>
public:
typedef llvm::object::Elf_Phdr_Impl<ELFT> Elf_Phdr;
typedef typename std::vector<Elf_Phdr *>::iterator PhIterT;
+ typedef typename std::reverse_iterator<PhIterT> ReversePhIterT;
/// \brief Find a program header entry, given the type of entry that
/// we are looking for
@@ -132,8 +133,9 @@ public:
void write(ELFWriter *writer, llvm::FileOutputBuffer &buffer);
/// \brief find a program header entry in the list of program headers
- PhIterT findProgramHeader(uint64_t type, uint64_t flags, uint64_t flagClear) {
- return std::find_if(_ph.begin(), _ph.end(),
+ ReversePhIterT
+ findProgramHeader(uint64_t type, uint64_t flags, uint64_t flagClear) {
+ return std::find_if(_ph.rbegin(), _ph.rend(),
FindPhdr(type, flags, flagClear));
}
@@ -145,6 +147,10 @@ public:
return _ph.end();
}
+ ReversePhIterT rbegin() { return _ph.rbegin(); }
+
+ ReversePhIterT rend() { return _ph.rend(); }
+
virtual void doPreFlight() {}
void finalize() {}
More information about the llvm-commits
mailing list