函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\kexec_file.c Create Date:2022-07-27 12:06:10
Last Modify:2020-03-12 14:18:49 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:crash_prepare_elf64_headers

函数原型:int crash_prepare_elf64_headers(struct crash_mem *mem, int kernel_map, void **addr, unsigned long *sz)

返回类型:int

参数:

类型参数名称
struct crash_mem *mem
intkernel_map
void **addr
unsigned long *sz
1245  nr_cpus等于num_possible_cpus()
1252  nr_phdr等于nr_cpus加1
1253  nr_phdr加等于nr_ranges
1263  nr_phdr自加
1264  elf_sz等于sizeof(Elf64_Ehdr)加nr_phdrsizeof(Elf64_Phdr)
1265  elf_sz等于@a is a power of 2 value (elf_sz, Alignment required for elf header segment )
1267  buf等于vzalloc(elf_sz)
1268  如果非buf则返回:负ENOMEM
1271  ehdr等于buf
1272  phdr等于ehdr加1
1273  内存复制(e_ident, ELFMAG, SELFMAG)
1274  ELF "magic number" [EI_CLASS]等于ELFCLASS64
1275  ELF "magic number" [EI_DATA]等于ELFDATA2LSB
1276  ELF "magic number" [EI_VERSION]等于EV_CURRENT
1277  ELF "magic number" [EI_OSABI]等于ELF_OSABI
1278  memset( ELF "magic number" + EI_PAD, 0, EI_NIDENT - EI_PAD)
1279  e_type等于ET_CORE
1280  e_machine等于ELF_ARCH
1281  e_version等于EV_CURRENT
1282  Program header table file offset 等于sizeof(Elf64_Ehdr)
1283  e_ehsize等于sizeof(Elf64_Ehdr)
1284  e_phentsize等于sizeof(Elf64_Phdr)
1287  遍历现有CPU(cpu)
1288  p_type等于PT_NOTE
1289  notes_addr等于per_cpu_ptr_to_phys(per_cpu_ptr(Per cpu memory for storing cpu states in case of system crash. , cpu))
1290  Segment file offset 等于 Segment physical address 等于notes_addr
1291  Segment size in file 等于 Segment size in memory 等于sizeof(note_buf_t)
1292  e_phnum自加
1293  phdr自加
1297  p_type等于PT_NOTE
1298  Segment file offset 等于 Segment physical address 等于paddr_vmcoreinfo_note()
1299  Segment size in file 等于 Segment size in memory 等于VMCOREINFO_NOTE_SIZE
1300  e_phnum自加
1301  phdr自加
1304  如果kernel_map
1305  p_type等于PT_LOAD
1306  p_flags等于These constants define the permissions on sections in the programheader, p_flags. 按位或PF_W按位或PF_X
1307  Segment virtual address 等于Usage guidelines:* _text, _data: architecture specific, don't use them in arch-independent code* [_stext, _etext]: contains .text.* sections, may also contain .rodata.** and/or .init.* sections* [_sdata, _edata]: contains
1308  Segment size in file 等于 Segment size in memory 等于_endUsage guidelines:* _text, _data: architecture specific, don't use them in arch-independent code* [_stext, _etext]: contains .text.* sections, may also contain .rodata.** and/or .init.* sections* [_sdata, _edata]: contains
1309  Segment file offset 等于 Segment physical address 等于We need __phys_reloc_hide() here because gcc may assume that there is no* overflow during __pa() calculation and can optimize it unexpectedly.* Newer versions of gcc provide -fno-strict-overflow switch to handle this* case properly(Usage guidelines:* _text, _data: architecture specific, don't use them in arch-independent code* [_stext, _etext]: contains .text.* sections, may also contain .rodata.** and/or .init.* sections* [_sdata, _edata]: contains )
1310  e_phnum自加
1311  phdr自加
1315 i小于nr_ranges循环
1316  mstart等于start
1317  mend等于end
1319  p_type等于PT_LOAD
1320  p_flags等于These constants define the permissions on sections in the programheader, p_flags. 按位或PF_W按位或PF_X
1321  Segment file offset 等于mstart
1323  Segment physical address 等于mstart
1324  Segment virtual address 等于__va(mstart)
1325  Segment size in file 等于 Segment size in memory 等于mendmstart加1
1326  Segment alignment, file & memory 等于0
1327  e_phnum自加
1328  phdr自加
1329  pr_debug("Crash PT_LOAD elf header. phdr=%p vaddr=0x%llx, paddr=0x%llx, sz=0x%llx e_phnum=%d p_offset=0x%llx\n", phdr, Segment virtual address , Segment physical address , Segment size in file , e_phnum, Segment file offset )
1334  addr等于buf
1335  sz等于elf_sz
1336  返回:0
调用者
名称描述
prepare_elf_headersPrepare elf headers. Return addr and size