Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:This is much more generalized than the library routine read function,so we keep this separate. Technically the library read functionis only provided so that we can read a.out libraries that havean ELF header

Proto:static unsigned long load_elf_interp(struct elf64_hdr *interp_elf_ex, struct file *interpreter, unsigned long no_base, struct elf64_phdr *interp_elf_phdata)

Type:unsigned long

Parameter:

TypeParameterName
struct elf64_hdr *interp_elf_ex
struct file *interpreter
unsigned longno_base
struct elf64_phdr *interp_elf_phdata
561  load_addr = 0
562  load_addr_set = 0
563  last_bss = 0 , elf_bss = 0
564  bss_prot = 0
565  error = ~0UL
570  If e_type != ET_EXEC && e_type != ET_DYN Then Go to out
573  If Not elf_check_arch(interp_elf_ex) || That's for binfmt_elf_fdpic to deal with (interp_elf_ex) Then Go to out
576  If Not mmap Then Go to out
579  total_size = total_mapping_size(interp_elf_phdata, e_phnum)
581  If Not total_size Then
582  error = -EINVAL
583  Go to out
586  eppnt = interp_elf_phdata
587  When i < e_phnum cycle
588  If p_type == PT_LOAD Then
591  vaddr = 0
597  Else if no_base && e_type == ET_DYN Then load_addr = -vaddr
602  total_size = 0
603  error = map_addr
604  If BAD_ADDR(map_addr) Then Go to out
607  If Not load_addr_set && e_type == ET_DYN Then
623  error = -ENOMEM
624  Go to out
632  If k > elf_bss Then elf_bss = k
640  If k > last_bss Then
641  last_bss = k
642  bss_prot = elf_prot
652  If We need to explicitly zero any fractional pagesafter the data section (i.e. bss). This wouldcontain the junk from the file that should notbe in memory Then
653  error = -EFAULT
654  Go to out
661  elf_bss = ELF_PAGEALIGN(elf_bss)
662  last_bss = ELF_PAGEALIGN(last_bss)
664  If last_bss > elf_bss Then
665  error = vm_brk_flags(elf_bss, last_bss - elf_bss, bss_prot & page can be executed ? VM_EXEC : 0)
667  If error Then Go to out
671  error = load_addr
672  out :
673  Return error
Caller
NameDescribe
load_elf_binary