30 std::vector<uint8_t>
UUID;
33 if (!MachUUID.
empty())
36 const StringRef GNUBuildID(
".note.gnu.build-id");
44 if (SectName != GNUBuildID)
63 if (!UUIDBytes.
empty()) {
64 auto Ptr =
reinterpret_cast<const uint8_t *
>(UUIDBytes.
data());
65 UUID.assign(Ptr, Ptr + UUIDBytes.
size());
101 const bool Is64Bit =
MachO.is64Bit();
106 uint32_t SectFlags, IndirectSymIdxStart, StubByteSize;
120 if (StubByteSize == 0)
123 const uint64_t SectAddr = Sect.getAddress();
124 const uint64_t NumStubs = Sect.getSize() / StubByteSize;
125 for (
uint64_t StubIdx = 0; StubIdx < NumStubs; ++StubIdx) {
126 const uint64_t StubAddr = SectAddr + StubIdx * StubByteSize;
129 const uint64_t IndirectSymIdx = IndirectSymIdxStart + StubIdx;
133 MachO.getIndirectSymbolTableEntry(Dysymtab, IndirectSymIdx);
137 if (SymIdx >= NumSyms)
141 const uint8_t NType = Is64Bit ?
MachO.getSymbol64TableEntry(SymDRI).n_type
142 :
MachO.getSymbolTableEntry(SymDRI).n_type;
151 "ObjectFileTransformer: ");
158 Name->consume_front(
"_");
166 constexpr bool Copy =
true;
167 const std::string StubName =
"symbol stub for: " + Name->str();
205 "ObjectFileTransformer: ");
213 Name->consume_front(
"_");
228 std::optional<SectionRef> DebugDataSect;
229 for (
const SectionRef &Sect : Obj.sections()) {
231 if (!SectNameOrErr) {
235 if (*SectNameOrErr ==
".gnu_debugdata") {
236 DebugDataSect = Sect;
245 Obj, Obj.getDynamicSymbolIterators(), Out, Gsym,
false);
246 if (!DynFunctionsAdded)
249 *Out.GetOS() <<
"Loaded " << *DynFunctionsAdded
250 <<
" functions from dynamic symbol table.\n";
254 "Failed to load the .gnu_debugdata section", [&](
raw_ostream &OS) {
255 OS <<
"warning: unable to read the .gnu_debugdata section: " <<
Msg
262 return Warn(
"missing LZMA support (LLVM_ENABLE_LZMA)");
269 return Warn(
"failed to decompress: " +
toString(std::move(
E)));
274 return Warn(
"failed to parse the embedded ELF object: " +
279 loadSymbols(**DebugObj, (*DebugObj)->symbols(), Out, Gsym,
281 if (!DebugFunctionsAdded)
284 *Out.GetOS() <<
"Loaded " << *DebugFunctionsAdded
285 <<
" functions from .gnu_debugdata symbol table.\n";
300 if (!FunctionsAddedCount)
303 *Out.GetOS() <<
"Loaded " << *FunctionsAddedCount
304 <<
" functions from symbol table.\n";
311 *Out.GetOS() <<
"Loaded " << StubsAddedCount
312 <<
" functions from symbol stubs.\n";
unsigned const MCDisassembler * Decoder
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
std::pair< llvm::MachO::Target, std::string > UUID
Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
Get the array size.
bool empty() const
Check if the array is empty.
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
Error takeError()
Take ownership of the stored error.
reference get()
Returns a reference to the stored T value.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
constexpr bool empty() const
Check if the string is empty.
constexpr size_t size() const
Get the string size.
constexpr const char * data() const
Get a pointer to the start of the string (which may not be null terminated).
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
GsymCreator is used to emit GSYM data to a stand alone file or section within a file.
LLVM_ABI void addFunctionInfo(FunctionInfo &&FI)
Add a function info to this GSYM creator.
LLVM_ABI gsym_strp_t insertString(StringRef S, bool Copy=true)
Insert a string into the GSYM string table.
void setUUID(llvm::ArrayRef< uint8_t > UUIDBytes)
Set the UUID value.
LLVM_ABI size_t getNumFunctionInfos() const
Get the current number of FunctionInfo objects contained in this object.
LLVM_ABI bool IsValidTextAddress(uint64_t Addr) const
Check if an address is a valid code address.
DataRefImpl getRawDataRefImpl() const
This class is the base class for all object file types.
static Expected< std::unique_ptr< ObjectFile > > createELFObjectFile(MemoryBufferRef Object, bool InitContent=true)
iterator_range< symbol_iterator > symbol_iterator_range
This is a value type class that represents a single section in the list of sections in the object fil...
This is a value type class that represents a single symbol in the list of symbols in the object file.
Expected< StringRef > getName() const
This class implements an extremely fast bulk output stream that can only output to a stream.
@ S_SYMBOL_STUBS
S_SYMBOL_STUBS - Section with symbol stubs, byte size of stub in the Reserved2 field.
constexpr uint32_t INDIRECT_SYMBOL_ABS
constexpr uint32_t INDIRECT_SYMBOL_LOCAL
constexpr size_t NameSize
LLVM_ABI bool isAvailable()
Return true if LLVM was built with LZMA support (LLVM_ENABLE_LZMA).
LLVM_ABI Error decompress(ArrayRef< uint8_t > Input, SmallVectorImpl< uint8_t > &Output)
Decompress an xz stream.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI void logAllUnhandledErrors(Error E, raw_ostream &OS, Twine ErrorBanner={})
Log all errors (if any) in E to OS.
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
ArrayRef< CharT > arrayRefFromStringRef(StringRef Input)
Construct an array ref of bytes from a string ref.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
constexpr uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
std::string toString(const APInt &I, unsigned Radix, bool Signed, bool formatAsCLiteral=false, bool UpperCase=true, bool InsertSeparators=false)
void consumeError(Error Err)
Consume a Error without doing anything.
StringRef toStringRef(bool B)
Construct a string ref from a boolean.