Don't use stale section data pointers

put_elf_reloca might reallocate the section into which we point,
so don't remember the pointer just the offset.
This commit is contained in:
Michael Matz 2021-02-13 00:35:29 +01:00
parent 468e59206b
commit 30814dfacf

View file

@ -8034,10 +8034,10 @@ static void init_putv(init_params *p, CType *type, unsigned long c)
includes relocations. Use the fact that relocs are includes relocations. Use the fact that relocs are
created it order, so look from the end of relocs created it order, so look from the end of relocs
until we hit one before the copied region. */ until we hit one before the copied region. */
int num_relocs = ssec->reloc->data_offset / sizeof(*rel); unsigned long relofs = ssec->reloc->data_offset;
rel = (ElfW_Rel*)(ssec->reloc->data + ssec->reloc->data_offset); while (relofs >= sizeof(*rel)) {
while (num_relocs--) { relofs -= sizeof(*rel);
rel--; rel = (ElfW_Rel*)(ssec->reloc->data + relofs);
if (rel->r_offset >= esym->st_value + size) if (rel->r_offset >= esym->st_value + size)
continue; continue;
if (rel->r_offset < esym->st_value) if (rel->r_offset < esym->st_value)