[libunwind] 52d0a78 - [libunwind] Fix CIE v1 return address parsing

Ryan Prichard via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 15 19:13:58 PDT 2020


Author: Ryan Prichard
Date: 2020-07-15T19:12:55-07:00
New Revision: 52d0a78b831584c46eda78b7cf349ab93ce13df0

URL: https://github.com/llvm/llvm-project/commit/52d0a78b831584c46eda78b7cf349ab93ce13df0
DIFF: https://github.com/llvm/llvm-project/commit/52d0a78b831584c46eda78b7cf349ab93ce13df0.diff

LOG: [libunwind] Fix CIE v1 return address parsing

 - 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.)

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

Added: 
    

Modified: 
    libunwind/src/DwarfParser.hpp

Removed: 
    


################################################################################
diff  --git a/libunwind/src/DwarfParser.hpp b/libunwind/src/DwarfParser.hpp
index d05ac468367f..c98c4f92a6ad 100644
--- a/libunwind/src/DwarfParser.hpp
+++ b/libunwind/src/DwarfParser.hpp
@@ -336,7 +336,8 @@ const char *CFI_Parser<A>::parseCIE(A &addressSpace, pint_t cie,
   // 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


        


More information about the cfe-commits mailing list