mirror of
https://github.com/apache/nuttx.git
synced 2025-12-06 17:23:49 +08:00
binfmt/elf: Support to load ET_EXEC in flat mode
Signed-off-by: wanggang26 <wanggang26@xiaomi.com>
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user