Skip to content

Commit 7479a5c

Browse files
committed
elf: Set ph sizes only if ph was allocated
1 parent 78e5e69 commit 7479a5c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tccelf.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2419,8 +2419,10 @@ static int layout_sections(TCCState *s1, int *sec_order, struct dyn_inf *d)
24192419
if (s->sh_type != SHT_NOBITS)
24202420
file_offset += s->sh_size;
24212421

2422-
ph->p_filesz = file_offset - ph->p_offset;
2423-
ph->p_memsz = addr - ph->p_vaddr;
2422+
if (ph) {
2423+
ph->p_filesz = file_offset - ph->p_offset;
2424+
ph->p_memsz = addr - ph->p_vaddr;
2425+
}
24242426
}
24252427

24262428
/* Fill other headers */

0 commit comments

Comments
 (0)