2014-03-29 07:34:53 +00:00
|
|
|
//===-- llvm/MC/MCLinkerOptimizationHint.cpp ----- LOH handling -*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "llvm/MC/MCLinkerOptimizationHint.h"
|
|
|
|
#include "llvm/MC/MCAsmLayout.h"
|
2015-03-04 01:24:24 +00:00
|
|
|
#include "llvm/MC/MCAssembler.h"
|
2015-01-14 11:23:27 +00:00
|
|
|
#include "llvm/Support/LEB128.h"
|
2014-03-29 07:34:53 +00:00
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
2014-04-02 01:02:28 +00:00
|
|
|
// Each LOH is composed by, in this order (each field is encoded using ULEB128):
|
|
|
|
// - Its kind.
|
|
|
|
// - Its number of arguments (let say N).
|
|
|
|
// - Its arg1.
|
|
|
|
// - ...
|
|
|
|
// - Its argN.
|
|
|
|
// <arg1> to <argN> are absolute addresses in the object file, i.e.,
|
|
|
|
// relative addresses from the beginning of the object file.
|
2015-06-01 23:55:06 +00:00
|
|
|
void MCLOHDirective::emit_impl(raw_ostream &OutStream,
|
2014-03-29 07:34:53 +00:00
|
|
|
const MachObjectWriter &ObjWriter,
|
|
|
|
const MCAsmLayout &Layout) const {
|
|
|
|
encodeULEB128(Kind, OutStream);
|
|
|
|
encodeULEB128(Args.size(), OutStream);
|
|
|
|
for (LOHArgs::const_iterator It = Args.begin(), EndIt = Args.end();
|
|
|
|
It != EndIt; ++It)
|
2015-05-20 00:02:39 +00:00
|
|
|
encodeULEB128(ObjWriter.getSymbolAddress(**It, Layout), OutStream);
|
2014-03-29 07:34:53 +00:00
|
|
|
}
|