зеркало из https://github.com/mozilla/gecko-dev.git
Bug 629635 part 3 - Add ElfSegment::getOffset and ElfSegment::getAddr functions. r=tglek,a=blocking2.0:final
This commit is contained in:
Родитель
45d53e96e2
Коммит
6b2a02f26f
|
@ -419,13 +419,8 @@ void Elf::write(std::ofstream &file)
|
|||
Elf_Phdr phdr;
|
||||
phdr.p_type = (*seg)->getType();
|
||||
phdr.p_flags = (*seg)->getFlags();
|
||||
if ((*seg)->getFirstSection()) {
|
||||
phdr.p_offset = (*seg)->getFirstSection()->getOffset();
|
||||
phdr.p_vaddr = (*seg)->getFirstSection()->getAddr();
|
||||
} else {
|
||||
phdr.p_offset = 0;
|
||||
phdr.p_vaddr = 0;
|
||||
}
|
||||
phdr.p_offset = (*seg)->getOffset();
|
||||
phdr.p_vaddr = (*seg)->getAddr();
|
||||
phdr.p_paddr = phdr.p_vaddr + (*seg)->getVPDiff();
|
||||
phdr.p_filesz = (*seg)->getFileSize();
|
||||
phdr.p_memsz = (*seg)->getMemSize();
|
||||
|
@ -603,6 +598,16 @@ unsigned int ElfSegment::getMemSize()
|
|||
return end - sections.front()->getAddr();
|
||||
}
|
||||
|
||||
unsigned int ElfSegment::getOffset()
|
||||
{
|
||||
return sections.empty() ? 0 : sections.front()->getOffset();
|
||||
}
|
||||
|
||||
unsigned int ElfSegment::getAddr()
|
||||
{
|
||||
return sections.empty() ? 0 : sections.front()->getAddr();
|
||||
}
|
||||
|
||||
ElfSegment *ElfSegment::splitBefore(ElfSection *section)
|
||||
{
|
||||
std::list<ElfSection *>::iterator i, rm;
|
||||
|
|
|
@ -353,8 +353,8 @@ int do_relocation_section(Elf *elf, unsigned int rel_type)
|
|||
// Our injected code is likely not to be allowed to write there.
|
||||
ElfSection *section = elf->getSectionAt(i->r_offset);
|
||||
if (!(section->getFlags() & SHF_WRITE) || (ELF32_R_TYPE(i->r_info) != rel_type) ||
|
||||
(relro && (i->r_offset >= relro->getFirstSection()->getAddr()) &&
|
||||
(i->r_offset < relro->getFirstSection()->getAddr() + relro->getMemSize())))
|
||||
(relro && (i->r_offset >= relro->getAddr()) &&
|
||||
(i->r_offset < relro->getAddr() + relro->getMemSize())))
|
||||
new_rels.push_back(*i);
|
||||
else {
|
||||
// TODO: check that i->r_addend == *i->r_offset
|
||||
|
|
|
@ -402,6 +402,8 @@ public:
|
|||
int getVPDiff() { return v_p_diff; }
|
||||
unsigned int getFileSize();
|
||||
unsigned int getMemSize();
|
||||
unsigned int getOffset();
|
||||
unsigned int getAddr();
|
||||
|
||||
void addSection(ElfSection *section);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче