函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

函数名称:load_flat_file

函数原型:static int load_flat_file(struct linux_binprm *bprm, struct lib_info *libinfo, int id, unsigned long *extra_stack)

返回类型:int

参数:

类型参数名称
struct linux_binprm *bprm
struct lib_info *libinfo
intid
unsigned long *extra_stack
432  __userreloc
433  __userrp
440  hdr等于buf
442  text_len等于ntohl(Offset of data segment from beginning offile )
443  data_len等于ntohl(Offset of end of data segment from beginningof file )减ntohl(Offset of data segment from beginning offile )
444  bss_len等于ntohl(Offset of end of bss segment from beginningof file )减ntohl(Offset of end of data segment from beginningof file )
445  stack_len等于ntohl(Size of stack, in bytes )
446  如果extra_stack
447  stack_len加等于extra_stack
448  extra_stack等于stack_len
450  relocs等于ntohl(Number of relocation records )
451  flags等于ntohl(flags)
452  rev等于ntohl(version (as above) )
453  full_data等于data_lenrelocssizeof(unsignedlong)
455  如果字符串指定长度比较
463  ret等于负ENOEXEC
464  转到:err
467  如果flags按位与utput useful kernel trace for debugging 打印信息("Loading file: %s\n", filename)
495  如果rev不等于FLAT_VERSION
496  打印错误信息("bad flat file version 0x%x (supported 0x%lx)\n", rev, FLAT_VERSION)
498  ret等于负ENOEXEC
499  转到:err
508  如果text_len按位或data_len按位或bss_len按位或stack_len按位或full_data的值右移28位则
509  打印错误信息("bad header\n")
510  ret等于负ENOEXEC
511  转到:err
515  如果flags按位与all but the header is compressed 按位或ly data/relocs are compressed (for XIP) 的值则
516  打印错误信息("Support for ZFLAT executables is not enabled.\n")
517  ret等于负ENOEXEC
518  转到:err
527  rlim等于rlimit(RLIMIT_DATA)
528  如果rlim大于等于RLIM_INFINITYrlim等于0的反
530  如果data_lenbss_len大于rlim
531  ret等于负ENOMEM
532  转到:err
536  如果id恒等于0则
537  ret等于Calling this is the point of no return. None of the failures will be* seen by userspace since either the process is already taking a fatal* signal (via de_thread() or coredump), or will have SEGV raised
538  如果ret则转到:err
542  Change personality of the currently running process.(PER_LINUX_32BIT)
543  setup_new_exec(bprm)
549  extra等于max_t - return maximum of two values, using the specified type*@type: data type to use*@x: first value*@y: second value(unsignedlong, bss_len + stack_len, relocs * sizeof(unsignedlong))
557  如果非IS_ENABLED(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y' or 'm',* 0 otherwise.(CONFIG_MMU)且非flags按位与load program entirely into RAM 按位或all but the header is compressed 的值的值则
562  pr_debug("ROM mapping of file (we hope)\n")
564  textpos等于vm_mmap(file, 0, text_len, page can be read | page can be executed , Changes are private | mark it as an executable , 0)
566  如果非textposIS_ERR_VALUE(textpos)则
567  ret等于textpos
568  如果非textposret等于负ENOMEM
570  打印错误信息("Unable to mmap process text, errno %d\n", ret)
571  转到:err
574  len等于data_lenextra
575  len等于 align the pointer to the (next) page boundary (len)
576  realdatastart等于vm_mmap(NULL, 0, len, page can be read | page can be written | page can be executed , Changes are private , 0)
579  如果realdatastart恒等于0或IS_ERR_VALUE(realdatastart)则
580  ret等于realdatastart
581  如果非realdatastartret等于负ENOMEM
583  打印错误信息("Unable to allocate RAM for process data, errno %d\n", ret)
586  转到:err
588  datapos等于@a is a power of 2 value (realdatastart, User data (data section and bss) needs to be aligned.* We pick 0x20 here because it is the max value elf2flt has always* used in producing FLAT files, and because it seems to be large* enough to make all the gcc alignment related tests happy.)
590  pr_debug("Allocated data+bss+stack (%u bytes): %lx\n", data_len + bss_len + stack_len, datapos)
604  如果IS_ERR_VALUE(result)则
605  ret等于result
606  打印错误信息("Unable to read data+bss, errno %d\n", ret)
609  转到:err
612  reloc__user等于dataposntohl(Offset of relocation records from beginning offile )减text_len
614  memp等于realdatastart
615  memp_size等于len
616  否则
618  len等于text_lendata_lenextra
619  len等于 align the pointer to the (next) page boundary (len)
620  textpos等于vm_mmap(NULL, 0, len, page can be read | page can be executed | page can be written , Changes are private , 0)
623  如果非textposIS_ERR_VALUE(textpos)则
624  ret等于textpos
625  如果非textposret等于负ENOMEM
627  打印错误信息("Unable to allocate RAM for process text/data, errno %d\n", ret)
629  转到:err
632  realdatastart等于textposntohl(Offset of data segment from beginning offile )
633  datapos等于@a is a power of 2 value (realdatastart, User data (data section and bss) needs to be aligned.* We pick 0x20 here because it is the max value elf2flt has always* used in producing FLAT files, and because it seems to be large* enough to make all the gcc alignment related tests happy.)
635  reloc__user等于dataposntohl(Offset of relocation records from beginning offile )减text_len
637  memp等于textpos
638  memp_size等于len
699  result等于read_code(file, textpos, 0, text_len)
705  如果IS_ERR_VALUE(result)则
706  ret等于result
707  打印错误信息("Unable to read code+data+bss, errno %d\n", ret)
709  转到:err
713  start_code等于textpossizeof(structflat_hdr)
714  end_code等于textpostext_len
715  text_len减等于sizeof(structflat_hdr)
718  如果id恒等于0则
719  start_code等于start_code
720  end_code等于end_code
721  start_data等于datapos
722  end_data等于dataposdata_len
730  start_brk等于dataposdata_lenbss_len
731  brk等于start_brk加3按位与3的反
737  如果flags按位与utput useful kernel trace for debugging
738  打印信息("Mapping is %lx, Entry point is %x, data_start is %x\n", textpos, 0x00ffffff & ntohl(Offset of first executable instructionwith text segment from beginning of file ), ntohl(Offset of data segment from beginning offile ))
740  打印信息("%s %s: TEXT=%lx-%lx DATA=%lx-%lx BSS=%lx-%lx\n", id ? "Lib" : "Load", filename, start_code, end_code, datapos, datapos + data_len, datapos + data_len, (datapos + data_len + bss_len + 3) & ~3)
747  Start of text segment 等于start_code
748  Start of data segment 等于datapos
749  End of data segment 等于dataposdata_lenbss_len
750  Length of text segment 等于text_len
751  Has this library been loaded? 等于1
752  Start address for this module 等于0x00ffffff按位与ntohl(Offset of first executable instructionwith text segment from beginning of file )的值加textpos
753  When this one was compiled 等于ntohl(When the program/library was built )
767  如果flags按位与program is PIC with GOT
768  循环
772  如果rp_val恒等于0xffffffff则退出
774  如果rp_val
775  addr等于calc_reloc(rp_val, libinfo, id, 0)
776  如果addr恒等于Relocation incorrect somewhere
777  ret等于负ENOEXEC
778  转到:err
797  如果rev大于While it would be nice to keep this header clean, users of older* tools still need this support in the kernel. So this section is* purely for compatibility with old tool chains.* DO NOT make changes or enhancements to the old format please, just work
798 i小于relocs循环
809  relval等于ntohl(tmp)
811  rp等于calc_reloc(addr, libinfo, id, 1)
812  如果rp恒等于Relocation incorrect somewhere
813  ret等于负ENOEXEC
814  转到:err
822  如果addr不等于0则
827  如果flags按位与program is PIC with GOT 的值恒等于0则
832  addr等于ntohl((__force__be32)addr)
834  addr等于calc_reloc(addr, libinfo, id, 0)
835  如果addr恒等于Relocation incorrect somewhere
836  ret等于负ENOEXEC
837  转到:err
857  flush_icache_range(start_code, end_code)
860  如果用户内存块清零则返回:负EFAULT
866  返回:0
867  err :
868  返回:ret
调用者
名称描述
load_flat_binaryThese are the functions used to load flat style executables and shared* libraries. There is no binary dependent code anywhere else.