mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 628618 part 6 - Delay refreshing of ElfSection addresses and offsets. r=tglek,a=sdwilsh
This commit is contained in:
parent
cc0eedf4c6
commit
3a16edea86
@ -234,19 +234,19 @@ Elf::Elf(std::ifstream &file)
|
|||||||
s.sh_size = s.sh_entsize * ehdr->e_phnum;
|
s.sh_size = s.sh_entsize * ehdr->e_phnum;
|
||||||
phdr_section = new ElfSection(s, NULL, NULL);
|
phdr_section = new ElfSection(s, NULL, NULL);
|
||||||
|
|
||||||
phdr_section->insertAfter(ehdr);
|
phdr_section->insertAfter(ehdr, false);
|
||||||
|
|
||||||
sections[1]->insertAfter(phdr_section);
|
sections[1]->insertAfter(phdr_section, false);
|
||||||
for (int i = 2; i < ehdr->e_shnum; i++) {
|
for (int i = 2; i < ehdr->e_shnum; i++) {
|
||||||
// TODO: this should be done in a better way
|
// TODO: this should be done in a better way
|
||||||
if ((shdr_section->getPrevious() == NULL) && (shdr[i]->sh_offset > ehdr->e_shoff)) {
|
if ((shdr_section->getPrevious() == NULL) && (shdr[i]->sh_offset > ehdr->e_shoff)) {
|
||||||
shdr_section->insertAfter(sections[i - 1]);
|
shdr_section->insertAfter(sections[i - 1], false);
|
||||||
sections[i]->insertAfter(shdr_section);
|
sections[i]->insertAfter(shdr_section, false);
|
||||||
} else
|
} else
|
||||||
sections[i]->insertAfter(sections[i - 1]);
|
sections[i]->insertAfter(sections[i - 1], false);
|
||||||
}
|
}
|
||||||
if (shdr_section->getPrevious() == NULL)
|
if (shdr_section->getPrevious() == NULL)
|
||||||
shdr_section->insertAfter(sections[ehdr->e_shnum - 1]);
|
shdr_section->insertAfter(sections[ehdr->e_shnum - 1], false);
|
||||||
|
|
||||||
tmp_file = NULL;
|
tmp_file = NULL;
|
||||||
tmp_shdr = NULL;
|
tmp_shdr = NULL;
|
||||||
@ -273,7 +273,6 @@ Elf::Elf(std::ifstream &file)
|
|||||||
phdr_section->getShdr().sh_addr += phdr.p_vaddr;
|
phdr_section->getShdr().sh_addr += phdr.p_vaddr;
|
||||||
segment->addSection(ehdr);
|
segment->addSection(ehdr);
|
||||||
segment->addSection(phdr_section);
|
segment->addSection(phdr_section);
|
||||||
ehdr->markDirty();
|
|
||||||
}
|
}
|
||||||
if (phdr.p_type == PT_PHDR)
|
if (phdr.p_type == PT_PHDR)
|
||||||
segment->addSection(phdr_section);
|
segment->addSection(phdr_section);
|
||||||
@ -381,7 +380,7 @@ void Elf::write(std::ofstream &file)
|
|||||||
ehdr->e_shnum = section->getIndex() + 1;
|
ehdr->e_shnum = section->getIndex() + 1;
|
||||||
section->getShdr().sh_name = eh_shstrndx->getStrIndex(section->getName());
|
section->getShdr().sh_name = eh_shstrndx->getStrIndex(section->getName());
|
||||||
}
|
}
|
||||||
phdr_section->getNext()->markDirty();
|
ehdr->markDirty();
|
||||||
// Adjust PT_LOAD segments
|
// Adjust PT_LOAD segments
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (std::vector<ElfSegment *>::iterator seg = segments.begin(); seg != segments.end(); seg++, i++) {
|
for (std::vector<ElfSegment *>::iterator seg = segments.begin(); seg != segments.end(); seg++, i++) {
|
||||||
|
@ -316,8 +316,6 @@ int do_relocation_section(Elf *elf, unsigned int rel_type)
|
|||||||
Elf_Shdr relhackcode_section(relhackcode32_section);
|
Elf_Shdr relhackcode_section(relhackcode32_section);
|
||||||
ElfRelHack_Section *relhack = new ElfRelHack_Section(relhack_section);
|
ElfRelHack_Section *relhack = new ElfRelHack_Section(relhack_section);
|
||||||
ElfRelHackCode_Section *relhackcode = new ElfRelHackCode_Section(relhackcode_section, *elf);
|
ElfRelHackCode_Section *relhackcode = new ElfRelHackCode_Section(relhackcode_section, *elf);
|
||||||
relhackcode->insertAfter(section);
|
|
||||||
relhack->insertAfter(relhackcode);
|
|
||||||
|
|
||||||
std::vector<Rel_Type> new_rels;
|
std::vector<Rel_Type> new_rels;
|
||||||
Elf_RelHack relhack_entry;
|
Elf_RelHack relhack_entry;
|
||||||
@ -350,6 +348,9 @@ int do_relocation_section(Elf *elf, unsigned int rel_type)
|
|||||||
relhack_entry.r_offset = relhack_entry.r_info = 0;
|
relhack_entry.r_offset = relhack_entry.r_info = 0;
|
||||||
relhack->push_back(relhack_entry);
|
relhack->push_back(relhack_entry);
|
||||||
|
|
||||||
|
relhackcode->insertAfter(section);
|
||||||
|
relhack->insertAfter(relhackcode);
|
||||||
|
|
||||||
section->rels.assign(new_rels.begin(), new_rels.end());
|
section->rels.assign(new_rels.begin(), new_rels.end());
|
||||||
section->shrink(new_rels.size() * section->getEntSize());
|
section->shrink(new_rels.size() * section->getEntSize());
|
||||||
ElfLocation *init = new ElfLocation(relhackcode, 0);
|
ElfLocation *init = new ElfLocation(relhackcode, 0);
|
||||||
|
@ -334,7 +334,7 @@ public:
|
|||||||
(getFlags() & SHF_ALLOC));
|
(getFlags() & SHF_ALLOC));
|
||||||
}
|
}
|
||||||
|
|
||||||
void insertAfter(ElfSection *section) {
|
void insertAfter(ElfSection *section, bool dirty = true) {
|
||||||
if (previous != NULL)
|
if (previous != NULL)
|
||||||
previous->next = next;
|
previous->next = next;
|
||||||
if (next != NULL)
|
if (next != NULL)
|
||||||
@ -347,7 +347,8 @@ public:
|
|||||||
next = NULL;
|
next = NULL;
|
||||||
if (next != NULL)
|
if (next != NULL)
|
||||||
next->previous = this;
|
next->previous = this;
|
||||||
markDirty();
|
if (dirty)
|
||||||
|
markDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
void markDirty() {
|
void markDirty() {
|
||||||
|
Loading…
Reference in New Issue
Block a user