Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:crash_prepare_elf64_headers

Proto:int crash_prepare_elf64_headers(struct crash_mem *mem, int kernel_map, void **addr, unsigned long *sz)

Type:int

Parameter:

TypeParameterName
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_phdr * sizeof(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  If Not buf Then Return -ENOMEM
1271  ehdr = buf
1272  phdr = ehdr + 1
1273  No 3D Now!(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  for_each_present_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  If kernel_map Then
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 = _end - 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
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  When i < nr_ranges cycle
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 = mend - mstart + 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  Return 0