Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

binfmt/elf_loadfile: Set sh_addr even if SHF_ALLOC == 0 #270

Merged
merged 1 commit into from
Aug 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions binfmt/libelf/libelf_load.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,6 @@ static inline int elf_loadfile(FAR struct elf_loadinfo_s *loadinfo)
{
FAR Elf_Shdr *shdr = &loadinfo->shdr[i];

/* SHF_ALLOC indicates that the section requires memory during
* execution.
*/

if ((shdr->sh_flags & SHF_ALLOC) == 0)
{
continue;
}

/* SHF_WRITE indicates that the section address space is write-
* able
*/
Expand All @@ -209,6 +200,18 @@ static inline int elf_loadfile(FAR struct elf_loadinfo_s *loadinfo)
pptr = &text;
}

/* SHF_ALLOC indicates that the section requires memory during
* execution.
*/

if ((shdr->sh_flags & SHF_ALLOC) == 0)
{
/* Set the VMA regardless, some relocations might depend on this */

shdr->sh_addr = (uintptr_t)*pptr;
continue;
}

if (*pptr == NULL)
{
if (shdr->sh_type != SHT_NOBITS)
Expand Down
Loading