[PATCH] D43313: [DebugInfo] Support parsing DWARF expressions

Reid Kleckner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 15 12:04:09 PST 2018


rnk added inline comments.


================
Comment at: include/llvm/BinaryFormat/Dwarf.h:533-534
+///
+uintptr_t readULEB128(const uint8_t *&Data);
+uintptr_t readSLEB128(const uint8_t *&Data);
+
----------------
Without a bounds, this seems like it's asking to crash on corrupt inputs. The pattern we adopted in the CV dumper that started life in llvm-readobj was to pass around `ArrayRef<uint8_t> &Data` and consume bytes from the front of the ArrayRef.

The other style common in dwarfdump is to use a DataExtractor, but personally we found it nicer to work directly with ArrayRefs.

Even if all we do is `assert` or `report_fatal_error` on buffer overrun, it's better than nothing.


================
Comment at: lib/DebugInfo/DWARF/DWARFDebugFrame.cpp:607-614
+        const uint8_t *DataStart = reinterpret_cast<const uint8_t *>(
+            Data.getData().substr(Offset).data());
+        const uint8_t *DataEnd = DataStart;
+        InitialLocation = readEncodedPointer(
+            DataEnd, Cie->getFDEPointerEncoding(), Data.getAddressSize(),
+            EHFrameAddress ? EHFrameAddress + Offset : 0);
+        Offset += DataEnd - DataStart;
----------------
Yeah, modifying in ArrayRef by reference seems preferable to this offsetting dance.


Repository:
  rL LLVM

https://reviews.llvm.org/D43313





More information about the llvm-commits mailing list