forked from mirrors/gecko-dev
Bug 1903021 - Avoid use after vector resize. a=RyanVM
Original Revision: https://phabricator.services.mozilla.com/D214330 Differential Revision: https://phabricator.services.mozilla.com/D214487
This commit is contained in:
parent
5af0b5d0b6
commit
7eeac8ca54
1 changed files with 7 additions and 5 deletions
|
|
@ -1116,7 +1116,7 @@ int do_relocation_section(Elf* elf, unsigned int rel_type,
|
||||||
// can actually use it)
|
// can actually use it)
|
||||||
if (elf->getSegmentByType(PT_GNU_RELRO)) {
|
if (elf->getSegmentByType(PT_GNU_RELRO)) {
|
||||||
ElfSection* gnu_versym = dyn->getSectionForType(DT_VERSYM);
|
ElfSection* gnu_versym = dyn->getSectionForType(DT_VERSYM);
|
||||||
auto lookup = [&symtab, &gnu_versym](const char* symbol) {
|
auto ensure_symbol = [&symtab, &gnu_versym](const char* symbol) {
|
||||||
Elf_SymValue* sym_value = symtab->lookup(symbol, STT(FUNC));
|
Elf_SymValue* sym_value = symtab->lookup(symbol, STT(FUNC));
|
||||||
if (!sym_value) {
|
if (!sym_value) {
|
||||||
symtab->syms.emplace_back();
|
symtab->syms.emplace_back();
|
||||||
|
|
@ -1138,11 +1138,13 @@ int do_relocation_section(Elf* elf, unsigned int rel_type,
|
||||||
gnu_versym->grow(gnu_versym->getSize() + gnu_versym->getEntSize());
|
gnu_versym->grow(gnu_versym->getSize() + gnu_versym->getEntSize());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return sym_value;
|
|
||||||
};
|
};
|
||||||
|
// ensure_symbol may trigger a symbol table vector resize, so only lookup
|
||||||
Elf_SymValue* mprotect = lookup("mprotect");
|
// the symbols after we're done touching the symbol table.
|
||||||
Elf_SymValue* sysconf = lookup("sysconf");
|
ensure_symbol("mprotect");
|
||||||
|
ensure_symbol("sysconf");
|
||||||
|
Elf_SymValue* mprotect = symtab->lookup("mprotect", STT(FUNC));
|
||||||
|
Elf_SymValue* sysconf = symtab->lookup("sysconf", STT(FUNC));
|
||||||
|
|
||||||
// Add relocations for the mprotect and sysconf symbols.
|
// Add relocations for the mprotect and sysconf symbols.
|
||||||
auto add_relocation_to = [&new_rels, &symtab, rel_type2](
|
auto add_relocation_to = [&new_rels, &symtab, rel_type2](
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue