Bug 1606739 - Initialize the .dynamic section first. r=froydnj

Differential Revision: https://phabricator.services.mozilla.com/D59078

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Mike Hommey 2020-01-08 14:30:21 +00:00
Родитель e4b8074522
Коммит a95697631f
1 изменённых файлов: 8 добавлений и 0 удалений

Просмотреть файл

@ -179,6 +179,14 @@ Elf::Elf(std::ifstream& file) {
// Fill sections list
sections = new ElfSection*[ehdr->e_shnum];
for (int i = 0; i < ehdr->e_shnum; i++) sections[i] = nullptr;
for (int i = 1; i < ehdr->e_shnum; i++) {
// The .dynamic section is going to have references to other sections,
// so it's better to start with that one and recursively initialize those
// other sections first, to avoid possible infinite recursion (bug 1606739).
if (tmp_shdr[i]->sh_type == SHT_DYNAMIC) {
getSection(i);
}
}
for (int i = 1; i < ehdr->e_shnum; i++) {
if (sections[i] != nullptr) continue;
getSection(i);