LLVM API Documentation
00001 //===-- llvm/MC/MCLinkerOptimizationHint.cpp ----- LOH handling -*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 00010 #include "llvm/MC/MCLinkerOptimizationHint.h" 00011 #include "llvm/MC/MCAsmLayout.h" 00012 #include "llvm/Support/LEB128.h" 00013 #include "llvm/MC/MCStreamer.h" 00014 00015 using namespace llvm; 00016 00017 // Each LOH is composed by, in this order (each field is encoded using ULEB128): 00018 // - Its kind. 00019 // - Its number of arguments (let say N). 00020 // - Its arg1. 00021 // - ... 00022 // - Its argN. 00023 // <arg1> to <argN> are absolute addresses in the object file, i.e., 00024 // relative addresses from the beginning of the object file. 00025 void MCLOHDirective::Emit_impl(raw_ostream &OutStream, 00026 const MachObjectWriter &ObjWriter, 00027 const MCAsmLayout &Layout) const { 00028 const MCAssembler &Asm = Layout.getAssembler(); 00029 encodeULEB128(Kind, OutStream); 00030 encodeULEB128(Args.size(), OutStream); 00031 for (LOHArgs::const_iterator It = Args.begin(), EndIt = Args.end(); 00032 It != EndIt; ++It) 00033 encodeULEB128(ObjWriter.getSymbolAddress(&Asm.getSymbolData(**It), Layout), 00034 OutStream); 00035 }