39 std::shared_ptr<orc::SymbolStringPool> SSP,
Triple TT,
54 assert(!GraphSymbols[SymIndex] &&
"Duplicate symbol at index");
55 GraphSymbols[SymIndex] = &Sym;
57 SymbolSets[SecIndex].insert({Sym.
getOffset(), &Sym});
64 return GraphSymbols[SymIndex];
68 assert(!GraphBlocks[SecIndex] &&
"Duplicate section at index");
70 GraphBlocks[SecIndex] =
B;
77 return GraphBlocks[SecIndex];
81 auto &ImageBase = G->addExternalSymbol(G->intern(Name), 0,
true);
87 return Obj.sections();
95 template <
typename RelocHandlerFunction>
97 RelocHandlerFunction &&Func,
98 bool ProcessDebugSections =
false);
103 template <
typename ClassT,
typename RelocHandlerMethod>
105 RelocHandlerMethod &&Method,
106 bool ProcessDebugSections =
false) {
109 [Instance, Method](
const auto &Rel,
const auto &
Target,
auto &GS) {
110 return (Instance->*Method)(Rel,
Target, GS);
112 ProcessDebugSections);
118 struct ComdatExportRequest {
123 std::vector<std::optional<ComdatExportRequest>> PendingComdatExports;
127 struct WeakExternalRequest {
133 std::vector<WeakExternalRequest> WeakExternalRequests;
137 using SymbolSet = std::set<std::pair<orc::ExecutorAddrDiff, Symbol *>>;
138 std::vector<SymbolSet> SymbolSets;
140 Section &getCommonSection();
143 orc::SymbolStringPtr SymbolName,
144 object::COFFSymbolRef Symbol,
145 const object::coff_section *Section);
146 Expected<Symbol *> createAliasSymbol(orc::SymbolStringPtr SymbolName,
147 Linkage L, Scope S, Symbol &Target);
149 orc::SymbolStringPtr SymbolName,
150 object::COFFSymbolRef Symbol,
151 const object::coff_section *Section);
152 Expected<Symbol *> createCOMDATExportRequest(
154 const object::coff_aux_section_definition *Definition);
156 orc::SymbolStringPtr SymbolName,
157 object::COFFSymbolRef Symbol);
159 Error handleDirectiveSection(StringRef Str);
160 Error flushWeakAliasRequests();
161 Error handleAlternateNames();
162 Error calculateImplicitSizeOfSymbols();
164 static uint64_t getSectionAddress(
const object::COFFObjectFile &Obj,
165 const object::coff_section *Section);
166 static uint64_t getSectionSize(
const object::COFFObjectFile &Obj,
167 const object::coff_section *Section);
168 static bool isComdatSection(
const object::coff_section *Section);
169 static unsigned getPointerSize(
const object::COFFObjectFile &Obj);
171 static StringRef getDLLImportStubPrefix() {
return "__imp_"; }
172 static StringRef getDirectiveSectionName() {
return ".drectve"; }
174 const object::coff_section *Sec,
175 object::COFFSymbolRef Sym);
177 const object::COFFObjectFile &Obj;
178 std::unique_ptr<LinkGraph> G;
179 COFFDirectiveParser DirectiveParser;
181 Section *CommonSection =
nullptr;
182 std::vector<Block *> GraphBlocks;
183 std::vector<Symbol *> GraphSymbols;
185 DenseMap<orc::SymbolStringPtr, orc::SymbolStringPtr> AlternateNames;
186 DenseMap<orc::SymbolStringPtr, Symbol *> ExternalSymbols;
187 DenseMap<orc::SymbolStringPtr, Symbol *> DefinedSymbols;