mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 06:11:37 +00:00
Bug 674888 - Allow elfhack to move .interp sections. r=tglek
This commit is contained in:
parent
5778ccd183
commit
a827925ebe
@ -566,6 +566,7 @@ void ElfSegment::addSection(ElfSection *section)
|
||||
if ((*i)->getAddr() > section->getAddr())
|
||||
break;
|
||||
sections.insert(i, section);
|
||||
section->addToSegment(this);
|
||||
}
|
||||
|
||||
unsigned int ElfSegment::getFileSize()
|
||||
@ -636,8 +637,10 @@ ElfSegment *ElfSegment::splitBefore(ElfSection *section)
|
||||
phdr.p_memsz = (unsigned int)-1;
|
||||
ElfSegment *segment = new ElfSegment(&phdr);
|
||||
|
||||
for (rm = i; i != sections.end(); ++i)
|
||||
for (rm = i; i != sections.end(); ++i) {
|
||||
(*i)->removeFromSegment(this);
|
||||
segment->addSection(*i);
|
||||
}
|
||||
sections.erase(rm, sections.end());
|
||||
|
||||
return segment;
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <algorithm>
|
||||
#include <elf.h>
|
||||
#include <asm/byteorder.h>
|
||||
|
||||
@ -370,7 +371,8 @@ public:
|
||||
(getType() == SHT_GNU_HASH) ||
|
||||
(getType() == SHT_GNU_verdef) ||
|
||||
(getType() == SHT_GNU_verneed) ||
|
||||
(getType() == SHT_GNU_versym)) &&
|
||||
(getType() == SHT_GNU_versym) ||
|
||||
isInSegmentType(PT_INTERP)) &&
|
||||
(getFlags() & SHF_ALLOC);
|
||||
}
|
||||
|
||||
@ -410,6 +412,20 @@ public:
|
||||
file.seekp(getOffset());
|
||||
file.write(data, getSize());
|
||||
}
|
||||
|
||||
private:
|
||||
friend class ElfSegment;
|
||||
|
||||
void addToSegment(ElfSegment *segment) {
|
||||
segments.push_back(segment);
|
||||
}
|
||||
|
||||
void removeFromSegment(ElfSegment *segment) {
|
||||
std::vector<ElfSegment *>::iterator i = std::find(segments.begin(), segments.end(), segment);
|
||||
segments.erase(i, i + 1);
|
||||
}
|
||||
|
||||
bool isInSegmentType(unsigned int type);
|
||||
protected:
|
||||
Elf_Shdr shdr;
|
||||
char *data;
|
||||
@ -419,6 +435,7 @@ private:
|
||||
SectionInfo info;
|
||||
ElfSection *next, *previous;
|
||||
int index;
|
||||
std::vector<ElfSegment *> segments;
|
||||
};
|
||||
|
||||
class ElfSegment {
|
||||
@ -636,6 +653,13 @@ inline unsigned int Elf::getSize() {
|
||||
return section->getOffset() + section->getSize();
|
||||
}
|
||||
|
||||
inline bool ElfSection::isInSegmentType(unsigned int type) {
|
||||
for (std::vector<ElfSegment *>::iterator seg = segments.begin(); seg != segments.end(); seg++)
|
||||
if ((*seg)->getType() == type)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
inline ElfLocation::ElfLocation(ElfSection *section, unsigned int off, enum position pos)
|
||||
: section(section) {
|
||||
if ((pos == ABSOLUTE) && section)
|
||||
|
Loading…
Reference in New Issue
Block a user