elf: Set ph sizes only if ph was allocated

This commit is contained in:
Aleksi Hannula 2025-11-29 22:28:31 +02:00
parent 78e5e690a2
commit 7479a5c21a
No known key found for this signature in database

View File

@ -2419,8 +2419,10 @@ static int layout_sections(TCCState *s1, int *sec_order, struct dyn_inf *d)
if (s->sh_type != SHT_NOBITS)
file_offset += s->sh_size;
ph->p_filesz = file_offset - ph->p_offset;
ph->p_memsz = addr - ph->p_vaddr;
if (ph) {
ph->p_filesz = file_offset - ph->p_offset;
ph->p_memsz = addr - ph->p_vaddr;
}
}
/* Fill other headers */