From 7479a5c21a2b14a135a8f1ad58857b6309d70ff2 Mon Sep 17 00:00:00 2001 From: Aleksi Hannula Date: Sat, 29 Nov 2025 22:28:31 +0200 Subject: [PATCH] elf: Set ph sizes only if ph was allocated --- tccelf.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tccelf.c b/tccelf.c index ef12ba02..c31f18ef 100644 --- a/tccelf.c +++ b/tccelf.c @@ -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 */