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

libs/modlib: Load data using up_textheap_data_address #14600

Merged
merged 1 commit into from
Nov 4, 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
14 changes: 11 additions & 3 deletions libs/libc/modlib/modlib_load.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@

#define _ALIGN_UP(v, a) (((v) + ((a) - 1)) & ~((a) - 1))

#ifdef CONFIG_ARCH_USE_TEXT_HEAP
# define buffer_data_address(p) \
(FAR uint8_t *)up_textheap_data_address((FAR void *)p)
#else
# define buffer_data_address(p) ((FAR uint8_t *)p)
#endif

/****************************************************************************
* Private Functions
****************************************************************************/
Expand Down Expand Up @@ -343,7 +350,8 @@ static inline int modlib_loadfile(FAR struct mod_loadinfo_s *loadinfo)
{
if (phdr->p_flags & PF_X)
{
ret = modlib_read(loadinfo, text, phdr->p_filesz,
ret = modlib_read(loadinfo, buffer_data_address(text),
phdr->p_filesz,
phdr->p_offset);
}
else
Expand Down Expand Up @@ -441,8 +449,8 @@ static inline int modlib_loadfile(FAR struct mod_loadinfo_s *loadinfo)

/* Read the section data from sh_offset to the memory region */

ret = modlib_read(loadinfo, *pptr, shdr->sh_size,
shdr->sh_offset);
ret = modlib_read(loadinfo, buffer_data_address(*pptr),
shdr->sh_size, shdr->sh_offset);
if (ret < 0)
{
berr("ERROR: Failed to read section %d: %d\n", i, ret);
Expand Down
Loading