blob: 112d7d887a2d93ca23da1dbe5b8ec56419299602 [file] [log] [blame]
Kevin Enderby7cbf73a2010-07-28 20:55:35 +00001//===- lib/MC/MCDwarf.cpp - MCDwarf implementation ------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
Rafael Espindolabdc31672010-12-27 15:56:22 +000010#include "llvm/ADT/FoldingSet.h"
Rafael Espindola767b1be2010-12-04 00:31:13 +000011#include "llvm/MC/MCAsmInfo.h"
Kevin Enderby7cbf73a2010-07-28 20:55:35 +000012#include "llvm/MC/MCDwarf.h"
Kevin Enderbyc0957932010-09-30 16:52:03 +000013#include "llvm/MC/MCAssembler.h"
Rafael Espindolaad8aaa02010-11-22 11:53:17 +000014#include "llvm/MC/MCStreamer.h"
Kevin Enderbyc0957932010-09-30 16:52:03 +000015#include "llvm/MC/MCSymbol.h"
16#include "llvm/MC/MCExpr.h"
17#include "llvm/MC/MCContext.h"
18#include "llvm/MC/MCObjectWriter.h"
19#include "llvm/ADT/SmallString.h"
Kevin Enderby7cbf73a2010-07-28 20:55:35 +000020#include "llvm/Support/Debug.h"
Rafael Espindolafe024d02010-12-28 18:36:23 +000021#include "llvm/Support/ErrorHandling.h"
Kevin Enderby7cbf73a2010-07-28 20:55:35 +000022#include "llvm/Support/raw_ostream.h"
Kevin Enderbyc0957932010-09-30 16:52:03 +000023#include "llvm/Target/TargetAsmBackend.h"
Rafael Espindola89b93722010-12-10 07:39:47 +000024#include "llvm/Target/TargetAsmInfo.h"
Kevin Enderby7cbf73a2010-07-28 20:55:35 +000025using namespace llvm;
26
Kevin Enderbyc0957932010-09-30 16:52:03 +000027// Given a special op, return the address skip amount (in units of
28// DWARF2_LINE_MIN_INSN_LENGTH.
29#define SPECIAL_ADDR(op) (((op) - DWARF2_LINE_OPCODE_BASE)/DWARF2_LINE_RANGE)
30
31// The maximum address skip amount that can be encoded with a special op.
32#define MAX_SPECIAL_ADDR_DELTA SPECIAL_ADDR(255)
33
34// First special line opcode - leave room for the standard opcodes.
35// Note: If you want to change this, you'll have to update the
36// "standard_opcode_lengths" table that is emitted in DwarfFileTable::Emit().
37#define DWARF2_LINE_OPCODE_BASE 13
38
39// Minimum line offset in a special line info. opcode. This value
40// was chosen to give a reasonable range of values.
41#define DWARF2_LINE_BASE -5
42
43// Range of line offsets in a special line info. opcode.
44# define DWARF2_LINE_RANGE 14
45
46// Define the architecture-dependent minimum instruction length (in bytes).
47// This value should be rather too small than too big.
48# define DWARF2_LINE_MIN_INSN_LENGTH 1
49
50// Note: when DWARF2_LINE_MIN_INSN_LENGTH == 1 which is the current setting,
51// this routine is a nop and will be optimized away.
52static inline uint64_t ScaleAddrDelta(uint64_t AddrDelta)
53{
54 if (DWARF2_LINE_MIN_INSN_LENGTH == 1)
55 return AddrDelta;
56 if (AddrDelta % DWARF2_LINE_MIN_INSN_LENGTH != 0) {
57 // TODO: report this error, but really only once.
58 ;
59 }
60 return AddrDelta / DWARF2_LINE_MIN_INSN_LENGTH;
61}
62
63//
64// This is called when an instruction is assembled into the specified section
65// and if there is information from the last .loc directive that has yet to have
66// a line entry made for it is made.
67//
Rafael Espindola195a0ce2010-11-19 02:26:16 +000068void MCLineEntry::Make(MCStreamer *MCOS, const MCSection *Section) {
Kevin Enderbyc0957932010-09-30 16:52:03 +000069 if (!MCOS->getContext().getDwarfLocSeen())
70 return;
71
72 // Create a symbol at in the current section for use in the line entry.
73 MCSymbol *LineSym = MCOS->getContext().CreateTempSymbol();
74 // Set the value of the symbol to use for the MCLineEntry.
75 MCOS->EmitLabel(LineSym);
76
77 // Get the current .loc info saved in the context.
78 const MCDwarfLoc &DwarfLoc = MCOS->getContext().getCurrentDwarfLoc();
79
80 // Create a (local) line entry with the symbol and the current .loc info.
81 MCLineEntry LineEntry(LineSym, DwarfLoc);
82
83 // clear DwarfLocSeen saying the current .loc info is now used.
Kevin Enderby3f55c242010-10-04 20:17:24 +000084 MCOS->getContext().ClearDwarfLocSeen();
Kevin Enderbyc0957932010-09-30 16:52:03 +000085
86 // Get the MCLineSection for this section, if one does not exist for this
87 // section create it.
Rafael Espindola17fd7bd2010-11-19 07:41:23 +000088 const DenseMap<const MCSection *, MCLineSection *> &MCLineSections =
Kevin Enderbyc0957932010-09-30 16:52:03 +000089 MCOS->getContext().getMCLineSections();
Rafael Espindola17fd7bd2010-11-19 07:41:23 +000090 MCLineSection *LineSection = MCLineSections.lookup(Section);
Kevin Enderbyc0957932010-09-30 16:52:03 +000091 if (!LineSection) {
92 // Create a new MCLineSection. This will be deleted after the dwarf line
93 // table is created using it by iterating through the MCLineSections
94 // DenseMap.
95 LineSection = new MCLineSection;
96 // Save a pointer to the new LineSection into the MCLineSections DenseMap.
Rafael Espindola17fd7bd2010-11-19 07:41:23 +000097 MCOS->getContext().addMCLineSection(Section, LineSection);
Kevin Enderbyc0957932010-09-30 16:52:03 +000098 }
99
100 // Add the line entry to this section's entries.
101 LineSection->addLineEntry(LineEntry);
102}
103
104//
105// This helper routine returns an expression of End - Start + IntVal .
106//
Rafael Espindola5fad7a92010-12-09 23:08:35 +0000107static inline const MCExpr *MakeStartMinusEndExpr(const MCStreamer &MCOS,
108 const MCSymbol &Start,
109 const MCSymbol &End,
110 int IntVal) {
Kevin Enderbyc0957932010-09-30 16:52:03 +0000111 MCSymbolRefExpr::VariantKind Variant = MCSymbolRefExpr::VK_None;
112 const MCExpr *Res =
Rafael Espindola5fad7a92010-12-09 23:08:35 +0000113 MCSymbolRefExpr::Create(&End, Variant, MCOS.getContext());
Kevin Enderbyc0957932010-09-30 16:52:03 +0000114 const MCExpr *RHS =
Rafael Espindola5fad7a92010-12-09 23:08:35 +0000115 MCSymbolRefExpr::Create(&Start, Variant, MCOS.getContext());
Kevin Enderbyc0957932010-09-30 16:52:03 +0000116 const MCExpr *Res1 =
Rafael Espindola5fad7a92010-12-09 23:08:35 +0000117 MCBinaryExpr::Create(MCBinaryExpr::Sub, Res, RHS, MCOS.getContext());
Kevin Enderbyc0957932010-09-30 16:52:03 +0000118 const MCExpr *Res2 =
Rafael Espindola5fad7a92010-12-09 23:08:35 +0000119 MCConstantExpr::Create(IntVal, MCOS.getContext());
Kevin Enderbyc0957932010-09-30 16:52:03 +0000120 const MCExpr *Res3 =
Rafael Espindola5fad7a92010-12-09 23:08:35 +0000121 MCBinaryExpr::Create(MCBinaryExpr::Sub, Res1, Res2, MCOS.getContext());
Kevin Enderbyc0957932010-09-30 16:52:03 +0000122 return Res3;
123}
124
Kevin Enderbyc0957932010-09-30 16:52:03 +0000125//
126// This emits the Dwarf line table for the specified section from the entries
127// in the LineSection.
128//
Rafael Espindola195a0ce2010-11-19 02:26:16 +0000129static inline void EmitDwarfLineTable(MCStreamer *MCOS,
Kevin Enderbyc0957932010-09-30 16:52:03 +0000130 const MCSection *Section,
Rafael Espindola89b93722010-12-10 07:39:47 +0000131 const MCLineSection *LineSection) {
Kevin Enderbyc0957932010-09-30 16:52:03 +0000132 unsigned FileNum = 1;
133 unsigned LastLine = 1;
134 unsigned Column = 0;
135 unsigned Flags = DWARF2_LINE_DEFAULT_IS_STMT ? DWARF2_FLAG_IS_STMT : 0;
136 unsigned Isa = 0;
Kevin Enderbyc0957932010-09-30 16:52:03 +0000137 MCSymbol *LastLabel = NULL;
Kevin Enderbyc0957932010-09-30 16:52:03 +0000138
139 // Loop through each MCLineEntry and encode the dwarf line number table.
Rafael Espindola17fd7bd2010-11-19 07:41:23 +0000140 for (MCLineSection::const_iterator
Kevin Enderbyc0957932010-09-30 16:52:03 +0000141 it = LineSection->getMCLineEntries()->begin(),
142 ie = LineSection->getMCLineEntries()->end(); it != ie; ++it) {
143
144 if (FileNum != it->getFileNum()) {
145 FileNum = it->getFileNum();
146 MCOS->EmitIntValue(dwarf::DW_LNS_set_file, 1);
Rafael Espindola3ff57092010-11-02 17:22:24 +0000147 MCOS->EmitULEB128IntValue(FileNum);
Kevin Enderbyc0957932010-09-30 16:52:03 +0000148 }
149 if (Column != it->getColumn()) {
150 Column = it->getColumn();
151 MCOS->EmitIntValue(dwarf::DW_LNS_set_column, 1);
Rafael Espindola3ff57092010-11-02 17:22:24 +0000152 MCOS->EmitULEB128IntValue(Column);
Kevin Enderbyc0957932010-09-30 16:52:03 +0000153 }
154 if (Isa != it->getIsa()) {
155 Isa = it->getIsa();
156 MCOS->EmitIntValue(dwarf::DW_LNS_set_isa, 1);
Rafael Espindola3ff57092010-11-02 17:22:24 +0000157 MCOS->EmitULEB128IntValue(Isa);
Kevin Enderbyc0957932010-09-30 16:52:03 +0000158 }
159 if ((it->getFlags() ^ Flags) & DWARF2_FLAG_IS_STMT) {
160 Flags = it->getFlags();
161 MCOS->EmitIntValue(dwarf::DW_LNS_negate_stmt, 1);
162 }
163 if (it->getFlags() & DWARF2_FLAG_BASIC_BLOCK)
164 MCOS->EmitIntValue(dwarf::DW_LNS_set_basic_block, 1);
165 if (it->getFlags() & DWARF2_FLAG_PROLOGUE_END)
166 MCOS->EmitIntValue(dwarf::DW_LNS_set_prologue_end, 1);
167 if (it->getFlags() & DWARF2_FLAG_EPILOGUE_BEGIN)
168 MCOS->EmitIntValue(dwarf::DW_LNS_set_epilogue_begin, 1);
169
Rafael Espindola64185cc2010-11-13 01:06:27 +0000170 int64_t LineDelta = static_cast<int64_t>(it->getLine()) - LastLine;
Kevin Enderbyc0957932010-09-30 16:52:03 +0000171 MCSymbol *Label = it->getLabel();
172
173 // At this point we want to emit/create the sequence to encode the delta in
174 // line numbers and the increment of the address from the previous Label
175 // and the current Label.
Rafael Espindola32a006e2010-12-03 00:55:40 +0000176 MCOS->EmitDwarfAdvanceLineAddr(LineDelta, LastLabel, Label);
Kevin Enderbyc0957932010-09-30 16:52:03 +0000177
178 LastLine = it->getLine();
179 LastLabel = Label;
Kevin Enderbyc0957932010-09-30 16:52:03 +0000180 }
181
182 // Emit a DW_LNE_end_sequence for the end of the section.
183 // Using the pointer Section create a temporary label at the end of the
184 // section and use that and the LastLabel to compute the address delta
185 // and use INT64_MAX as the line delta which is the signal that this is
186 // actually a DW_LNE_end_sequence.
187
188 // Switch to the section to be able to create a symbol at its end.
189 MCOS->SwitchSection(Section);
Rafael Espindola89b93722010-12-10 07:39:47 +0000190
191 MCContext &context = MCOS->getContext();
Kevin Enderbyc0957932010-09-30 16:52:03 +0000192 // Create a symbol at the end of the section.
Rafael Espindola89b93722010-12-10 07:39:47 +0000193 MCSymbol *SectionEnd = context.CreateTempSymbol();
Kevin Enderbyc0957932010-09-30 16:52:03 +0000194 // Set the value of the symbol, as we are at the end of the section.
195 MCOS->EmitLabel(SectionEnd);
196
197 // Switch back the the dwarf line section.
Rafael Espindola89b93722010-12-10 07:39:47 +0000198 MCOS->SwitchSection(context.getTargetAsmInfo().getDwarfLineSection());
Rafael Espindola195a0ce2010-11-19 02:26:16 +0000199
Rafael Espindola32a006e2010-12-03 00:55:40 +0000200 MCOS->EmitDwarfAdvanceLineAddr(INT64_MAX, LastLabel, SectionEnd);
Kevin Enderbyc0957932010-09-30 16:52:03 +0000201}
202
203//
204// This emits the Dwarf file and the line tables.
205//
Rafael Espindola89b93722010-12-10 07:39:47 +0000206void MCDwarfFileTable::Emit(MCStreamer *MCOS) {
207 MCContext &context = MCOS->getContext();
Kevin Enderbyc0957932010-09-30 16:52:03 +0000208 // Switch to the section where the table will be emitted into.
Rafael Espindola89b93722010-12-10 07:39:47 +0000209 MCOS->SwitchSection(context.getTargetAsmInfo().getDwarfLineSection());
Kevin Enderbyc0957932010-09-30 16:52:03 +0000210
211 // Create a symbol at the beginning of this section.
Rafael Espindola89b93722010-12-10 07:39:47 +0000212 MCSymbol *LineStartSym = context.CreateTempSymbol();
Kevin Enderbyc0957932010-09-30 16:52:03 +0000213 // Set the value of the symbol, as we are at the start of the section.
214 MCOS->EmitLabel(LineStartSym);
215
216 // Create a symbol for the end of the section (to be set when we get there).
Rafael Espindola89b93722010-12-10 07:39:47 +0000217 MCSymbol *LineEndSym = context.CreateTempSymbol();
Kevin Enderbyc0957932010-09-30 16:52:03 +0000218
219 // The first 4 bytes is the total length of the information for this
220 // compilation unit (not including these 4 bytes for the length).
Rafael Espindola5fad7a92010-12-09 23:08:35 +0000221 MCOS->EmitAbsValue(MakeStartMinusEndExpr(*MCOS, *LineStartSym, *LineEndSym,4),
Rafael Espindola0bbe0b42010-12-06 17:27:56 +0000222 4);
Kevin Enderbyc0957932010-09-30 16:52:03 +0000223
224 // Next 2 bytes is the Version, which is Dwarf 2.
225 MCOS->EmitIntValue(2, 2);
226
227 // Create a symbol for the end of the prologue (to be set when we get there).
Rafael Espindola89b93722010-12-10 07:39:47 +0000228 MCSymbol *ProEndSym = context.CreateTempSymbol(); // Lprologue_end
Kevin Enderbyc0957932010-09-30 16:52:03 +0000229
230 // Length of the prologue, is the next 4 bytes. Which is the start of the
231 // section to the end of the prologue. Not including the 4 bytes for the
232 // total length, the 2 bytes for the version, and these 4 bytes for the
233 // length of the prologue.
Rafael Espindola5fad7a92010-12-09 23:08:35 +0000234 MCOS->EmitAbsValue(MakeStartMinusEndExpr(*MCOS, *LineStartSym, *ProEndSym,
Kevin Enderbyc0957932010-09-30 16:52:03 +0000235 (4 + 2 + 4)),
Rafael Espindola5d4918d2010-12-04 03:21:47 +0000236 4, 0);
Kevin Enderbyc0957932010-09-30 16:52:03 +0000237
238 // Parameters of the state machine, are next.
239 MCOS->EmitIntValue(DWARF2_LINE_MIN_INSN_LENGTH, 1);
240 MCOS->EmitIntValue(DWARF2_LINE_DEFAULT_IS_STMT, 1);
241 MCOS->EmitIntValue(DWARF2_LINE_BASE, 1);
242 MCOS->EmitIntValue(DWARF2_LINE_RANGE, 1);
243 MCOS->EmitIntValue(DWARF2_LINE_OPCODE_BASE, 1);
244
245 // Standard opcode lengths
246 MCOS->EmitIntValue(0, 1); // length of DW_LNS_copy
247 MCOS->EmitIntValue(1, 1); // length of DW_LNS_advance_pc
248 MCOS->EmitIntValue(1, 1); // length of DW_LNS_advance_line
249 MCOS->EmitIntValue(1, 1); // length of DW_LNS_set_file
250 MCOS->EmitIntValue(1, 1); // length of DW_LNS_set_column
251 MCOS->EmitIntValue(0, 1); // length of DW_LNS_negate_stmt
252 MCOS->EmitIntValue(0, 1); // length of DW_LNS_set_basic_block
253 MCOS->EmitIntValue(0, 1); // length of DW_LNS_const_add_pc
254 MCOS->EmitIntValue(1, 1); // length of DW_LNS_fixed_advance_pc
255 MCOS->EmitIntValue(0, 1); // length of DW_LNS_set_prologue_end
256 MCOS->EmitIntValue(0, 1); // length of DW_LNS_set_epilogue_begin
257 MCOS->EmitIntValue(1, 1); // DW_LNS_set_isa
258
259 // Put out the directory and file tables.
260
261 // First the directory table.
262 const std::vector<StringRef> &MCDwarfDirs =
Rafael Espindola89b93722010-12-10 07:39:47 +0000263 context.getMCDwarfDirs();
Kevin Enderbyc0957932010-09-30 16:52:03 +0000264 for (unsigned i = 0; i < MCDwarfDirs.size(); i++) {
265 MCOS->EmitBytes(MCDwarfDirs[i], 0); // the DirectoryName
266 MCOS->EmitBytes(StringRef("\0", 1), 0); // the null term. of the string
267 }
268 MCOS->EmitIntValue(0, 1); // Terminate the directory list
269
270 // Second the file table.
271 const std::vector<MCDwarfFile *> &MCDwarfFiles =
272 MCOS->getContext().getMCDwarfFiles();
273 for (unsigned i = 1; i < MCDwarfFiles.size(); i++) {
274 MCOS->EmitBytes(MCDwarfFiles[i]->getName(), 0); // FileName
275 MCOS->EmitBytes(StringRef("\0", 1), 0); // the null term. of the string
Rafael Espindola3ff57092010-11-02 17:22:24 +0000276 // the Directory num
277 MCOS->EmitULEB128IntValue(MCDwarfFiles[i]->getDirIndex());
Kevin Enderbyc0957932010-09-30 16:52:03 +0000278 MCOS->EmitIntValue(0, 1); // last modification timestamp (always 0)
279 MCOS->EmitIntValue(0, 1); // filesize (always 0)
280 }
281 MCOS->EmitIntValue(0, 1); // Terminate the file list
282
283 // This is the end of the prologue, so set the value of the symbol at the
284 // end of the prologue (that was used in a previous expression).
285 MCOS->EmitLabel(ProEndSym);
286
287 // Put out the line tables.
Rafael Espindola17fd7bd2010-11-19 07:41:23 +0000288 const DenseMap<const MCSection *, MCLineSection *> &MCLineSections =
Kevin Enderbyc0957932010-09-30 16:52:03 +0000289 MCOS->getContext().getMCLineSections();
Rafael Espindola17fd7bd2010-11-19 07:41:23 +0000290 const std::vector<const MCSection *> &MCLineSectionOrder =
291 MCOS->getContext().getMCLineSectionOrder();
292 for (std::vector<const MCSection*>::const_iterator it =
293 MCLineSectionOrder.begin(), ie = MCLineSectionOrder.end(); it != ie;
294 ++it) {
295 const MCSection *Sec = *it;
296 const MCLineSection *Line = MCLineSections.lookup(Sec);
Rafael Espindola89b93722010-12-10 07:39:47 +0000297 EmitDwarfLineTable(MCOS, Sec, Line);
Kevin Enderbyc0957932010-09-30 16:52:03 +0000298
299 // Now delete the MCLineSections that were created in MCLineEntry::Make()
300 // and used to emit the line table.
Rafael Espindola17fd7bd2010-11-19 07:41:23 +0000301 delete Line;
Kevin Enderbyc0957932010-09-30 16:52:03 +0000302 }
303
Rafael Espindola767b1be2010-12-04 00:31:13 +0000304 if (MCOS->getContext().getAsmInfo().getLinkerRequiresNonEmptyDwarfLines()
305 && MCLineSectionOrder.begin() == MCLineSectionOrder.end()) {
Rafael Espindolaa8de83c2010-12-03 23:36:59 +0000306 // The darwin9 linker has a bug (see PR8715). For for 32-bit architectures
307 // it requires:
308 // total_length >= prologue_length + 10
309 // We are 4 bytes short, since we have total_length = 51 and
310 // prologue_length = 45
Devang Patel5113cdb2010-12-03 00:10:48 +0000311
Rafael Espindolaa8de83c2010-12-03 23:36:59 +0000312 // The regular end_sequence should be sufficient.
313 MCDwarfLineAddr::Emit(MCOS, INT64_MAX, 0);
Devang Patel5113cdb2010-12-03 00:10:48 +0000314 }
315
Kevin Enderbyc0957932010-09-30 16:52:03 +0000316 // This is the end of the section, so set the value of the symbol at the end
317 // of this section (that was used in a previous expression).
318 MCOS->EmitLabel(LineEndSym);
319}
320
Kevin Enderbyc0957932010-09-30 16:52:03 +0000321/// Utility function to write the encoding to an object writer.
322void MCDwarfLineAddr::Write(MCObjectWriter *OW, int64_t LineDelta,
323 uint64_t AddrDelta) {
324 SmallString<256> Tmp;
325 raw_svector_ostream OS(Tmp);
326 MCDwarfLineAddr::Encode(LineDelta, AddrDelta, OS);
327 OW->WriteBytes(OS.str());
328}
329
330/// Utility function to emit the encoding to a streamer.
Rafael Espindola195a0ce2010-11-19 02:26:16 +0000331void MCDwarfLineAddr::Emit(MCStreamer *MCOS, int64_t LineDelta,
Kevin Enderbyc0957932010-09-30 16:52:03 +0000332 uint64_t AddrDelta) {
333 SmallString<256> Tmp;
334 raw_svector_ostream OS(Tmp);
335 MCDwarfLineAddr::Encode(LineDelta, AddrDelta, OS);
336 MCOS->EmitBytes(OS.str(), /*AddrSpace=*/0);
337}
338
339/// Utility function to encode a Dwarf pair of LineDelta and AddrDeltas.
340void MCDwarfLineAddr::Encode(int64_t LineDelta, uint64_t AddrDelta,
341 raw_ostream &OS) {
342 uint64_t Temp, Opcode;
343 bool NeedCopy = false;
344
345 // Scale the address delta by the minimum instruction length.
346 AddrDelta = ScaleAddrDelta(AddrDelta);
347
348 // A LineDelta of INT64_MAX is a signal that this is actually a
349 // DW_LNE_end_sequence. We cannot use special opcodes here, since we want the
350 // end_sequence to emit the matrix entry.
351 if (LineDelta == INT64_MAX) {
352 if (AddrDelta == MAX_SPECIAL_ADDR_DELTA)
353 OS << char(dwarf::DW_LNS_const_add_pc);
354 else {
355 OS << char(dwarf::DW_LNS_advance_pc);
356 SmallString<32> Tmp;
357 raw_svector_ostream OSE(Tmp);
358 MCObjectWriter::EncodeULEB128(AddrDelta, OSE);
359 OS << OSE.str();
360 }
361 OS << char(dwarf::DW_LNS_extended_op);
362 OS << char(1);
363 OS << char(dwarf::DW_LNE_end_sequence);
364 return;
365 }
366
367 // Bias the line delta by the base.
368 Temp = LineDelta - DWARF2_LINE_BASE;
369
370 // If the line increment is out of range of a special opcode, we must encode
371 // it with DW_LNS_advance_line.
372 if (Temp >= DWARF2_LINE_RANGE) {
373 OS << char(dwarf::DW_LNS_advance_line);
374 SmallString<32> Tmp;
375 raw_svector_ostream OSE(Tmp);
376 MCObjectWriter::EncodeSLEB128(LineDelta, OSE);
377 OS << OSE.str();
378
379 LineDelta = 0;
380 Temp = 0 - DWARF2_LINE_BASE;
381 NeedCopy = true;
382 }
383
384 // Use DW_LNS_copy instead of a "line +0, addr +0" special opcode.
385 if (LineDelta == 0 && AddrDelta == 0) {
386 OS << char(dwarf::DW_LNS_copy);
387 return;
388 }
389
390 // Bias the opcode by the special opcode base.
391 Temp += DWARF2_LINE_OPCODE_BASE;
392
393 // Avoid overflow when addr_delta is large.
394 if (AddrDelta < 256 + MAX_SPECIAL_ADDR_DELTA) {
395 // Try using a special opcode.
396 Opcode = Temp + AddrDelta * DWARF2_LINE_RANGE;
397 if (Opcode <= 255) {
398 OS << char(Opcode);
399 return;
400 }
401
402 // Try using DW_LNS_const_add_pc followed by special op.
403 Opcode = Temp + (AddrDelta - MAX_SPECIAL_ADDR_DELTA) * DWARF2_LINE_RANGE;
404 if (Opcode <= 255) {
405 OS << char(dwarf::DW_LNS_const_add_pc);
406 OS << char(Opcode);
407 return;
408 }
409 }
410
411 // Otherwise use DW_LNS_advance_pc.
412 OS << char(dwarf::DW_LNS_advance_pc);
413 SmallString<32> Tmp;
414 raw_svector_ostream OSE(Tmp);
415 MCObjectWriter::EncodeULEB128(AddrDelta, OSE);
416 OS << OSE.str();
417
418 if (NeedCopy)
419 OS << char(dwarf::DW_LNS_copy);
420 else
421 OS << char(Temp);
422}
423
Kevin Enderby7cbf73a2010-07-28 20:55:35 +0000424void MCDwarfFile::print(raw_ostream &OS) const {
425 OS << '"' << getName() << '"';
426}
427
428void MCDwarfFile::dump() const {
429 print(dbgs());
430}
Kevin Enderbyc0957932010-09-30 16:52:03 +0000431
Rafael Espindola89b93722010-12-10 07:39:47 +0000432static int getDataAlignmentFactor(MCStreamer &streamer) {
433 MCContext &context = streamer.getContext();
434 const TargetAsmInfo &asmInfo = context.getTargetAsmInfo();
435 int size = asmInfo.getPointerSize();
Anton Korobeynikov16c29b52011-01-10 12:39:04 +0000436 if (asmInfo.getStackGrowthDirection() == TargetFrameLowering::StackGrowsUp)
Rafael Espindola89b93722010-12-10 07:39:47 +0000437 return size;
438 else
439 return -size;
440}
441
Rafael Espindolafe024d02010-12-28 18:36:23 +0000442static void EmitCFIInstruction(MCStreamer &Streamer,
Rafael Espindolab40a71f2010-12-29 01:42:56 +0000443 const MCCFIInstruction &Instr) {
Rafael Espindolafe024d02010-12-28 18:36:23 +0000444 int dataAlignmentFactor = getDataAlignmentFactor(Streamer);
445
446 switch (Instr.getOperation()) {
447 case MCCFIInstruction::Move: {
448 const MachineLocation &Dst = Instr.getDestination();
449 const MachineLocation &Src = Instr.getSource();
450
451 // If advancing cfa.
452 if (Dst.isReg() && Dst.getReg() == MachineLocation::VirtualFP) {
453 assert(!Src.isReg() && "Machine move not supported yet.");
454
455 if (Src.getReg() == MachineLocation::VirtualFP) {
456 Streamer.EmitIntValue(dwarf::DW_CFA_def_cfa_offset, 1);
457 } else {
458 Streamer.EmitIntValue(dwarf::DW_CFA_def_cfa, 1);
Rafael Espindolab40a71f2010-12-29 01:42:56 +0000459 Streamer.EmitULEB128IntValue(Src.getReg());
Rafael Espindolafe024d02010-12-28 18:36:23 +0000460 }
461
462 Streamer.EmitULEB128IntValue(-Src.getOffset(), 1);
463 return;
464 }
465
466 if (Src.isReg() && Src.getReg() == MachineLocation::VirtualFP) {
467 assert(Dst.isReg() && "Machine move not supported yet.");
468 Streamer.EmitIntValue(dwarf::DW_CFA_def_cfa_register, 1);
Rafael Espindolab40a71f2010-12-29 01:42:56 +0000469 Streamer.EmitULEB128IntValue(Dst.getReg());
Rafael Espindolafe024d02010-12-28 18:36:23 +0000470 return;
471 }
472
Rafael Espindolab40a71f2010-12-29 01:42:56 +0000473 unsigned Reg = Src.getReg();
Rafael Espindolafe024d02010-12-28 18:36:23 +0000474 int Offset = Dst.getOffset() / dataAlignmentFactor;
475
476 if (Offset < 0) {
477 Streamer.EmitIntValue(dwarf::DW_CFA_offset_extended_sf, 1);
478 Streamer.EmitULEB128IntValue(Reg);
479 Streamer.EmitSLEB128IntValue(Offset);
480 } else if (Reg < 64) {
481 Streamer.EmitIntValue(dwarf::DW_CFA_offset + Reg, 1);
482 Streamer.EmitULEB128IntValue(Offset, 1);
483 } else {
484 Streamer.EmitIntValue(dwarf::DW_CFA_offset_extended, 1);
485 Streamer.EmitULEB128IntValue(Reg, 1);
486 Streamer.EmitULEB128IntValue(Offset, 1);
487 }
488 return;
489 }
490 case MCCFIInstruction::Remember:
491 Streamer.EmitIntValue(dwarf::DW_CFA_remember_state, 1);
492 return;
493 case MCCFIInstruction::Restore:
494 Streamer.EmitIntValue(dwarf::DW_CFA_restore_state, 1);
495 return;
496 }
497 llvm_unreachable("Unhandled case in switch");
498}
499
Rafael Espindola89b93722010-12-10 07:39:47 +0000500/// EmitFrameMoves - Emit frame instructions to describe the layout of the
501/// frame.
Rafael Espindolafe024d02010-12-28 18:36:23 +0000502static void EmitCFIInstructions(MCStreamer &streamer,
503 const std::vector<MCCFIInstruction> &Instrs,
Rafael Espindolab40a71f2010-12-29 01:42:56 +0000504 MCSymbol *BaseLabel) {
Rafael Espindolafe024d02010-12-28 18:36:23 +0000505 for (unsigned i = 0, N = Instrs.size(); i < N; ++i) {
506 const MCCFIInstruction &Instr = Instrs[i];
507 MCSymbol *Label = Instr.getLabel();
Rafael Espindola89b93722010-12-10 07:39:47 +0000508 // Throw out move if the label is invalid.
509 if (Label && !Label->isDefined()) continue; // Not emitted, in dead code.
510
Rafael Espindola89b93722010-12-10 07:39:47 +0000511 // Advance row if new location.
512 if (BaseLabel && Label) {
513 MCSymbol *ThisSym = Label;
514 if (ThisSym != BaseLabel) {
Rafael Espindola245a1e22010-12-28 05:39:27 +0000515 streamer.EmitDwarfAdvanceFrameAddr(BaseLabel, ThisSym);
Rafael Espindola89b93722010-12-10 07:39:47 +0000516 BaseLabel = ThisSym;
517 }
518 }
519
Rafael Espindolab40a71f2010-12-29 01:42:56 +0000520 EmitCFIInstruction(streamer, Instr);
Rafael Espindola89b93722010-12-10 07:39:47 +0000521 }
522}
523
Rafael Espindolabdc31672010-12-27 15:56:22 +0000524static void EmitSymbol(MCStreamer &streamer, const MCSymbol &symbol,
525 unsigned symbolEncoding) {
526 MCContext &context = streamer.getContext();
527 const TargetAsmInfo &asmInfo = context.getTargetAsmInfo();
528 unsigned format = symbolEncoding & 0x0f;
Rafael Espindolacaf11582010-12-29 04:31:26 +0000529 unsigned application = symbolEncoding & 0x70;
Rafael Espindolabdc31672010-12-27 15:56:22 +0000530 unsigned size;
531 switch (format) {
532 default:
533 assert(0 && "Unknown Encoding");
Rafael Espindolabdc31672010-12-27 15:56:22 +0000534 case dwarf::DW_EH_PE_absptr:
535 case dwarf::DW_EH_PE_signed:
536 size = asmInfo.getPointerSize();
537 break;
538 case dwarf::DW_EH_PE_udata2:
539 case dwarf::DW_EH_PE_sdata2:
540 size = 2;
541 break;
542 case dwarf::DW_EH_PE_udata4:
543 case dwarf::DW_EH_PE_sdata4:
544 size = 4;
545 break;
546 case dwarf::DW_EH_PE_udata8:
547 case dwarf::DW_EH_PE_sdata8:
548 size = 8;
549 break;
550 }
551 switch (application) {
552 default:
553 assert(0 && "Unknown Encoding");
554 break;
555 case 0:
Rafael Espindolabdc31672010-12-27 15:56:22 +0000556 streamer.EmitSymbolValue(&symbol, size);
557 break;
558 case dwarf::DW_EH_PE_pcrel:
559 streamer.EmitPCRelSymbolValue(&symbol, size);
560 break;
561 }
562}
563
Rafael Espindolab40a71f2010-12-29 01:42:56 +0000564static const MachineLocation TranslateMachineLocation(
565 const TargetAsmInfo &AsmInfo,
566 const MachineLocation &Loc) {
567 unsigned Reg = Loc.getReg() == MachineLocation::VirtualFP ?
568 MachineLocation::VirtualFP :
569 unsigned(AsmInfo.getDwarfRegNum(Loc.getReg(), true));
570 const MachineLocation &NewLoc = Loc.isReg() ?
571 MachineLocation(Reg) : MachineLocation(Reg, Loc.getOffset());
572 return NewLoc;
573}
574
Rafael Espindolad7c8cca2010-12-26 20:20:31 +0000575static const MCSymbol &EmitCIE(MCStreamer &streamer,
Rafael Espindola3a83c402010-12-27 00:36:05 +0000576 const MCSymbol *personality,
Rafael Espindolabdc31672010-12-27 15:56:22 +0000577 unsigned personalityEncoding,
578 const MCSymbol *lsda,
579 unsigned lsdaEncoding) {
Rafael Espindola89b93722010-12-10 07:39:47 +0000580 MCContext &context = streamer.getContext();
581 const TargetAsmInfo &asmInfo = context.getTargetAsmInfo();
582 const MCSection &section = *asmInfo.getEHFrameSection();
583 streamer.SwitchSection(&section);
584 MCSymbol *sectionStart = streamer.getContext().CreateTempSymbol();
585 MCSymbol *sectionEnd = streamer.getContext().CreateTempSymbol();
586
587 // Length
588 const MCExpr *Length = MakeStartMinusEndExpr(streamer, *sectionStart,
589 *sectionEnd, 4);
590 streamer.EmitLabel(sectionStart);
591 streamer.EmitValue(Length, 4);
592
593 // CIE ID
594 streamer.EmitIntValue(0, 4);
595
596 // Version
597 streamer.EmitIntValue(dwarf::DW_CIE_VERSION, 1);
598
599 // Augmentation String
600 SmallString<8> Augmentation;
Rafael Espindolad7c8cca2010-12-26 20:20:31 +0000601 Augmentation += "z";
602 if (personality)
603 Augmentation += "P";
Rafael Espindolabdc31672010-12-27 15:56:22 +0000604 if (lsda)
605 Augmentation += "L";
Rafael Espindolad7c8cca2010-12-26 20:20:31 +0000606 Augmentation += "R";
Rafael Espindola89b93722010-12-10 07:39:47 +0000607 streamer.EmitBytes(Augmentation.str(), 0);
608 streamer.EmitIntValue(0, 1);
609
610 // Code Alignment Factor
611 streamer.EmitULEB128IntValue(1);
612
613 // Data Alignment Factor
614 streamer.EmitSLEB128IntValue(getDataAlignmentFactor(streamer));
615
616 // Return Address Register
617 streamer.EmitULEB128IntValue(asmInfo.getDwarfRARegNum(true));
618
619 // Augmentation Data Length (optional)
620 MCSymbol *augmentationStart = streamer.getContext().CreateTempSymbol();
621 MCSymbol *augmentationEnd = streamer.getContext().CreateTempSymbol();
622 const MCExpr *augmentationLength = MakeStartMinusEndExpr(streamer,
623 *augmentationStart,
624 *augmentationEnd, 0);
625 streamer.EmitULEB128Value(augmentationLength);
626
627 // Augmentation Data (optional)
628 streamer.EmitLabel(augmentationStart);
Rafael Espindolad7c8cca2010-12-26 20:20:31 +0000629 if (personality) {
630 // Personality Encoding
Rafael Espindola3a83c402010-12-27 00:36:05 +0000631 streamer.EmitIntValue(personalityEncoding, 1);
Rafael Espindolad7c8cca2010-12-26 20:20:31 +0000632 // Personality
Rafael Espindolabdc31672010-12-27 15:56:22 +0000633 EmitSymbol(streamer, *personality, personalityEncoding);
634 }
635 if (lsda) {
636 // LSDA Encoding
637 streamer.EmitIntValue(lsdaEncoding, 1);
Rafael Espindolad7c8cca2010-12-26 20:20:31 +0000638 }
639 // Encoding of the FDE pointers
Rafael Espindola89b93722010-12-10 07:39:47 +0000640 streamer.EmitIntValue(dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4, 1);
641 streamer.EmitLabel(augmentationEnd);
642
643 // Initial Instructions
644
645 const std::vector<MachineMove> Moves = asmInfo.getInitialFrameState();
Rafael Espindolafe024d02010-12-28 18:36:23 +0000646 std::vector<MCCFIInstruction> Instructions;
Rafael Espindola89b93722010-12-10 07:39:47 +0000647
Rafael Espindolafe024d02010-12-28 18:36:23 +0000648 for (int i = 0, n = Moves.size(); i != n; ++i) {
Rafael Espindolab40a71f2010-12-29 01:42:56 +0000649 MCSymbol *Label = Moves[i].getLabel();
650 const MachineLocation &Dst =
651 TranslateMachineLocation(asmInfo, Moves[i].getDestination());
652 const MachineLocation &Src =
653 TranslateMachineLocation(asmInfo, Moves[i].getSource());
654 MCCFIInstruction Inst(Label, Dst, Src);
Rafael Espindolafe024d02010-12-28 18:36:23 +0000655 Instructions.push_back(Inst);
656 }
657
Rafael Espindolab40a71f2010-12-29 01:42:56 +0000658 EmitCFIInstructions(streamer, Instructions, NULL);
Rafael Espindola89b93722010-12-10 07:39:47 +0000659
660 // Padding
Rafael Espindolad7c8cca2010-12-26 20:20:31 +0000661 streamer.EmitValueToAlignment(4);
Rafael Espindola89b93722010-12-10 07:39:47 +0000662
663 streamer.EmitLabel(sectionEnd);
664 return *sectionStart;
665}
666
Rafael Espindoladfe125c2010-12-17 00:28:02 +0000667static MCSymbol *EmitFDE(MCStreamer &streamer,
668 const MCSymbol &cieStart,
669 const MCDwarfFrameInfo &frame) {
Rafael Espindolabdc31672010-12-27 15:56:22 +0000670 MCContext &context = streamer.getContext();
671 MCSymbol *fdeStart = context.CreateTempSymbol();
672 MCSymbol *fdeEnd = context.CreateTempSymbol();
Rafael Espindola89b93722010-12-10 07:39:47 +0000673
674 // Length
675 const MCExpr *Length = MakeStartMinusEndExpr(streamer, *fdeStart, *fdeEnd, 0);
676 streamer.EmitValue(Length, 4);
677
678 streamer.EmitLabel(fdeStart);
679 // CIE Pointer
680 const MCExpr *offset = MakeStartMinusEndExpr(streamer, cieStart, *fdeStart,
681 0);
682 streamer.EmitValue(offset, 4);
683
684 // PC Begin
685 streamer.EmitPCRelSymbolValue(frame.Begin, 4);
686
687 // PC Range
688 const MCExpr *Range = MakeStartMinusEndExpr(streamer, *frame.Begin,
689 *frame.End, 0);
690 streamer.EmitValue(Range, 4);
691
692 // Augmentation Data Length
Rafael Espindolabdc31672010-12-27 15:56:22 +0000693 MCSymbol *augmentationStart = streamer.getContext().CreateTempSymbol();
694 MCSymbol *augmentationEnd = streamer.getContext().CreateTempSymbol();
695 const MCExpr *augmentationLength = MakeStartMinusEndExpr(streamer,
696 *augmentationStart,
697 *augmentationEnd, 0);
698 streamer.EmitULEB128Value(augmentationLength);
Rafael Espindola89b93722010-12-10 07:39:47 +0000699
700 // Augmentation Data
Rafael Espindolabdc31672010-12-27 15:56:22 +0000701 streamer.EmitLabel(augmentationStart);
702 if (frame.Lsda)
703 EmitSymbol(streamer, *frame.Lsda, frame.LsdaEncoding);
704 streamer.EmitLabel(augmentationEnd);
Rafael Espindola89b93722010-12-10 07:39:47 +0000705 // Call Frame Instructions
706
Rafael Espindolab40a71f2010-12-29 01:42:56 +0000707 EmitCFIInstructions(streamer, frame.Instructions, frame.Begin);
Rafael Espindola5bba0842010-12-28 04:15:37 +0000708
Rafael Espindola89b93722010-12-10 07:39:47 +0000709 // Padding
Rafael Espindoladfe125c2010-12-17 00:28:02 +0000710 streamer.EmitValueToAlignment(4);
711
712 return fdeEnd;
Rafael Espindola89b93722010-12-10 07:39:47 +0000713}
714
Benjamin Kramer19282362010-12-30 22:34:44 +0000715namespace {
716 struct CIEKey {
717 static const CIEKey getEmptyKey() { return CIEKey(0, 0, -1); }
718 static const CIEKey getTombstoneKey() { return CIEKey(0, -1, 0); }
Rafael Espindolabdc31672010-12-27 15:56:22 +0000719
Benjamin Kramer19282362010-12-30 22:34:44 +0000720 CIEKey(const MCSymbol* Personality_, unsigned PersonalityEncoding_,
721 unsigned LsdaEncoding_) : Personality(Personality_),
722 PersonalityEncoding(PersonalityEncoding_),
723 LsdaEncoding(LsdaEncoding_) {
724 }
725 const MCSymbol* Personality;
726 unsigned PersonalityEncoding;
727 unsigned LsdaEncoding;
728 };
729}
Rafael Espindolabdc31672010-12-27 15:56:22 +0000730
731namespace llvm {
732 template <>
733 struct DenseMapInfo<CIEKey> {
734 static CIEKey getEmptyKey() {
Benjamin Kramer19282362010-12-30 22:34:44 +0000735 return CIEKey::getEmptyKey();
Rafael Espindolabdc31672010-12-27 15:56:22 +0000736 }
737 static CIEKey getTombstoneKey() {
Benjamin Kramer19282362010-12-30 22:34:44 +0000738 return CIEKey::getTombstoneKey();
Rafael Espindolabdc31672010-12-27 15:56:22 +0000739 }
740 static unsigned getHashValue(const CIEKey &Key) {
741 FoldingSetNodeID ID;
742 ID.AddPointer(Key.Personality);
743 ID.AddInteger(Key.PersonalityEncoding);
744 ID.AddInteger(Key.LsdaEncoding);
745 return ID.ComputeHash();
746 }
747 static bool isEqual(const CIEKey &LHS,
748 const CIEKey &RHS) {
749 return LHS.Personality == RHS.Personality &&
750 LHS.PersonalityEncoding == RHS.PersonalityEncoding &&
751 LHS.LsdaEncoding == RHS.LsdaEncoding;
752 }
753 };
754}
755
Rafael Espindola89b93722010-12-10 07:39:47 +0000756void MCDwarfFrameEmitter::Emit(MCStreamer &streamer) {
Rafael Espindoladfe125c2010-12-17 00:28:02 +0000757 const MCContext &context = streamer.getContext();
758 const TargetAsmInfo &asmInfo = context.getTargetAsmInfo();
Rafael Espindoladfe125c2010-12-17 00:28:02 +0000759 MCSymbol *fdeEnd = NULL;
Rafael Espindolabdc31672010-12-27 15:56:22 +0000760 DenseMap<CIEKey, const MCSymbol*> CIEStarts;
Rafael Espindolad7c8cca2010-12-26 20:20:31 +0000761
Rafael Espindoladfe125c2010-12-17 00:28:02 +0000762 for (unsigned i = 0, n = streamer.getNumFrameInfos(); i < n; ++i) {
Rafael Espindolad7c8cca2010-12-26 20:20:31 +0000763 const MCDwarfFrameInfo &frame = streamer.getFrameInfo(i);
Rafael Espindolabdc31672010-12-27 15:56:22 +0000764 CIEKey key(frame.Personality, frame.PersonalityEncoding,
765 frame.LsdaEncoding);
766 const MCSymbol *&cieStart = CIEStarts[key];
Rafael Espindolad7c8cca2010-12-26 20:20:31 +0000767 if (!cieStart)
Rafael Espindola3a83c402010-12-27 00:36:05 +0000768 cieStart = &EmitCIE(streamer, frame.Personality,
Rafael Espindolabdc31672010-12-27 15:56:22 +0000769 frame.PersonalityEncoding, frame.Lsda,
770 frame.LsdaEncoding);
Rafael Espindolad7c8cca2010-12-26 20:20:31 +0000771 fdeEnd = EmitFDE(streamer, *cieStart, frame);
Rafael Espindoladfe125c2010-12-17 00:28:02 +0000772 if (i != n - 1)
773 streamer.EmitLabel(fdeEnd);
774 }
Rafael Espindolad7c8cca2010-12-26 20:20:31 +0000775
Rafael Espindoladfe125c2010-12-17 00:28:02 +0000776 streamer.EmitValueToAlignment(asmInfo.getPointerSize());
777 if (fdeEnd)
778 streamer.EmitLabel(fdeEnd);
Rafael Espindola89b93722010-12-10 07:39:47 +0000779}
Rafael Espindola245a1e22010-12-28 05:39:27 +0000780
781void MCDwarfFrameEmitter::EmitAdvanceLoc(MCStreamer &Streamer,
782 uint64_t AddrDelta) {
783 SmallString<256> Tmp;
784 raw_svector_ostream OS(Tmp);
785 MCDwarfFrameEmitter::EncodeAdvanceLoc(AddrDelta, OS);
786 Streamer.EmitBytes(OS.str(), /*AddrSpace=*/0);
787}
788
789void MCDwarfFrameEmitter::EncodeAdvanceLoc(uint64_t AddrDelta,
790 raw_ostream &OS) {
791 // FIXME: Assumes the code alignment factor is 1.
Rafael Espindola3b78cdc2010-12-28 23:38:03 +0000792 if (AddrDelta == 0) {
793 } else if (isUIntN(6, AddrDelta)) {
Rafael Espindola245a1e22010-12-28 05:39:27 +0000794 uint8_t Opcode = dwarf::DW_CFA_advance_loc | AddrDelta;
795 OS << Opcode;
796 } else if (isUInt<8>(AddrDelta)) {
797 OS << uint8_t(dwarf::DW_CFA_advance_loc1);
798 OS << uint8_t(AddrDelta);
799 } else if (isUInt<16>(AddrDelta)) {
Rafael Espindolaa7e45052010-12-29 02:30:49 +0000800 // FIXME: check what is the correct behavior on a big endian machine.
Rafael Espindola245a1e22010-12-28 05:39:27 +0000801 OS << uint8_t(dwarf::DW_CFA_advance_loc2);
Rafael Espindolaa7e45052010-12-29 02:30:49 +0000802 OS << uint8_t( AddrDelta & 0xff);
803 OS << uint8_t((AddrDelta >> 8) & 0xff);
Rafael Espindola245a1e22010-12-28 05:39:27 +0000804 } else {
Rafael Espindolaa7e45052010-12-29 02:30:49 +0000805 // FIXME: check what is the correct behavior on a big endian machine.
Rafael Espindola245a1e22010-12-28 05:39:27 +0000806 assert(isUInt<32>(AddrDelta));
807 OS << uint8_t(dwarf::DW_CFA_advance_loc4);
Rafael Espindolaa7e45052010-12-29 02:30:49 +0000808 OS << uint8_t( AddrDelta & 0xff);
809 OS << uint8_t((AddrDelta >> 8) & 0xff);
810 OS << uint8_t((AddrDelta >> 16) & 0xff);
811 OS << uint8_t((AddrDelta >> 24) & 0xff);
812
Rafael Espindola245a1e22010-12-28 05:39:27 +0000813 }
814}