This is an archive of the discontinued LLVM Phabricator instance.

[Support] Add LEB128 support to BinaryStreamReader/Writer.
ClosedPublic

Authored by lhames on Apr 16 2019, 9:30 PM.

Details

Summary

This patch adds support for ULEB128 and SLEB128 encoding and decoding to
BinaryStreamWriter and BinaryStreamReader respectively.

Support for ULEB128/SLEB128 will be used for eh-frame parsing in the JITLink
library currently under development (see https://reviews.llvm.org/D58704).

Diff Detail

Repository
rL LLVM

Event Timeline

lhames created this revision.Apr 16 2019, 9:30 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 16 2019, 9:30 PM
Herald added a subscriber: kristina. · View Herald Transcript
dblaikie accepted this revision.Apr 17 2019, 8:09 AM

Looks reasonable to me

lib/Support/BinaryStreamReader.cpp
64–68 ↗(On Diff #195509)

Wonder if it's worth rewriting decodeULEB128 as a template (so it can read from different sources without having to buffer it all into an array (& in doing that buffering, having to reimplement the 0x80 check piece))?

This revision is now accepted and ready to land.Apr 17 2019, 8:09 AM
This revision was automatically updated to reflect the committed changes.
lhames marked an inline comment as done.Apr 17 2019, 8:41 AM

Thanks Dave!

lib/Support/BinaryStreamReader.cpp
64–68 ↗(On Diff #195509)

Yep — I considered that, but it would involve teaching decodeULEB128 to deal with sources that potentially generate errors. Since ULEB128 encoding isn’t built for speed anyway (prefix-based variable length encodings are better for that) I did not think the complication was worth it.