Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:43:54

0001 //===---- SectCreate.h -- Emulates ld64's -sectcreate option ----*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 // Emulates ld64's -sectcreate option.
0010 //
0011 //===----------------------------------------------------------------------===//
0012 
0013 #ifndef LLVM_EXECUTIONENGINE_ORC_SECTCREATE_H
0014 #define LLVM_EXECUTIONENGINE_ORC_SECTCREATE_H
0015 
0016 #include "llvm/ExecutionEngine/Orc/Core.h"
0017 #include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h"
0018 
0019 #include <utility>
0020 #include <vector>
0021 
0022 namespace llvm::orc {
0023 
0024 class SectCreateMaterializationUnit : public MaterializationUnit {
0025 public:
0026   struct ExtraSymbolInfo {
0027     JITSymbolFlags Flags;
0028     size_t Offset = 0;
0029   };
0030 
0031   using ExtraSymbolsMap = DenseMap<SymbolStringPtr, ExtraSymbolInfo>;
0032 
0033   SectCreateMaterializationUnit(
0034       ObjectLinkingLayer &ObjLinkingLayer, std::string SectName, MemProt MP,
0035       uint64_t Alignment, std::unique_ptr<MemoryBuffer> Data,
0036       ExtraSymbolsMap ExtraSymbols = ExtraSymbolsMap())
0037       : MaterializationUnit(getInterface(ExtraSymbols)),
0038         ObjLinkingLayer(ObjLinkingLayer), SectName(std::move(SectName)), MP(MP),
0039         Alignment(Alignment), Data(std::move(Data)),
0040         ExtraSymbols(std::move(ExtraSymbols)) {}
0041 
0042   StringRef getName() const override { return "SectCreate"; }
0043 
0044   void materialize(std::unique_ptr<MaterializationResponsibility> R) override;
0045 
0046 private:
0047   void discard(const JITDylib &JD, const SymbolStringPtr &Name) override;
0048 
0049   static Interface getInterface(const ExtraSymbolsMap &ExtraSymbols);
0050 
0051   ObjectLinkingLayer &ObjLinkingLayer;
0052   std::string SectName;
0053   MemProt MP;
0054   uint64_t Alignment;
0055   std::unique_ptr<MemoryBuffer> Data;
0056   ExtraSymbolsMap ExtraSymbols;
0057 };
0058 
0059 } // namespace llvm::orc
0060 
0061 #endif // LLVM_EXECUTIONENGINE_ORC_SECTCREATE_H