MCLinkerOptimizationHint.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. //===-- 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. #include "llvm/MC/MCLinkerOptimizationHint.h"
  10. #include "llvm/MC/MCAsmLayout.h"
  11. #include "llvm/MC/MCAssembler.h"
  12. #include "llvm/Support/LEB128.h"
  13. using namespace llvm;
  14. // Each LOH is composed by, in this order (each field is encoded using ULEB128):
  15. // - Its kind.
  16. // - Its number of arguments (let say N).
  17. // - Its arg1.
  18. // - ...
  19. // - Its argN.
  20. // <arg1> to <argN> are absolute addresses in the object file, i.e.,
  21. // relative addresses from the beginning of the object file.
  22. void MCLOHDirective::emit_impl(raw_ostream &OutStream,
  23. const MachObjectWriter &ObjWriter,
  24. const MCAsmLayout &Layout) const {
  25. encodeULEB128(Kind, OutStream);
  26. encodeULEB128(Args.size(), OutStream);
  27. for (LOHArgs::const_iterator It = Args.begin(), EndIt = Args.end();
  28. It != EndIt; ++It)
  29. encodeULEB128(ObjWriter.getSymbolAddress(**It, Layout), OutStream);
  30. }