[PATCH] D24220: [UNWIND] Handle non-existing FDE count / search table

Patrick Wildt via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 4 08:25:54 PDT 2016


Bluerise created this revision.
Bluerise added a subscriber: llvm-commits.
Bluerise set the repository for this revision to rL LLVM.

On OpenBSD the binutils 2.17 linker in combination with clang++ 3.8.1 seems to produce an EH frame that does omit the fde count and the binary table. Unfortunately the code does not handle this scenario and will blow up. If we just return when it's omitted the fallback code will look through the full table and there the unwinding works.

Repository:
  rL LLVM

https://reviews.llvm.org/D24220

Files:
  src/AddressSpace.hpp
  src/EHHeaderParser.hpp

Index: src/EHHeaderParser.hpp
===================================================================
--- src/EHHeaderParser.hpp
+++ src/EHHeaderParser.hpp
@@ -103,6 +103,9 @@
   EHHeaderParser<A>::EHHeaderInfo hdrInfo;
   EHHeaderParser<A>::decodeEHHdr(addressSpace, ehHdrStart, ehHdrEnd, hdrInfo);
 
+  if (hdrInfo.fde_count == 0)
+    return false;
+
   size_t tableEntrySize = getTableEntrySize(hdrInfo.table_enc);
   pint_t tableEntry;
 
@@ -136,6 +139,10 @@
 
 template <typename A>
 size_t EHHeaderParser<A>::getTableEntrySize(uint8_t tableEnc) {
+  if (tableEnc == DW_EH_PE_omit) {
+    return 0;
+  }
+
   switch (tableEnc & 0x0f) {
   case DW_EH_PE_sdata2:
   case DW_EH_PE_udata2:
@@ -149,8 +156,6 @@
   case DW_EH_PE_sleb128:
   case DW_EH_PE_uleb128:
     _LIBUNWIND_ABORT("Can't binary search on variable length encoded data.");
-  case DW_EH_PE_omit:
-    return 0;
   default:
     _LIBUNWIND_ABORT("Unknown DWARF encoding for search table.");
   }
Index: src/AddressSpace.hpp
===================================================================
--- src/AddressSpace.hpp
+++ src/AddressSpace.hpp
@@ -221,6 +221,10 @@
   const uint8_t *p = (uint8_t *)addr;
   pint_t result;
 
+  if (encoding == DW_EH_PE_omit) {
+    return (pint_t)NULL;
+  }
+
   // first get value
   switch (encoding & 0x0F) {
   case DW_EH_PE_ptr:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24220.70290.patch
Type: text/x-patch
Size: 1330 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160904/5625364d/attachment.bin>


More information about the llvm-commits mailing list