put_elf_reloca might reallocate the section into which we point, so don't remember the pointer just the offset.
Unified · Split
| @@ -8034,10 +8034,10 @@ static void init_putv(init_params *p, CType *type, unsigned long c) · 8033 unmodified lines | ||
| 8034 | 8034 | includes relocations. Use the fact that relocs are |
| 8035 | 8035 | created it order, so look from the end of relocs |
| 8036 | 8036 | until we hit one before the copied region. */ |
| 8037 | − int num_relocs = ssec->reloc->data_offset / sizeof(*rel); | |
| 8038 | − rel = (ElfW_Rel*)(ssec->reloc->data + ssec->reloc->data_offset); | |
| 8039 | − while (num_relocs--) { | |
| 8040 | − rel--; | |
| 8037 | + unsigned long relofs = ssec->reloc->data_offset; | |
| 8038 | + while (relofs >= sizeof(*rel)) { | |
| 8039 | + relofs -= sizeof(*rel); | |
| 8040 | + rel = (ElfW_Rel*)(ssec->reloc->data + relofs); | |
| 8041 | 8041 | if (rel->r_offset >= esym->st_value + size) |
| 8042 | 8042 | continue; |
| 8043 | 8043 | if (rel->r_offset < esym->st_value) |