Skip to content

Commit d82f2a1

Browse files
author
Esme-Yi
committed
[llvm-objdump] Print the DEBUG type under --section-headers.
Summary: Under the option --section-headers, we can only print the section types of TEXT, DATA, and BSS for now. This patch adds the DEBUG type. Reviewed By: jhenderson, Higuoxing Differential Revision: https://reviews.llvm.org/D102603
1 parent cc3db8d commit d82f2a1

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

llvm/test/tools/llvm-objdump/section-headers.test

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# WHITESPACE-NEXT: {{^}} 2 .data 00000000 0000000000000000 0000000000000000 DATA{{$}}
1616
# WHITESPACE-NEXT: {{^}} 3 .bss 00000000 0000000000000000 0000000000000000 BSS{{$}}
1717
# WHITESPACE-NEXT: {{^}} 4 .other 00000000 0000000000000000 0000000000000000 {{$}}
18+
# WHITESPACE-NEXT: {{^}} 5 .debug_abbrev 00000000 0000000000000000 0000000000000000 DEBUG{{$}}
19+
# WHITESPACE-NEXT: {{^}} 6 .debug_info 00000000 0000000000000000 0000000000000000 DATA, DEBUG{{$}}
1820

1921
# WHITESPACE-NO-LMA: {{^}}Sections:{{$}}
2022
# WHITESPACE-NO-LMA-NEXT: {{^}}Idx Name Size VMA Type{{$}}
@@ -23,6 +25,8 @@
2325
# WHITESPACE-NO-LMA-NEXT: {{^}} 2 .data 00000000 0000000000000000 DATA{{$}}
2426
# WHITESPACE-NO-LMA-NEXT: {{^}} 3 .bss 00000000 0000000000000000 BSS{{$}}
2527
# WHITESPACE-NO-LMA-NEXT: {{^}} 4 .other 00000000 0000000000000000 {{$}}
28+
# WHITESPACE-NO-LMA-NEXT: {{^}} 5 .debug_abbrev 00000000 0000000000000000 DEBUG{{$}}
29+
# WHITESPACE-NO-LMA-NEXT: {{^}} 6 .debug_info 00000000 0000000000000000 DATA, DEBUG{{$}}
2630

2731
--- !ELF
2832
FileHeader:
@@ -42,6 +46,11 @@ Sections:
4246
Flags: [SHF_ALLOC, SHF_WRITE]
4347
- Name: .other
4448
Type: SHT_REL
49+
- Name: .debug_abbrev
50+
Type: SHT_PROGBITS
51+
- Name: .debug_info
52+
Type: SHT_PROGBITS
53+
Flags: [ SHF_WRITE, SHF_ALLOC ]
4554

4655
## The name field automatically expands past the default 13 columns when a
4756
## section name is longer than that.

llvm/tools/llvm-objdump/llvm-objdump.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1764,9 +1764,11 @@ void objdump::printSectionHeaders(const ObjectFile *Obj) {
17641764

17651765
std::string Type = Section.isText() ? "TEXT" : "";
17661766
if (Section.isData())
1767-
Type += Type.empty() ? "DATA" : " DATA";
1767+
Type += Type.empty() ? "DATA" : ", DATA";
17681768
if (Section.isBSS())
1769-
Type += Type.empty() ? "BSS" : " BSS";
1769+
Type += Type.empty() ? "BSS" : ", BSS";
1770+
if (Section.isDebugSection())
1771+
Type += Type.empty() ? "DEBUG" : ", DEBUG";
17701772

17711773
if (HasLMAColumn)
17721774
outs() << format("%3" PRIu64 " %-*s %08" PRIx64 " ", Idx, NameWidth,

0 commit comments

Comments
 (0)