Bug 1480654 - Allow empty eh_frame entries. r?froydnj
Somehow, when building with LTO, clang can end up creating a eh_frame
section with only one, empty, entry (which just looks like a 4-bytes
long section full of 0x00).
--- a/build/unix/elfhack/elfhack.cpp
+++ b/build/unix/elfhack/elfhack.cpp
@@ -662,24 +662,30 @@ static void adjust_eh_frame(ElfSection*
char* data = const_cast<char*>(eh_frame->getData());
size_t size = eh_frame->getSize();
char LSDAencoding = DW_EH_PE_omit;
char FDEencoding = DW_EH_PE_absptr;
bool hasZ = false;
// Decoding of eh_frame based on https://www.airs.com/blog/archives/460
while (size) {
- if (size < 2 * sizeof(uint32_t)) goto malformed;
+ if (size < sizeof(uint32_t)) goto malformed;
serializable<FixedSizeData<uint32_t>> entryLength(data, size, elf->getClass(), elf->getData());
if (!advance_buffer(&data, &size, sizeof(uint32_t))) goto malformed;
char* cursor = data;
size_t length = entryLength.value;
+ if (length == 0) {
+ continue;
+ }
+
+ if (size < sizeof(uint32_t)) goto malformed;
+
serializable<FixedSizeData<uint32_t>> id(data, size, elf->getClass(), elf->getData());
if (!advance_buffer(&cursor, &length, sizeof(uint32_t))) goto malformed;
if (id.value == 0) {
// This is a Common Information Entry
if (length < 2) goto malformed;
// Reset LSDA and FDE encodings, and hasZ for subsequent FDEs.
LSDAencoding = DW_EH_PE_omit;