| 1 | //===----- XCOFFLinkGraphBuilder.h - XCOFF LinkGraph builder ----*- C++ -*-===// |
|---|---|
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | // |
| 9 | // Generic XCOFF LinkGraph building code. |
| 10 | // |
| 11 | //===----------------------------------------------------------------------===// |
| 12 | |
| 13 | #ifndef LIB_EXECUTIONENGINE_JITLINK_XCOFFLINKGRAPHBUILDER_H |
| 14 | #define LIB_EXECUTIONENGINE_JITLINK_XCOFFLINKGRAPHBUILDER_H |
| 15 | |
| 16 | #include "llvm/ExecutionEngine/JITLink/JITLink.h" |
| 17 | #include "llvm/ExecutionEngine/Orc/SymbolStringPool.h" |
| 18 | #include "llvm/Object/ObjectFile.h" |
| 19 | #include "llvm/Object/XCOFFObjectFile.h" |
| 20 | #include "llvm/TargetParser/SubtargetFeature.h" |
| 21 | #include <memory> |
| 22 | |
| 23 | namespace llvm { |
| 24 | namespace jitlink { |
| 25 | |
| 26 | class XCOFFLinkGraphBuilder { |
| 27 | public: |
| 28 | virtual ~XCOFFLinkGraphBuilder() = default; |
| 29 | Expected<std::unique_ptr<LinkGraph>> buildGraph(); |
| 30 | |
| 31 | public: |
| 32 | XCOFFLinkGraphBuilder(const object::XCOFFObjectFile &Obj, |
| 33 | std::shared_ptr<orc::SymbolStringPool> SSP, Triple TT, |
| 34 | SubtargetFeatures Features, |
| 35 | LinkGraph::GetEdgeKindNameFunction GetEdgeKindName); |
| 36 | LinkGraph &getGraph() const { return *G; } |
| 37 | const object::XCOFFObjectFile &getObject() const { return Obj; } |
| 38 | |
| 39 | private: |
| 40 | Error processSections(); |
| 41 | Error processCsectsAndSymbols(); |
| 42 | Error processRelocations(); |
| 43 | |
| 44 | private: |
| 45 | const object::XCOFFObjectFile &Obj; |
| 46 | std::unique_ptr<LinkGraph> G; |
| 47 | |
| 48 | Section *UndefSection; |
| 49 | |
| 50 | struct SectionEntry { |
| 51 | jitlink::Section *Section; |
| 52 | object::SectionRef SectionData; |
| 53 | }; |
| 54 | |
| 55 | DenseMap<uint16_t, SectionEntry> SectionTable; |
| 56 | DenseMap<uint32_t, Block *> CsectTable; |
| 57 | DenseMap<uint32_t, Symbol *> SymbolIndexTable; |
| 58 | }; |
| 59 | |
| 60 | } // namespace jitlink |
| 61 | } // namespace llvm |
| 62 | |
| 63 | #endif // LIB_EXECUTIONENGINE_JITLINK_XCOFFLINKGRAPHBUILDER_H |
| 64 |