OSDN Git Service

llvm-readobj: Try the DWARF CFI dumper on all machines.
authorPeter Collingbourne <peter@pcc.me.uk>
Thu, 28 Feb 2019 22:42:55 +0000 (22:42 +0000)
committerPeter Collingbourne <peter@pcc.me.uk>
Thu, 28 Feb 2019 22:42:55 +0000 (22:42 +0000)
There's no reason to limit the DWARF CFI dumper to EM_386 and EM_X86_64;
ELF files could contain DWARF CFI on almost any platform (even 32-bit ARM;
NetBSD uses DWARF CFI on that platform). So start using the DWARF CFI dumper
unconditionally so that we can dump .eh_frame sections on the remaining ELF
platforms as well as in NetBSD binaries.

Differential Revision: https://reviews.llvm.org/D58761

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355151 91177308-0d34-0410-b5e6-96231b3b80d8

test/tools/llvm-readobj/AArch64/dwarf-cfi.s [new file with mode: 0644]
test/tools/llvm-readobj/AArch64/lit.local.cfg [new file with mode: 0644]
test/tools/llvm-readobj/ARM/dwarf-cfi.s [new file with mode: 0644]
tools/llvm-readobj/ELFDumper.cpp

diff --git a/test/tools/llvm-readobj/AArch64/dwarf-cfi.s b/test/tools/llvm-readobj/AArch64/dwarf-cfi.s
new file mode 100644 (file)
index 0000000..f129546
--- /dev/null
@@ -0,0 +1,25 @@
+# RUN: llvm-mc -triple arm64-linux -filetype obj -o - %s | llvm-readobj -u | FileCheck %s
+
+# CHECK:      [0x0] CIE length=16
+# CHECK-NEXT:   version: 1
+# CHECK-NEXT:   augmentation: zR
+# CHECK-NEXT:   code_alignment_factor: 1
+# CHECK-NEXT:   data_alignment_factor: -4
+# CHECK-NEXT:   return_address_register: 30
+
+# CHECK:        Program:
+# CHECK-NEXT: DW_CFA_def_cfa: reg31 +0
+
+# CHECK:      [0x14] FDE length=16 cie=[0x0]
+# CHECK-NEXT:   initial_location: 0x0
+# CHECK-NEXT:   address_range: 0x4 (end : 0x4)
+
+# CHECK:        Program:
+# CHECK-NEXT: DW_CFA_nop:
+# CHECK-NEXT: DW_CFA_nop:
+# CHECK-NEXT: DW_CFA_nop:
+
+foo:
+.cfi_startproc
+ret
+.cfi_endproc
diff --git a/test/tools/llvm-readobj/AArch64/lit.local.cfg b/test/tools/llvm-readobj/AArch64/lit.local.cfg
new file mode 100644 (file)
index 0000000..cec29af
--- /dev/null
@@ -0,0 +1,3 @@
+if not 'AArch64' in config.root.targets:
+    config.unsupported = True
+
diff --git a/test/tools/llvm-readobj/ARM/dwarf-cfi.s b/test/tools/llvm-readobj/ARM/dwarf-cfi.s
new file mode 100644 (file)
index 0000000..36d71d6
--- /dev/null
@@ -0,0 +1,27 @@
+# RUN: llvm-mc -triple arm-linux -filetype obj -o - %s | llvm-readobj -u | FileCheck %s
+
+# CHECK:      [0x0] CIE length=16
+# CHECK-NEXT:   version: 1
+# CHECK-NEXT:   augmentation: zR
+# CHECK-NEXT:   code_alignment_factor: 1
+# CHECK-NEXT:   data_alignment_factor: -4
+# CHECK-NEXT:   return_address_register: 14
+
+# CHECK:        Program:
+# CHECK-NEXT: DW_CFA_def_cfa: reg13 +0
+
+# CHECK:      [0x14] FDE length=16 cie=[0x0]
+# CHECK-NEXT:   initial_location: 0x0
+# CHECK-NEXT:   address_range: 0x4 (end : 0x4)
+
+# CHECK:        Program:
+# CHECK-NEXT: DW_CFA_nop:
+# CHECK-NEXT: DW_CFA_nop:
+# CHECK-NEXT: DW_CFA_nop:
+
+.cpu cortex-a8
+
+foo:
+.cfi_startproc
+bx lr
+.cfi_endproc
index 410ab3f..6428e99 100644 (file)
@@ -1890,12 +1890,8 @@ void ELFDumper<ELFT>::printValue(uint64_t Type, uint64_t Value) {
 
 template<class ELFT>
 void ELFDumper<ELFT>::printUnwindInfo() {
-  const unsigned Machine = ObjF->getELFFile()->getHeader()->e_machine;
-  if (Machine == EM_386 || Machine == EM_X86_64) {
-    DwarfCFIEH::PrinterContext<ELFT> Ctx(W, ObjF);
-    return Ctx.printUnwindInformation();
-  }
-  W.startLine() << "UnwindInfo not implemented.\n";
+  DwarfCFIEH::PrinterContext<ELFT> Ctx(W, ObjF);
+  Ctx.printUnwindInformation();
 }
 
 namespace {
@@ -1905,9 +1901,10 @@ template <> void ELFDumper<ELF32LE>::printUnwindInfo() {
   const unsigned Machine = Obj->getHeader()->e_machine;
   if (Machine == EM_ARM) {
     ARM::EHABI::PrinterContext<ELF32LE> Ctx(W, Obj, DotSymtabSec);
-    return Ctx.PrintUnwindInformation();
+    Ctx.PrintUnwindInformation();
   }
-  W.startLine() << "UnwindInfo not implemented.\n";
+  DwarfCFIEH::PrinterContext<ELF32LE> Ctx(W, ObjF);
+  Ctx.printUnwindInformation();
 }
 
 } // end anonymous namespace