| Function report | 
| 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 activity | Download SCCT | Chinese | 
Name:map a binary by direct mmap() of the individual PT_LOAD segments
Proto:static int elf_fdpic_map_file_by_direct_mmap(struct elf_fdpic_params *params, struct file *file, struct mm_struct *mm)
Type:int
Parameter:
| Type | Parameter | Name | 
|---|---|---|
| struct elf_fdpic_params * | params | |
| struct file * | file | |
| struct mm_struct * | mm | 
| 1014 | delta_vaddr = 0 | 
| 1015 | dvset = 0 | 
| 1020 | phdr = copy of PT_PHDR table | 
| 1023 | prot = 0 | 
| 1028 | kdebug("[LOAD] va=%lx of=%lx fs=%lx ms=%lx", (unsignedlong)p_vaddr, (unsignedlong)p_offset, (unsignedlong)p_filesz, (unsignedlong)p_memsz) | 
| 1035 | If p_flags & These constants define the permissions on sections in the programheader, p_flags. Then prot |= page can be read | 
| 1036 | If p_flags & PF_W Then prot |= page can be written | 
| 1037 | If p_flags & PF_X Then prot |= page can be executed | 
| 1039 | flags = Changes are private | ETXTBSY | 
| 1040 | If flags & T if this object is the executable Then flags |= mark it as an executable | 
| 1043 | maddr = 0 | 
| 1046 | Case & == PT_LOADs can be put anywhere | 
| 1048 | Break | 
| 1050 | Case & == PT_LOAD.vaddr must be honoured | 
| 1056 | Case & == PT_LOADs require constant* displacement | 
| 1061 | If Not dvset Then | 
| 1065 | Else | 
| 1066 | maddr = load_addr + p_vaddr - delta_vaddr | 
| 1067 | flags |= Interpret addr exactly | 
| 1069 | Break | 
| 1071 | Case & == PT_LOADs should be contiguous | 
| 1073 | Break | 
| 1075 | Default | 
| 1076 | BUG() | 
| 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 | If IS_ERR_VALUE(maddr) Then Return maddr | 
| 1093 | If (flags & PT_LOAD arrangement flags ) == PT_LOADs should be contiguous Then load_addr += align the pointer to the (next) page boundary (p_memsz + disp) | 
| 1097 | core address to which mapped = maddr + disp | 
| 1098 | VMA recorded in file = p_vaddr | 
| 1102 | If p_offset == 0 Then mapped ELF header user address = core address to which mapped | 
| 1107 | If prot & page can be written && disp > 0 Then | 
| 1127 | flags |= Interpret addr exactly | don't use a file | 
| 1140 | If prot & page can be written && excess1 > 0 Then | 
| 1157 | If mm Then | 
| 1159 | If Not start_code Then | 
| 1160 | start_code = maddr | 
| 1163 | Else if Not start_data Then | 
| 1164 | start_data = maddr | 
| 1169 | seg++ | 
| 1172 | Return 0 | 
| Name | Describe | 
|---|---|
| elf_fdpic_map_file | 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 | 
| Source code conversion tool public plug-in interface | X | 
|---|---|
| Support c/c++/esqlc/java Oracle/Informix/Mysql Plug-in can realize: logical Report Code generation and batch code conversion |