forked from OSchip/llvm-project
[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
llvm-svn: 176795
This commit is contained in:
parent
7b287eea22
commit
fc9d0a7d9b
|
@ -108,10 +108,10 @@ 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 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;
|
||||
|
|
|
@ -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() {}
|
||||
|
|
Loading…
Reference in New Issue