[PATCH] D53264: [ARM64] [Windows] Add unwind support to llvm-readobj

Sanjin Sijaric via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 14 20:02:50 PDT 2018


ssijaric created this revision.
ssijaric added reviewers: rnk, mstorsjo, thegameg, majnemer.
Herald added a reviewer: javed.absar.
Herald added subscribers: kristina, chrib, kristof.beyls.

This patch adds support for dumping the unwind info from ARM64 COFF object files.  This is required so that we can add test cases to  https://reviews.llvm.org/D50166 (MCLayer support for ARM64 exception handling).  Only unpacked unwind data is supported, as that is what https://reviews.llvm.org/D50166 currently supports.

I tested this with objects produced by both cl.exe and clang that includes the Windows ARM64 exception handling patches.  The output that is produced looks like:

Case 1: single epilogue
File: test.obj
Format: COFF-ARM64
Arch: aarch64
AddressSize: 64bit
UnwindInformation [

  RuntimeFunction {
    Function: $LN6 (0x0)
    ExceptionRecord: $unwind$?func@@YAHH at Z (0x0)
    ExceptionData {
      FunctionLength: 340
      Version: 0
      ExceptionData: No
      EpiloguePacked: Yes
      EpilogueOffset: 15
      ByteCodeLength: 28
      Prologue [
        0xe002dac8          ; sub sp, #2993280
        0xe3                ; nop
        0xe3                ; nop
        0xe3                ; nop
        0xd885              ; stp d10, d11, [sp, #40]
        0xd803              ; stp d8, d9, [sp, #24]
        0xd2c2              ; str x30, [sp, #16]
        0x28                ; stp x19, x20, [sp, #-64]!
        0xe4                ; end
      ]
      Epilogue [
        0xe002dac8          ; add sp, #2993280
        0xd885              ; ldp d10, d11, [sp, #40]
        0xd803              ; ldp d8, d9, [sp, #24]
        0xd2c2              ; ldr x30, [sp, #16]
        0x28                ; ldp x19, x20, [sp], #64
        0xe4                ; end
      ]
    }
  }

]

Case 2: multiple epilogues
File: test1.obj
Format: COFF-ARM64
Arch: aarch64
AddressSize: 64bit
UnwindInformation [

  RuntimeFunction {
    Function: $LN6 (0x0)
    ExceptionRecord: $unwind$?func@@YAHH at Z (0x0)
    ExceptionData {
      FunctionLength: 72
      Version: 0
      ExceptionData: No
      EpiloguePacked: No
      EpilogueScopes: 2
      ByteCodeLength: 8
      Prologue [
        0x1f                ; sub sp, #496
        0xd600              ; stp x19, lr, [sp, #0]
        0x01                ; sub sp, #16
        0xe4                ; end
      ]
      EpilogueScopes [
        EpilogueScope {
          StartOffset: 8
          EpilogueStartIndex: 0
          Opcodes [
            0x1f                ; add sp, #496
            0xd600              ; ldp x19, lr, [sp, #0]
            0x01                ; add sp, #16
            0xe4                ; end
          ]
        }
        EpilogueScope {
          StartOffset: 14
          EpilogueStartIndex: 0
          Opcodes [
            0x1f                ; add sp, #496
            0xd600              ; ldp x19, lr, [sp, #0]
            0x01                ; add sp, #16
            0xe4                ; end
          ]
        }
      ]
    }
  }

]

Testing uncovered an encoding issue for the large stack size unwind opcode in https://reviews.llvm.org/D50166.  I will update that patch with the fix and test cases that rely on this patch.


Repository:
  rL LLVM

https://reviews.llvm.org/D53264

Files:
  include/llvm/Support/ARMWinEH.h
  tools/llvm-readobj/ARMWinEHPrinter.cpp
  tools/llvm-readobj/ARMWinEHPrinter.h
  tools/llvm-readobj/COFFDumper.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53264.169642.patch
Type: text/x-patch
Size: 27575 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181015/59b7bfe6/attachment-0001.bin>


More information about the llvm-commits mailing list