[PATCH] D144999: [RFC][MC][MachO]Only emits compact-unwind format for "canonical" personality symbols. For the rest, use DWARFs.

Vy Nguyen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 23 08:14:47 PDT 2023


oontvoo updated this revision to Diff 507744.
oontvoo marked an inline comment as done.
oontvoo added a comment.

Updated diff:

- flip the emit-compact-unwind-non-canonical flag's default value back to false
- have all the generateCompactUnwind...() return MODE_DWARF (instead of 0, that was a bug).

Tested this manually. Seemed to work!
The test was:

(0) Generate an asm file from:

  #include <iostream>
  #include <stdexcept>
  #include "unwind.h"
   
  typedef uint32_t _Unwind_State;
  extern "C" _Unwind_Reason_Code __gxx_personality_v0(_Unwind_State state,
  						    _Unwind_Exception* unwind_exception,
  						    _Unwind_Context* context);
   
   _Unwind_Reason_Code
  _my_personality(_Unwind_State state,
  		_Unwind_Exception* unwind_exception,
  		_Unwind_Context* context) {
     return __gxx_personality_v0(state, unwind_exception, context);
  }
   
  void func() {
    throw std::runtime_error("RUNTIME error");
  }
   
  int main() {
      try {
      	func();
      } catch(std::runtime_error ex){
          std::cout << "caught \n";
      }
      
      try {
        func();
      }
      catch (int i) { }
   
   
    return 0;
  }

(1) Manually edit the asm to change  main's personality function from `__gxx_personality_v0` to `_my_personality`
(2) Assemble/link/execute it.
(3) Run the binary and got the following, which confirmed that DWARF unwind worked.

  % ./manual.out 
  caught 
  libc++abi: terminating with uncaught exception of type std::runtime_error: RUNTIME error
  zsh: abort      ./manual..out

(4) Extra verification: looking at the objdump to confirm that DWARF entries are emitted (rather than compact-unwind) for _main


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144999/new/

https://reviews.llvm.org/D144999

Files:
  lld/MachO/UnwindInfoSection.cpp
  lld/test/MachO/compact-unwind-both-local-and-dylib-personality.s
  llvm/include/llvm/MC/MCAsmBackend.h
  llvm/include/llvm/MC/MCContext.h
  llvm/include/llvm/MC/MCTargetOptions.h
  llvm/include/llvm/MC/MCTargetOptionsCommandFlags.h
  llvm/lib/MC/MCAsmBackend.cpp
  llvm/lib/MC/MCContext.cpp
  llvm/lib/MC/MCStreamer.cpp
  llvm/lib/MC/MCTargetOptionsCommandFlags.cpp
  llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
  llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
  llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackendDarwin.h
  llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144999.507744.patch
Type: text/x-patch
Size: 15207 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230323/8e424e4c/attachment.bin>


More information about the llvm-commits mailing list