Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[llvm-objdump] Create fake sections for a ELF core file
The linux perf tools use /proc/kcore for disassembly kernel functions. Actually it copies the relevant parts to a temp file and then pass it to objdump. But it doesn't have section headers so llvm-objdump cannot handle it. Let's create fake section headers for the program headers. It'd have a single section for each segment to cover the entire range. And for this purpose we can consider only executable code segments. With this change, I can see the following command shows proper outputs. perf annotate --stdio --objdump=/path/to/llvm-objdump Differential Revision: https://reviews.llvm.org/D128705
- Loading branch information
Showing
6 changed files
with
112 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
; RUN: llvm-objdump -h %p/Inputs/no-sections.elf-x86-64 \ | ||
; RUN: | FileCheck %s | ||
|
||
; CHECK: Sections: | ||
; CHECK: Idx Name Size VMA Type | ||
; CHECK-NOT: {{.}} | ||
; CHECK: Sections: | ||
; CHECK-NEXT: Idx Name Size VMA Type | ||
; CHECK-NEXT: 0 000006ec 0000000000400000 TEXT | ||
; CHECK-NEXT: 1 00000000 0000000000000000 TEXT | ||
; CHECK-NOT: {{.}} |
51 changes: 51 additions & 0 deletions
51
llvm/test/tools/llvm-objdump/X86/disassemble-no-section.test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
## This test checks -d disassembles an ELF file without section headers. | ||
## Such files include kcore files extracted by linux perf tools, or | ||
## executables with section headers stripped by e.g. | ||
## llvm-strip --strip-sections. | ||
|
||
# RUN: yaml2obj %s -o %t | ||
# RUN: llvm-objdump -d %t | FileCheck %s | ||
|
||
# CHECK: Disassembly of section : | ||
# CHECK-EMPTY: | ||
# CHECK-NEXT: <>: | ||
# CHECK-NEXT: 55 pushq %rbp | ||
# CHECK-NEXT: 48 89 e5 movq %rsp, %rbp | ||
# CHECK-NEXT: 0f 1f 40 00 nopl (%rax) | ||
# CHECK-NEXT: 5d popq %rbp | ||
# CHECK-NEXT: c3 retq | ||
|
||
## Check disassembly with an address range. | ||
# RUN: llvm-objdump -d --start-address=0xffffffff00000000 \ | ||
# RUN: --stop-address=0xffffffff00000004 %t 2>&1 | \ | ||
# RUN: FileCheck %s --check-prefix RANGE | ||
|
||
# RANGE: no section overlaps the range | ||
# RANGE-EMPTY: | ||
# RANGE-NEXT: Disassembly of section : | ||
# RANGE-EMPTY: | ||
# RANGE-NEXT: <>: | ||
# RANGE-NEXT: 55 pushq %rbp | ||
# RANGE-NEXT: 48 89 e5 movq %rsp, %rbp | ||
# RANGE-EMPTY: | ||
|
||
!ELF | ||
FileHeader: | ||
Class: ELFCLASS64 | ||
Data: ELFDATA2LSB | ||
Type: ET_CORE | ||
Machine: EM_X86_64 | ||
Sections: | ||
- Type: SectionHeaderTable | ||
NoHeaders: true | ||
- Type: Fill | ||
Name: code | ||
Pattern: "554889E50F1F40005DC3" | ||
Size: 10 | ||
Offset: 0x1000 | ||
ProgramHeaders: | ||
- Type: PT_LOAD | ||
Flags: [ PF_X ] | ||
VAddr: 0xFFFFFFFF00000000 | ||
FirstSec: code | ||
LastSec: code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters