Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:fs\binfmt_elf_fdpic.c Create Date:2022-07-28 20:29:04
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name: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

Proto:static int elf_fdpic_map_file(struct elf_fdpic_params *params, struct file *file, struct mm_struct *mm, const char *what)

Type:int

Parameter:

TypeParameterName
struct elf_fdpic_params *params
struct file *file
struct mm_struct *mm
const char *what
745  nloads = 0
746  When loop < e_phnum cycle If p_type == PT_LOAD Then
748  nloads++
750  If nloads == 0 Then Return -ELIBBAD
753  size = size of loadmap + nloads * size of seg
754  loadmap = kzalloc - allocate memory. The memory is set to zero.*@size: how many bytes of memory are required.*@flags: the type of memory to allocate (see kmalloc).
755  If Not loadmap Then Return -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  Case & == PT_LOADs require constant* displacement
769  Case & == PT_LOADs should be contiguous
776  Default
777  ret = map a binary by direct mmap() of the individual PT_LOAD segments
778  If ret < 0 Then Return ret
780  Break
784  If e_entry Then
785  seg = segs
786  When loop > 0 cycle
798  stop = e_phoff
799  stop += e_phnum * sizeof(structelf_phdr)
800  phdr = copy of PT_PHDR table
802  When loop < e_phnum cycle
803  If p_type != PT_LOAD Then Continue
806  If p_offset > e_phoff || p_offset + p_filesz < stop Then Continue
810  seg = segs
811  When loop > 0 cycle
822  Break
826  phdr = copy of PT_PHDR table
827  When loop < e_phnum cycle
828  If p_type != PT_DYNAMIC Then Continue
831  seg = segs
832  When loop > 0 cycle
858  Break
866  nloads = number of segments
867  mseg = segs
868  seg = mseg + 1
869  When loop < nloads cycle
884  mseg++
885  If mseg != seg Then mseg = 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  When loop < number of segments cycle 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  Return 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  Return -ELIBBAD
Caller
NameDescribe
load_elf_fdpic_binaryload an fdpic binary into various bits of memory