binfmt/elf: Support to load ET_EXEC in flat mode

Signed-off-by: wanggang26 <wanggang26@xiaomi.com>
This commit is contained in:
wanggang26
2023-06-27 18:40:33 +08:00
committed by Xiang Xiao
parent dfa6a43744
commit abc1cade35
2 changed files with 23 additions and 0 deletions

View File

@@ -137,6 +137,11 @@ errout_with_addrenv:
addrenv_drop(loadinfo->addrenv, false);
return ret;
#else
if (loadinfo->ehdr.e_type == ET_EXEC)
{
return OK;
}
/* Allocate memory to hold the ELF image */
#if defined(CONFIG_ARCH_USE_TEXT_HEAP)

View File

@@ -179,6 +179,24 @@ static inline int elf_loadfile(FAR struct elf_loadinfo_s *loadinfo)
pptr = &text;
}
if (*pptr == NULL)
{
if (shdr->sh_type != SHT_NOBITS)
{
/* Read the section data from sh_offset to specified region */
ret = elf_read(loadinfo, (FAR uint8_t *)shdr->sh_addr,
shdr->sh_size, shdr->sh_offset);
if (ret < 0)
{
berr("ERROR: Failed to read section %d: %d\n", i, ret);
return ret;
}
}
continue;
}
*pptr = (FAR uint8_t *)_ALIGN_UP((uintptr_t)*pptr, shdr->sh_addralign);
/* SHT_NOBITS indicates that there is no data in the file for the