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
created it order, so look from the end of relocs
until we hit one before the copied region. */
int num_relocs = ssec->reloc->data_offset / sizeof(*rel);
rel = (ElfW_Rel*)(ssec->reloc->data + ssec->reloc->data_offset);
while (num_relocs--) {
rel--;
unsigned long relofs = ssec->reloc->data_offset;
while (relofs >= sizeof(*rel)) {
relofs -= sizeof(*rel);
rel = (ElfW_Rel*)(ssec->reloc->data + relofs);
if (rel->r_offset >= esym->st_value + size)
continue;
if (rel->r_offset < esym->st_value)