MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / total_mapping_size

Function total_mapping_size

components/lwp/lwp_elf.c:526–549  ·  view source on GitHub ↗

* @brief Calculate the total size required to map all loadable ELF segments. * * @param elf_info Pointer to the ELF file information structure. * @return 0 on success, -1 if no loadable segments are found. */

Source from the content-addressed store, hash-verified

524 * @return 0 on success, -1 if no loadable segments are found.
525 */
526static int total_mapping_size(elf_info_t *elf_info)
527{
528 int i;
529 int first_idx = -1;
530 int last_idx = -1;
531
532 for (i = 0; i < elf_info->ehdr.e_phnum; i++)
533 {
534 if (elf_info->phdr[i].p_type == PT_LOAD)
535 {
536 last_idx = i;
537 if (first_idx == -1)
538 first_idx = i;
539 }
540 }
541
542 if (first_idx == -1)
543 return -1;
544
545 elf_info->map_size = elf_info->phdr[last_idx].p_vaddr + elf_info->phdr[last_idx].p_memsz -
546 ELF_PAGESTART(elf_info->phdr[first_idx].p_vaddr);
547
548 return 0;
549}
550
551/**
552 * @brief Map an ELF segment into the process's address space.

Callers 2

load_elf_interpFunction · 0.85
elf_load_segmentFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected