From 1329c29ecdb3a49d7b08270d793575ba71d81ddd Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 12 Sep 2014 10:32:23 -0600 Subject: [PATCH] ELF: Critical bugfix.. BSS was not being cleared --- binfmt/libelf/libelf_load.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/binfmt/libelf/libelf_load.c b/binfmt/libelf/libelf_load.c index 75ecb30fc71..11d054a945f 100644 --- a/binfmt/libelf/libelf_load.c +++ b/binfmt/libelf/libelf_load.c @@ -43,6 +43,7 @@ #include #include +#include #include #include #include @@ -200,6 +201,15 @@ static inline int elf_loadfile(FAR struct elf_loadinfo_s *loadinfo) } } + /* If there is no data in an allocated section, then the allocated + * section must be cleared. + */ + + else + { + memset(*pptr, 0, shdr->sh_size); + } + /* Update sh_addr to point to copy in memory */ bvdbg("%d. %08lx->%08lx\n", i,