From 8ed840f79e131ac22aef40610fb6067d964154fc Mon Sep 17 00:00:00 2001 From: Greg Haerr Date: Sat, 30 Nov 2024 16:17:14 -0700 Subject: [PATCH] [kernel] Fix incorrect BSS clearing when BSS size is zero --- elks/fs/exec.c | 3 ++- elks/tools/objtools/objdump86.c | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/elks/fs/exec.c b/elks/fs/exec.c index 8963a3be1..ae8fdda2b 100644 --- a/elks/fs/exec.c +++ b/elks/fs/exec.c @@ -488,7 +488,8 @@ static int execve_aout(struct inode *inode, struct file *filp, char *sptr, size_ /* From this point, exec() will surely succeed */ /* clear bss */ - fmemsetb((char *)(size_t)mh.dseg + base_data, seg_data->base, 0, (size_t)mh.bseg); + if ((size_t)mh.bseg) + fmemsetb((char *)(size_t)mh.dseg + base_data, seg_data->base, 0, (size_t)mh.bseg); /* set data/stack limits and copy argc/argv */ currentp->t_enddata = (size_t)mh.dseg + (size_t)mh.bseg + base_data; diff --git a/elks/tools/objtools/objdump86.c b/elks/tools/objtools/objdump86.c index e69b8e049..94f7bc299 100644 --- a/elks/tools/objtools/objdump86.c +++ b/elks/tools/objtools/objdump86.c @@ -830,8 +830,7 @@ static char * byteord[] = { "LITTLE_ENDIAN", "(2143)","(3412)","BIG_ENDIAN" }; if( h_flgs & 0x80 ) printf(" A_TOVLY"); printf("\n"); - if( header[5] ) - printf("a_entry = 0x%08lx\n", header[5]); + printf("a_entry = 0x%08lx\n", header[5]); printf("a_total = 0x%08lx\n", header[6]); if( header[7] ) printf("a_syms = 0x%08lx\n", header[7]);