ld: zero-init data segment before reading contents from executable
This commit is contained in:
@@ -176,6 +176,7 @@ static int map_image(struct elf_image *image)
|
|||||||
if (phdr.p_flags & PF_W) {
|
if (phdr.p_flags & PF_W) {
|
||||||
lseek(image->e_fd, phdr.p_offset, SEEK_SET);
|
lseek(image->e_fd, phdr.p_offset, SEEK_SET);
|
||||||
void *dst = (void *)image->e_base + phdr.p_vaddr;
|
void *dst = (void *)image->e_base + phdr.p_vaddr;
|
||||||
|
memset(dst, 0x0, phdr.p_memsz);
|
||||||
r = read(image->e_fd, dst, phdr.p_filesz);
|
r = read(image->e_fd, dst, phdr.p_filesz);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
return -r;
|
return -r;
|
||||||
|
|||||||
Reference in New Issue
Block a user