[PATCH] D57081: [libunwind] Don't abort if encoutering invalid .eh_frame_hdr
Petr Hosek via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 23 19:04:51 PST 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL352016: [libunwind] Don't abort if encoutering invalid .eh_frame_hdr (authored by phosek, committed by ).
Herald added a subscriber: llvm-commits.
Changed prior to commit:
https://reviews.llvm.org/D57081?vs=183035&id=183231#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D57081/new/
https://reviews.llvm.org/D57081
Files:
libunwind/trunk/src/AddressSpace.hpp
libunwind/trunk/src/EHHeaderParser.hpp
Index: libunwind/trunk/src/EHHeaderParser.hpp
===================================================================
--- libunwind/trunk/src/EHHeaderParser.hpp
+++ libunwind/trunk/src/EHHeaderParser.hpp
@@ -35,7 +35,7 @@
uint8_t table_enc;
};
- static void decodeEHHdr(A &addressSpace, pint_t ehHdrStart, pint_t ehHdrEnd,
+ static bool decodeEHHdr(A &addressSpace, pint_t ehHdrStart, pint_t ehHdrEnd,
EHHeaderInfo &ehHdrInfo);
static bool findFDE(A &addressSpace, pint_t pc, pint_t ehHdrStart,
uint32_t sectionLength,
@@ -52,12 +52,14 @@
};
template <typename A>
-void EHHeaderParser<A>::decodeEHHdr(A &addressSpace, pint_t ehHdrStart,
+bool EHHeaderParser<A>::decodeEHHdr(A &addressSpace, pint_t ehHdrStart,
pint_t ehHdrEnd, EHHeaderInfo &ehHdrInfo) {
pint_t p = ehHdrStart;
uint8_t version = addressSpace.get8(p++);
- if (version != 1)
- _LIBUNWIND_ABORT("Unsupported .eh_frame_hdr version");
+ if (version != 1) {
+ _LIBUNWIND_LOG0("Unsupported .eh_frame_hdr version");
+ return false;
+ }
uint8_t eh_frame_ptr_enc = addressSpace.get8(p++);
uint8_t fde_count_enc = addressSpace.get8(p++);
@@ -70,6 +72,8 @@
? 0
: addressSpace.getEncodedP(p, ehHdrEnd, fde_count_enc, ehHdrStart);
ehHdrInfo.table = p;
+
+ return true;
}
template <typename A>
@@ -101,7 +105,9 @@
pint_t ehHdrEnd = ehHdrStart + sectionLength;
EHHeaderParser<A>::EHHeaderInfo hdrInfo;
- EHHeaderParser<A>::decodeEHHdr(addressSpace, ehHdrStart, ehHdrEnd, hdrInfo);
+ if (!EHHeaderParser<A>::decodeEHHdr(addressSpace, ehHdrStart, ehHdrEnd,
+ hdrInfo))
+ return false;
size_t tableEntrySize = getTableEntrySize(hdrInfo.table_enc);
pint_t tableEntry;
Index: libunwind/trunk/src/AddressSpace.hpp
===================================================================
--- libunwind/trunk/src/AddressSpace.hpp
+++ libunwind/trunk/src/AddressSpace.hpp
@@ -535,11 +535,11 @@
#endif
cbdata->sects->dwarf_index_section = eh_frame_hdr_start;
cbdata->sects->dwarf_index_section_length = phdr->p_memsz;
- EHHeaderParser<LocalAddressSpace>::decodeEHHdr(
+ found_hdr = EHHeaderParser<LocalAddressSpace>::decodeEHHdr(
*cbdata->addressSpace, eh_frame_hdr_start, phdr->p_memsz,
hdrInfo);
- cbdata->sects->dwarf_section = hdrInfo.eh_frame_ptr;
- found_hdr = true;
+ if (found_hdr)
+ cbdata->sects->dwarf_section = hdrInfo.eh_frame_ptr;
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57081.183231.patch
Type: text/x-patch
Size: 2651 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190124/4872351d/attachment.bin>
More information about the llvm-commits
mailing list