41 std::shared_ptr<orc::SymbolStringPool> SSP,
Triple TT,
56 assert(!GraphSymbols[SymIndex] &&
"Duplicate symbol at index");
57 GraphSymbols[SymIndex] = &Sym;
59 SymbolSets[SecIndex].insert({Sym.
getOffset(), &Sym});
66 return GraphSymbols[SymIndex];
70 assert(!GraphBlocks[SecIndex] &&
"Duplicate section at index");
72 GraphBlocks[SecIndex] =
B;
79 return GraphBlocks[SecIndex];
83 auto &ImageBase = G->addExternalSymbol(G->intern(Name), 0,
true);
89 return Obj.sections();
97 template <
typename RelocHandlerFunction>
99 RelocHandlerFunction &&Func,
100 bool ProcessDebugSections =
false);
105 template <
typename ClassT,
typename RelocHandlerMethod>
107 RelocHandlerMethod &&Method,
108 bool ProcessDebugSections =
false) {
111 [Instance, Method](
const auto &Rel,
const auto &
Target,
auto &GS) {
112 return (Instance->*Method)(Rel,
Target, GS);
114 ProcessDebugSections);
120 struct ComdatExportRequest {
125 std::vector<std::optional<ComdatExportRequest>> PendingComdatExports;
129 struct WeakExternalRequest {
135 std::vector<WeakExternalRequest> WeakExternalRequests;
139 using SymbolSet = std::set<std::pair<orc::ExecutorAddrDiff, Symbol *>>;
140 std::vector<SymbolSet> SymbolSets;
142 Section &getCommonSection();
145 orc::SymbolStringPtr SymbolName,
146 object::COFFSymbolRef Symbol,
147 const object::coff_section *Section);
148 Expected<Symbol *> createAliasSymbol(orc::SymbolStringPtr SymbolName,
149 Linkage L, Scope S, Symbol &Target);
151 orc::SymbolStringPtr SymbolName,
152 object::COFFSymbolRef Symbol,
153 const object::coff_section *Section);
154 Expected<Symbol *> createCOMDATExportRequest(
156 const object::coff_aux_section_definition *Definition);
158 orc::SymbolStringPtr SymbolName,
159 object::COFFSymbolRef Symbol);
161 Error handleDirectiveSection(StringRef Str);
162 Error flushWeakAliasRequests();
163 Error handleAlternateNames();
164 Error calculateImplicitSizeOfSymbols();
166 static uint64_t getSectionAddress(
const object::COFFObjectFile &Obj,
167 const object::coff_section *Section);
168 static uint64_t getSectionSize(
const object::COFFObjectFile &Obj,
169 const object::coff_section *Section);
170 static bool isComdatSection(
const object::coff_section *Section);
171 static unsigned getPointerSize(
const object::COFFObjectFile &Obj);
173 static StringRef getDLLImportStubPrefix() {
return "__imp_"; }
174 static StringRef getDirectiveSectionName() {
return ".drectve"; }
176 const object::coff_section *Sec,
177 object::COFFSymbolRef Sym);
179 const object::COFFObjectFile &Obj;
180 std::unique_ptr<LinkGraph> G;
181 COFFDirectiveParser DirectiveParser;
183 Section *CommonSection =
nullptr;
184 std::vector<Block *> GraphBlocks;
185 std::vector<Symbol *> GraphSymbols;
187 DenseMap<orc::SymbolStringPtr, orc::SymbolStringPtr> AlternateNames;
188 DenseMap<orc::SymbolStringPtr, Symbol *> ExternalSymbols;
189 DenseMap<orc::SymbolStringPtr, Symbol *> DefinedSymbols;