blob: 5f6a57980ad45ac3b4212b949c4002b9549ededa [file] [log] [blame]
Tim Northover53d32512014-03-29 07:34:53 +00001//===-- llvm/MC/MCLinkerOptimizationHint.cpp ----- LOH handling -*- C++ -*-===//
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
10#include "llvm/MC/MCLinkerOptimizationHint.h"
11#include "llvm/MC/MCAsmLayout.h"
Pete Cooper885bd8a2015-03-04 01:24:24 +000012#include "llvm/MC/MCAssembler.h"
Chandler Carruthd9903882015-01-14 11:23:27 +000013#include "llvm/Support/LEB128.h"
Tim Northover53d32512014-03-29 07:34:53 +000014
15using namespace llvm;
16
Quentin Colombet3c2b13b2014-04-02 01:02:28 +000017// Each LOH is composed by, in this order (each field is encoded using ULEB128):
18// - Its kind.
19// - Its number of arguments (let say N).
20// - Its arg1.
21// - ...
22// - Its argN.
23// <arg1> to <argN> are absolute addresses in the object file, i.e.,
24// relative addresses from the beginning of the object file.
Jim Grosbach249af2a2015-06-01 23:55:06 +000025void MCLOHDirective::emit_impl(raw_ostream &OutStream,
Tim Northover53d32512014-03-29 07:34:53 +000026 const MachObjectWriter &ObjWriter,
27 const MCAsmLayout &Layout) const {
Tim Northover53d32512014-03-29 07:34:53 +000028 encodeULEB128(Kind, OutStream);
29 encodeULEB128(Args.size(), OutStream);
30 for (LOHArgs::const_iterator It = Args.begin(), EndIt = Args.end();
31 It != EndIt; ++It)
Duncan P. N. Exon Smith99d8a8e2015-05-20 00:02:39 +000032 encodeULEB128(ObjWriter.getSymbolAddress(**It, Layout), OutStream);
Tim Northover53d32512014-03-29 07:34:53 +000033}