From c74798d5cfbb7ae62e7e430e3b7097397faac848 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Sat, 5 Nov 2011 11:52:44 +0000 Subject: Add an option to pad an uleb128 to MCObjectWriter and remove the uleb128 encoding from the DWARF asm printer. As a side effect we now print dwarf ulebs with .ascii directives. llvm-svn: 143809 --- llvm/lib/MC/MCObjectWriter.cpp | 12 ++++++++++-- llvm/lib/MC/MCStreamer.cpp | 5 +++-- 2 files changed, 13 insertions(+), 4 deletions(-) (limited to 'llvm/lib/MC') diff --git a/llvm/lib/MC/MCObjectWriter.cpp b/llvm/lib/MC/MCObjectWriter.cpp index efe9f68ee22..18887397ab6 100644 --- a/llvm/lib/MC/MCObjectWriter.cpp +++ b/llvm/lib/MC/MCObjectWriter.cpp @@ -33,14 +33,22 @@ void MCObjectWriter::EncodeSLEB128(int64_t Value, raw_ostream &OS) { } /// Utility function to encode a ULEB128 value. -void MCObjectWriter::EncodeULEB128(uint64_t Value, raw_ostream &OS) { +void MCObjectWriter::EncodeULEB128(uint64_t Value, raw_ostream &OS, + unsigned Padding) { do { uint8_t Byte = Value & 0x7f; Value >>= 7; - if (Value != 0) + if (Value != 0 || Padding != 0) Byte |= 0x80; // Mark this byte that that more bytes will follow. OS << char(Byte); } while (Value != 0); + + // Pad with 0x80 and emit a null byte at the end. + if (Padding != 0) { + for (; Padding != 1; --Padding) + OS << '\x80'; + OS << '\x00'; + } } bool diff --git a/llvm/lib/MC/MCStreamer.cpp b/llvm/lib/MC/MCStreamer.cpp index 2a37f82a518..62abe54b1a3 100644 --- a/llvm/lib/MC/MCStreamer.cpp +++ b/llvm/lib/MC/MCStreamer.cpp @@ -94,10 +94,11 @@ void MCStreamer::EmitIntValue(uint64_t Value, unsigned Size, /// EmitULEB128Value - Special case of EmitULEB128Value that avoids the /// client having to pass in a MCExpr for constant integers. -void MCStreamer::EmitULEB128IntValue(uint64_t Value, unsigned AddrSpace) { +void MCStreamer::EmitULEB128IntValue(uint64_t Value, unsigned AddrSpace, + unsigned Padding) { SmallString<32> Tmp; raw_svector_ostream OSE(Tmp); - MCObjectWriter::EncodeULEB128(Value, OSE); + MCObjectWriter::EncodeULEB128(Value, OSE, Padding); EmitBytes(OSE.str(), AddrSpace); } -- cgit v1.2.3