[PATCH] D83741: [libunwind] Fix CIE v1 return address parsing

Ryan Prichard via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 13 22:06:19 PDT 2020


rprichard created this revision.
Herald added subscribers: libcxx-commits, llvm-commits, aprantl.
Herald added projects: LLVM, libunwind.
Herald added a reviewer: libunwind.

- For CIE version 1 (e.g. in DWARF 2.0.0), the return_address_register field is a ubyte [0..255].
- For CIE version 3 (e.g. in DWARF 3), the field is instead a ULEB128 constant.

Previously, libunwind accepted a CIE version of 1 or 3, but always
parsed the field as ULEB128.

Clang always outputs CIE version 1 into .eh_frame. (It can output CIE
version 3 or 4, but only into .debug_frame.)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83741

Files:
  libunwind/src/DwarfParser.hpp


Index: libunwind/src/DwarfParser.hpp
===================================================================
--- libunwind/src/DwarfParser.hpp
+++ libunwind/src/DwarfParser.hpp
@@ -336,7 +336,8 @@
   // parse data alignment factor
   cieInfo->dataAlignFactor = (int)addressSpace.getSLEB128(p, cieContentEnd);
   // parse return address register
-  uint64_t raReg = addressSpace.getULEB128(p, cieContentEnd);
+  uint64_t raReg = version == 1 ? addressSpace.get8(p++) :
+                                  addressSpace.getULEB128(p, cieContentEnd);
   assert(raReg < 255 && "return address register too large");
   cieInfo->returnAddressRegister = (uint8_t)raReg;
   // parse augmentation data based on augmentation string


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83741.277660.patch
Type: text/x-patch
Size: 716 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200714/b96062ee/attachment.bin>


More information about the llvm-commits mailing list