text: /*
   * This file is part of QBDI.
   *
   * Copyright 2017 Quarkslab
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  #ifndef INMEMORYASSEMBLER_H
  #define INMEMORYASSEMBLER_H
  
  #include <gtest/gtest.h>
  
  #include "llvm/ADT/Triple.h"
  #include "llvm/ADT/SmallVector.h"
  #include "llvm/MC/MCAsmBackend.h"
  #include "llvm/MC/MCAsmInfo.h"
  #include "llvm/MC/MCContext.h"
  #include "llvm/MC/MCCodeEmitter.h"
  #include "llvm/MC/MCDisassembler/MCDisassembler.h"
  #include "llvm/MC/MCInstrInfo.h"
  #include "llvm/MC/MCObjectFileInfo.h"
  #include "llvm/MC/MCParser/MCAsmParser.h"
  #include "llvm/MC/MCRegisterInfo.h"
  #include "llvm/MC/MCTargetOptions.h"
  #include "llvm/MC/MCParser/MCTargetAsmParser.h"
  #include "llvm/MC/MCSubtargetInfo.h"
  #include "llvm/MC/MCStreamer.h"
  #include "llvm/MC/SubtargetFeature.h"
  #include "llvm/Object/ObjectFile.h"
  #include "llvm/Support/CommandLine.h"
  #include "llvm/Support/FileUtilities.h"
  #include "llvm/Support/ManagedStatic.h"
  #include "llvm/Support/Memory.h"
  #include "llvm/Support/Process.h"
  #include "llvm/Support/SourceMgr.h"
  #include "llvm/Support/TargetRegistry.h"
  #include "llvm/Support/TargetSelect.h"
  
  class InMemoryObject {
  
  protected:
  
      using PF = llvm::sys::Memory::ProtectionFlags;
  
      llvm::sys::MemoryBlock                   objectBlock;
      llvm::ArrayRef<uint8_t>                  code;
      
  public:
  
      InMemoryObject(const char* source, const char* cpu = "", const char** mattrs = nullptr);
  
      llvm::ArrayRef<uint8_t> getCode() { return code; }
  };
  
  #endif
  