1. How to get .text section dump from vmcore?
Using vmlinux, I am able to look at section information as below.
sys.cpu cortexa53
sys.u
d.load.elf vmlinux
y.l.sec
____________address________________|path\section___________________________|acc|init|physical
P:FFFFFF8008080000--FFFFFF8008081FFF|\\vmlinux\.head.text |R-X|L- |
P:FFFFFF8008082000--FFFFFF800888202F|\\vmlinux\.text |R-X|L- |
D:FFFFFF8008883000--FFFFFF8008AE44F7|\\vmlinux\.rodata |R--|L- |
D:FFFFFF8008AE44F8--FFFFFF8008AE453F|\\vmlinux\.eh_frame |R--|L- |
The .text section where kernel code exists is located between 0xFFFFFF8008082000 and 0xFFFFFF800888202F
So I could dump memory content of .text section using below command.
crash64> rd 0xFFFFFF8008082000 -e 0xFFFFFF800888202F -r kernel_code_dump.bin
8388655 bytes copied from 0xffffff8008082000 to kernel_code_dump.bin
2. Code dump using Trace32 with vmlinux
Run below T32 script and be aware that vmlinux is located in the specified directory.
;****************************************************************************
;** _Elf_KernelCodeDumpFromELF_ARM64.cmm
;** This script is to dump kernel-text area memory dump of ARM64 architecture to figure out bit-flip in memory area.
;**
;**
;**
;** when who what, where, why
;** -------------- ------------ ------------------------------------------------------
;** 07/03/2017 austin.kim First version
;****************************************************************************
Reset
Area.Create IO 80. 100.
Area.Select IO
Area IO
;=====specify the output directory of dump file, start =====
DIALOG.DIR D:\kernel_panic\*
ENTRY &output_dir
print "Text Kernel dump from ELF"
&elf_dump_file="&output_dir"+"/kernel_ro_elf.c"
&load_elf_file_name="&output_dir"+"/vmlinux"
printer.FILE &elf_dump_file
printer.OPEN &elf_dump_file
SYS.CPU cortexa53
SYS.UP
// load vmlinux
d.load.elf &load_elf_file_name
// dump text section in the kernel ramdump
gosub procKernelRODump
enddo
; *************************************************************************
; procKernelRODump
;
; Parse Kernel RO dump
;
; *************************************************************************
procKernelRODump:
LOCAL &loc_code_start &loc_code_end
printer.FILE &elf_dump_file
printer.OPEN &elf_dump_file
&loc_code_start=ADDRESS.OFFSET(sYmbol.SECADDRESS(\\vmlinux\.head.text))
&loc_code_end=ADDRESS.OFFSET(sYmbol.SECEND(\\vmlinux\.text))
// dump elf memory
wp.d.dump &loc_code_start--&loc_code_end
printer.CLOSE
RETURN
// end of procKernelRODump
3. Code dump using Trace32 from kernel_code_dump.bin(vmcore) and vmlinux.
sys.cpu cortexa53
sys.u
d.load.binary kernel_code_dump.bin 0xFFFFFF8008082000
d.load.elf vmlinux /nocode
And then run below script.
;****************************************************************************
;** _dumpKernelTextSectionFromRamdump.cmm
;** This script is to dump kernel-text area memory dump to figure out bit-flip in memory area.
;**
;**
;**
;** when who what, where, why
;** -------------- ------------ ------------------------------------------------------
;** 07/03/2017 austin.kim First version
;
; Attention: Please make sure that this cmm script should be used after kernel ramdump is loaded.
;****************************************************************************
Area.Create IO 80. 100.
Area.Select IO
Area IO
;=====specify the output directory of dump file, start =====
DIALOG.DIR D:\kernel_panic\*
ENTRY &output_dir
print "Text Kernel dump from Ramdump"
printer.FILE &elf_dump_file
printer.OPEN &elf_dump_file
&elf_dump_file="&output_dir"+"/kernel_ro_ramdump.c"
// dump text section in the kernel ramdump
gosub procKernelRODump
enddo
; *************************************************************************
; procKernelRODump
;
; Parse Kernel RO dump
;
; *************************************************************************
procKernelRODump:
LOCAL &loc_code_start &loc_code_end
printer.FILE &elf_dump_file
printer.OPEN &elf_dump_file
&loc_code_start=ADDRESS.OFFSET(sYmbol.SECADDRESS(\\vmlinux\.head.text))
&loc_code_end=ADDRESS.OFFSET(sYmbol.SECEND(\\vmlinux\.text))
// dump elf memory
wp.d.dump &loc_code_start--&loc_code_end
printer.CLOSE
RETURN
// end of procKernelRODump
4. Compare kernel_ro_ramdump.c and kernel_ro_elf.c using beyond compare program.
Please be noticed that output files are attached in the
'유용한 디버깅 팁' 카테고리의 다른 글
[리눅스커널] kimage_voffset를 T32으로 디버깅하기 (0) | 2023.04.18 |
---|---|
[crash-utility] kvm(Arm64) vmcore 로딩 + ftrace 추출 (0) | 2023.04.18 |
[리눅스커널] LKDTM(Linux Kernel Dump Test Module) 소개 (0) | 2023.04.18 |
[라즈베리파이] crash-utility 설치(Arm64) (0) | 2023.03.27 |