21#define DEBUG_TYPE "orc"
28 assert(!
I.InitSymbol &&
"I already has an init symbol");
32 std::string InitSymString;
34 <<
"$." << ObjFileName <<
".__inits." << Counter++;
35 I.InitSymbol = ES.
intern(InitSymString);
36 }
while (
I.SymbolFlags.count(
I.InitSymbol));
61 if (
auto SymType =
Sym.getType()) {
65 return SymType.takeError();
69 return Name.takeError();
72 return SymFlags.takeError();
75 if (
Name->starts_with(
"l"))
78 I.SymbolFlags[ES.
intern(*
Name)] = std::move(*SymFlags);
118 if (
auto SymType =
Sym.getType()) {
122 return SymType.takeError();
126 return Name.takeError();
130 return SymFlags.takeError();
136 I.SymbolFlags[ES.
intern(*
Name)] = std::move(*SymFlags);
141 if (
auto SecName = Sec.getName()) {
156 std::vector<std::optional<object::coff_aux_section_definition>> ComdatDefs(
167 if (
auto *Def = COFFSym.getSectionDefinition()) {
168 auto Sec = Obj.
getSection(COFFSym.getSectionNumber());
170 return Sec.takeError();
173 ComdatDefs[COFFSym.getSectionNumber()] = *Def;
178 ComdatDefs[COFFSym.getSectionNumber()]) {
179 auto Def = ComdatDefs[COFFSym.getSectionNumber()];
183 ComdatDefs[COFFSym.getSectionNumber()] = std::nullopt;
195 if (
auto SymType =
Sym.getType()) {
199 return SymType.takeError();
203 return Name.takeError();
207 return SymFlags.takeError();
211 if (COFFSym.isWeakExternal())
217 I.SymbolFlags[ES.
intern(*
Name)] = std::move(*SymFlags);
222 if (
auto SecName = Sec.getName()) {
228 return SecName.takeError();
254 if (
auto SymType =
Sym.getType()) {
258 return SymType.takeError();
262 return Name.takeError();
266 return SymFlags.takeError();
268 I.SymbolFlags[ES.
intern(*
Name)] = std::move(*SymFlags);
279 return Obj.takeError();
281 if (
auto *MachOObj = dyn_cast<object::MachOObjectFile>(Obj->get()))
283 else if (
auto *ELFObj = dyn_cast<object::ELFObjectFileBase>(Obj->get()))
285 else if (
auto *COFFObj = dyn_cast<object::COFFObjectFile>(Obj->get()))
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Tagged union holding either a T or a Error.
Error takeError()
Take ownership of the stored error.
Flags for symbols in the JIT.
static Expected< JITSymbolFlags > fromObjectSymbol(const object::SymbolRef &Symbol)
Construct a JITSymbolFlags value based on the flags of the given libobject symbol.
@ MaterializationSideEffectsOnly
StringRef - Represent a constant reference to a string, i.e.
StringRef getFileName() const
uint32_t getNumberOfSections() const
Expected< const coff_section * > getSection(int32_t index) const
COFFSymbolRef getCOFFSymbol(const DataRefImpl &Ref) const
elf_symbol_iterator_range symbols() const
unsigned getSectionType(SectionRef Sec) const
StringRef getSectionFinalSegmentName(DataRefImpl Sec) const
Expected< StringRef > getSectionName(DataRefImpl Sec) const override
This class is the base class for all object file types.
section_iterator_range sections() const
static Expected< OwningBinary< ObjectFile > > createObjectFile(StringRef ObjectPath)
symbol_iterator_range symbols() const
An ExecutionSession represents a running JIT program.
SymbolStringPtr intern(StringRef SymName)
Add a symbol name to the SymbolStringPool and return a pointer to it.
Pointer to a pooled string representing a symbol name.
A raw_ostream that writes to an std::string.
@ IMAGE_COMDAT_SELECT_NODUPLICATES
@ IMAGE_COMDAT_SELECT_ASSOCIATIVE
bool isReservedSectionNumber(int32_t SectionNumber)
@ S_MOD_INIT_FUNC_POINTERS
S_MOD_INIT_FUNC_POINTERS - Section with only function pointers for initialization.
void addInitSymbol(MaterializationUnit::Interface &I, ExecutionSession &ES, StringRef ObjFileName)
Adds an initializer symbol to the given MU interface.
static Expected< MaterializationUnit::Interface > getMachOObjectFileSymbolInfo(ExecutionSession &ES, const object::MachOObjectFile &Obj)
Expected< MaterializationUnit::Interface > getGenericObjectFileSymbolInfo(ExecutionSession &ES, const object::ObjectFile &Obj)
static Expected< MaterializationUnit::Interface > getELFObjectFileSymbolInfo(ExecutionSession &ES, const object::ELFObjectFileBase &Obj)
bool isMachOInitializerSection(StringRef SegName, StringRef SecName)
Expected< MaterializationUnit::Interface > getObjectFileInterface(ExecutionSession &ES, MemoryBufferRef ObjBuffer)
Returns a MaterializationUnit::Interface for the object file contained in the given buffer,...
bool isCOFFInitializerSection(StringRef Name)
static Expected< MaterializationUnit::Interface > getCOFFObjectFileSymbolInfo(ExecutionSession &ES, const object::COFFObjectFile &Obj)
bool isELFInitializerSection(StringRef SecName)
This is an optimization pass for GlobalISel generic memory operations.
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.