1 //===-- WebAssemblyELFObjectWriter.cpp - WebAssembly ELF Writer -----------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 /// \brief This file handles ELF-specific object emission, converting LLVM's
12 /// internal fixups into the appropriate relocations.
14 //===----------------------------------------------------------------------===//
16 #include "MCTargetDesc/WebAssemblyMCTargetDesc.h"
17 #include "llvm/MC/MCELFObjectWriter.h"
18 #include "llvm/MC/MCFixup.h"
19 #include "llvm/Support/ErrorHandling.h"
23 class WebAssemblyELFObjectWriter final : public MCELFObjectTargetWriter {
25 WebAssemblyELFObjectWriter(bool Is64Bit, uint8_t OSABI);
28 unsigned GetRelocType(const MCValue &Target, const MCFixup &Fixup,
29 bool IsPCRel) const override;
31 } // end anonymous namespace
33 // FIXME: Use EM_NONE as a temporary hack. Should we decide to pursue ELF
34 // writing seriously, we should email generic-abi@googlegroups.com and ask
35 // for our own ELF code.
36 WebAssemblyELFObjectWriter::WebAssemblyELFObjectWriter(bool Is64Bit,
38 : MCELFObjectTargetWriter(Is64Bit, OSABI, ELF::EM_NONE,
39 /*HasRelocationAddend=*/true) {}
41 unsigned WebAssemblyELFObjectWriter::GetRelocType(const MCValue &Target,
44 // FIXME: Do we need our own relocs?
45 return Fixup.getKind();
48 MCObjectWriter *llvm::createWebAssemblyELFObjectWriter(raw_pwrite_stream &OS,
51 MCELFObjectTargetWriter *MOTW =
52 new WebAssemblyELFObjectWriter(Is64Bit, OSABI);
53 return createELFObjectWriter(MOTW, OS, /*IsLittleEndian=*/true);