函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:fs\binfmt_elf_fdpic.c Create Date:2022-07-29 11:03:58
Last Modify:2020-03-12 14:18:49 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:map a binary by direct mmap() of the individual PT_LOAD segments

函数原型:static int elf_fdpic_map_file_by_direct_mmap(struct elf_fdpic_params *params, struct file *file, struct mm_struct *mm)

返回类型:int

参数:

类型参数名称
struct elf_fdpic_params *params
struct file *file
struct mm_struct *mm
1013  load_addr等于user address at which to map binary
1014  delta_vaddr等于0
1015  dvset等于0
1017  seg等于segs
1020  phdr等于 copy of PT_PHDR table
1021 loop小于e_phnum循环
1023  prot等于0
1025  如果p_type不等于PT_LOAD则继续下一循环
1028  kdebug("[LOAD] va=%lx of=%lx fs=%lx ms=%lx", (unsignedlong)p_vaddr, (unsignedlong)p_offset, (unsignedlong)p_filesz, (unsignedlong)p_memsz)
1035  如果p_flags按位与These constants define the permissions on sections in the programheader, p_flags. prot或等于page can be read
1036  如果p_flags按位与PF_Wprot或等于page can be written
1037  如果p_flags按位与PF_Xprot或等于page can be executed
1039  flags等于Changes are private 按位或ETXTBSY
1040  如果flags按位与T if this object is the executable flags或等于mark it as an executable
1043  maddr等于0
1048  退出
1052  maddr等于p_vaddr
1054  退出
1061  如果非dvset
1062  maddr等于load_addr
1063  delta_vaddr等于p_vaddr
1064  dvset等于1
1065  否则
1069  退出
1073  退出
1075  默认
1076  BUG()
1079  maddr与等于PAGE_MASK
1082  disp等于p_vaddr按位与PAGE_MASK的反
1083  maddr等于vm_mmap(file, maddr, p_memsz + disp, prot, flags, p_offset - disp)
1086  kdebug("mmap[%d] <file> sz=%lx pr=%x fl=%x of=%lx --> %08lx", loop, p_memsz + disp, prot, flags, p_offset - disp, maddr)
1090  如果IS_ERR_VALUE(maddr)则返回:maddr
1093  如果flags按位与PT_LOAD arrangement flags 的值恒等于PT_LOADs should be contiguous load_addr加等于 align the pointer to the (next) page boundary (p_memsz + disp)
1097  core address to which mapped 等于maddrdisp
1098  VMA recorded in file 等于p_vaddr
1099  allocation size recorded in file 等于p_memsz
1102  如果p_offset恒等于0则mapped ELF header user address 等于core address to which mapped
1107  如果prot按位与page can be written disp大于0则
1108  kdebug("clear[%d] ad=%lx sz=%lx", loop, maddr, disp)
1109  如果用户内存块清零则返回:负EFAULT
1111  maddr加等于disp
1119  excess等于p_memszp_filesz
1120  excess1等于PAGE_SIZEmaddrp_filesz按位与PAGE_MASK的反的值
1123  如果excess大于excess1
1124  xaddr等于maddrp_fileszexcess1
1128  xmaddr等于vm_mmap(NULL, xaddr, excess - excess1, prot, flags, 0)
1131  kdebug("mmap[%d] <anon> ad=%lx sz=%lx pr=%x fl=%x of=0 --> %08lx", loop, xaddr, excess - excess1, prot, flags, xmaddr)
1136  如果xmaddr不等于xaddr则返回:负ENOMEM
1140  如果prot按位与page can be written excess1大于0则
1141  kdebug("clear[%d] ad=%lx sz=%lx", loop, maddr + p_filesz, excess1)
1143  如果用户内存块清零则返回:负EFAULT
1157  如果mm
1158  如果p_flags按位与PF_X
1159  如果非start_code
1160  start_code等于maddr
1161  end_code等于maddrp_memsz
1163  否则如果非start_data
1164  start_data等于maddr
1165  end_data等于maddrp_memsz
1169  seg自加
1172  返回:0
调用者
名称描述
elf_fdpic_map_fileload the appropriate binary image (executable or interpreter) into memory* - we assume no MMU is available* - if no other PIC bits are set in params->hdr->e_flags* - we assume that the LOADable segments in the binary are independently relocatable* - we