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

Function elf_map

components/lwp/lwp_elf.c:569–592  ·  view source on GitHub ↗

* @brief Map an ELF segment into the process's address space. * * This function maps a specific ELF segment into the process's virtual memory space. * It handles page alignment, calculates the correct offset, and performs the actual * memory mapping operation. * * @param lwp Pointer to the Light Weight Process (LWP) structure. * @param elf_phdr Pointer to the ELF program header describing t

Source from the content-addressed store, hash-verified

567 * @return 0 on failure.
568 */
569static rt_ubase_t elf_map(struct rt_lwp *lwp, const Elf_Phdr *elf_phdr, int fd, rt_ubase_t addr, size_t prot, size_t flags, rt_ubase_t map_size)
570{
571 rt_ubase_t map_va = 0;
572 rt_ubase_t va_offset;
573 addr = ELF_PAGESTART(addr);
574 va_offset = elf_phdr->p_offset - ELF_PAGEOFFSET(elf_phdr->p_vaddr);
575 rt_ubase_t size;
576
577 if (map_size != 0)
578 {
579 size = map_size;
580 }
581 else
582 {
583 size = elf_phdr->p_memsz + ELF_PAGEOFFSET(elf_phdr->p_vaddr);
584 if (size == 0)
585 {
586 return addr;
587 }
588 }
589 map_va = (rt_ubase_t)file_mmap(lwp, fd, addr, size, prot, flags, va_offset);
590
591 return map_va;
592}
593
594static int elf_zero_bss(struct rt_lwp *lwp, int fd, const Elf_Phdr *phdr, rt_ubase_t bss_start,
595 rt_ubase_t bss_end)

Callers 1

elf_file_mmapFunction · 0.85

Calls 1

file_mmapFunction · 0.85

Tested by

no test coverage detected