llvm-readobj: Try the DWARF CFI dumper on all machines.

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

llvm-svn: 355151
This commit is contained in:
Peter Collingbourne 2019-02-28 22:42:55 +00:00
parent b7812652c6
commit ac136cd18c
4 changed files with 60 additions and 8 deletions

View File

@ -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

View File

@ -0,0 +1,3 @@
if not 'AArch64' in config.root.targets:
config.unsupported = True

View File

@ -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

View 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