函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

函数名称:load 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

函数原型:static int elf_fdpic_map_file(struct elf_fdpic_params *params, struct file *file, struct mm_struct *mm, const char *what)

返回类型:int

参数:

类型参数名称
struct elf_fdpic_params *params
struct file *file
struct mm_struct *mm
const char *what
745  nloads等于0
746 loop小于e_phnum循环如果p_type恒等于PT_LOAD
748  nloads自加
750  如果nloads恒等于0则返回:负ELIBBAD
753  size等于loadmap的长度加nloadsseg的长度
754  loadmap等于分配内存并置零
755  如果非loadmap则返回:负ENOMEM
758  loadmap to be passed to userspace 等于loadmap
760  version of these structures, just in case... 等于ELF32_FDPIC_LOADMAP_VERSION
761  number of segments 等于nloads
763  load_addr等于user address at which to map binary
764  seg等于segs
768  : & == PT_LOADs require constant* displacement
769  : & == PT_LOADs should be contiguous
776  默认
777  ret等于map a binary by direct mmap() of the individual PT_LOAD segments
778  如果ret小于0则返回:ret
780  退出
784  如果e_entry
785  seg等于segs
786 loop大于0循环
798  stop等于e_phoff
799  stop加等于e_phnumsizeof(structelf_phdr)
800  phdr等于 copy of PT_PHDR table
802 loop小于e_phnum循环
803  如果p_type不等于PT_LOAD则继续下一循环
806  如果p_offset大于e_phoffp_offsetp_filesz小于stop则继续下一循环
810  seg等于segs
811 loop大于0循环
822  退出
826  phdr等于 copy of PT_PHDR table
827 loop小于e_phnum循环
828  如果p_type不等于PT_DYNAMIC则继续下一循环
831  seg等于segs
832 loop大于0循环
858  退出
866  nloads等于 number of segments
867  mseg等于segs
868  seg等于mseg加1
869 loop小于nloads循环
873  如果load_addr恒等于core address to which mapped 按位与PAGE_MASK的值则
884  mseg自加
885  如果mseg不等于segmseg等于seg
890  kdebug("Mapped Object [%s]:", what)
891  kdebug("- elfhdr : %lx", mapped ELF header user address )
892  kdebug("- entry : %lx", mapped entry user address )
893  kdebug("- PHDR[] : %lx", mapped PT_PHDR user address )
894  kdebug("- DYNAMIC[]: %lx", mapped PT_DYNAMIC user address )
895  seg等于segs
896 loop小于 number of segments 循环kdebug("- LOAD[%d] : %08x-%08x [va=%x ms=%x]", loop, core address to which mapped , core address to which mapped + allocation size recorded in file - 1, VMA recorded in file , allocation size recorded in file )
902  返回:0
904  dynamic_error :
905  printk - print a kernel message*@fmt: format string* This is printk(). It can be called from any context. We want it to work.* We try to grab the console_lock. If we succeed, it's easy - we log the* output and call the console drivers
907  返回:负ELIBBAD
调用者
名称描述
load_elf_fdpic_binaryload an fdpic binary into various bits of memory