[llvm] d82f2a1 - [llvm-objdump] Print the DEBUG type under `--section-headers`.

via llvm-commits llvm-commits at lists.llvm.org
Wed May 26 21:53:59 PDT 2021


Author: Esme-Yi
Date: 2021-05-27T04:53:14Z
New Revision: d82f2a123f9c443911fc40009d2017915b850758

URL: https://github.com/llvm/llvm-project/commit/d82f2a123f9c443911fc40009d2017915b850758
DIFF: https://github.com/llvm/llvm-project/commit/d82f2a123f9c443911fc40009d2017915b850758.diff

LOG: [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

Added: 
    

Modified: 
    llvm/test/tools/llvm-objdump/section-headers.test
    llvm/tools/llvm-objdump/llvm-objdump.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/test/tools/llvm-objdump/section-headers.test b/llvm/test/tools/llvm-objdump/section-headers.test
index 5822459acd79f..f8159be030647 100644
--- a/llvm/test/tools/llvm-objdump/section-headers.test
+++ b/llvm/test/tools/llvm-objdump/section-headers.test
@@ -15,6 +15,8 @@
 # WHITESPACE-NEXT: {{^}}  2 .data         00000000 0000000000000000 0000000000000000 DATA{{$}}
 # WHITESPACE-NEXT: {{^}}  3 .bss          00000000 0000000000000000 0000000000000000 BSS{{$}}
 # WHITESPACE-NEXT: {{^}}  4 .other        00000000 0000000000000000 0000000000000000 {{$}}
+# WHITESPACE-NEXT: {{^}}  5 .debug_abbrev 00000000 0000000000000000 0000000000000000 DEBUG{{$}}
+# WHITESPACE-NEXT: {{^}}  6 .debug_info   00000000 0000000000000000 0000000000000000 DATA, DEBUG{{$}}
 
 # WHITESPACE-NO-LMA:      {{^}}Sections:{{$}}
 # WHITESPACE-NO-LMA-NEXT: {{^}}Idx Name          Size     VMA              Type{{$}}
@@ -23,6 +25,8 @@
 # WHITESPACE-NO-LMA-NEXT: {{^}}  2 .data         00000000 0000000000000000 DATA{{$}}
 # WHITESPACE-NO-LMA-NEXT: {{^}}  3 .bss          00000000 0000000000000000 BSS{{$}}
 # WHITESPACE-NO-LMA-NEXT: {{^}}  4 .other        00000000 0000000000000000 {{$}}
+# WHITESPACE-NO-LMA-NEXT: {{^}}  5 .debug_abbrev 00000000 0000000000000000 DEBUG{{$}}
+# WHITESPACE-NO-LMA-NEXT: {{^}}  6 .debug_info   00000000 0000000000000000 DATA, DEBUG{{$}}
 
 --- !ELF
 FileHeader:
@@ -42,6 +46,11 @@ Sections:
     Flags: [SHF_ALLOC, SHF_WRITE]
   - Name:  .other
     Type:  SHT_REL
+  - Name:  .debug_abbrev
+    Type:  SHT_PROGBITS
+  - Name:  .debug_info
+    Type:  SHT_PROGBITS
+    Flags: [ SHF_WRITE, SHF_ALLOC ]
 
 ## The name field automatically expands past the default 13 columns when a
 ## section name is longer than that.

diff  --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp
index 084c5ed406666..bb02ed4490cf7 100644
--- a/llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -1764,9 +1764,11 @@ void objdump::printSectionHeaders(const ObjectFile *Obj) {
 
     std::string Type = Section.isText() ? "TEXT" : "";
     if (Section.isData())
-      Type += Type.empty() ? "DATA" : " DATA";
+      Type += Type.empty() ? "DATA" : ", DATA";
     if (Section.isBSS())
-      Type += Type.empty() ? "BSS" : " BSS";
+      Type += Type.empty() ? "BSS" : ", BSS";
+    if (Section.isDebugSection())
+      Type += Type.empty() ? "DEBUG" : ", DEBUG";
 
     if (HasLMAColumn)
       outs() << format("%3" PRIu64 " %-*s %08" PRIx64 " ", Idx, NameWidth,


        


More information about the llvm-commits mailing list