ld: zero-init data segment before reading contents from executable

This commit is contained in:
2026-04-20 22:14:11 +01:00
parent f5c3d885ec
commit 19683dbaa8
+1
View File
@@ -176,6 +176,7 @@ static int map_image(struct elf_image *image)
if (phdr.p_flags & PF_W) {
lseek(image->e_fd, phdr.p_offset, SEEK_SET);
void *dst = (void *)image->e_base + phdr.p_vaddr;
memset(dst, 0x0, phdr.p_memsz);
r = read(image->e_fd, dst, phdr.p_filesz);
if (r < 0) {
return -r;