LLVM 24.0.0git
ObjectFileTransformer.cpp File Reference

Go to the source code of this file.

Functions

static std::vector< uint8_t > getUUID (const object::ObjectFile &Obj)
static uint64_t addMachOSymbolStubs (const object::MachOObjectFile &MachO, OutputAggregator &Out, GsymCreator &Gsym)
 Create function information entries for Mach-O symbol stubs.

Variables

constexpr uint32_t NT_GNU_BUILD_ID_TAG = 0x03

Function Documentation

◆ addMachOSymbolStubs()

uint64_t addMachOSymbolStubs ( const object::MachOObjectFile & MachO,
OutputAggregator & Out,
GsymCreator & Gsym )
static

Create function information entries for Mach-O symbol stubs.

Symbol stubs are small chunks of code, all with the same fixed size, that resolves a function pointer on first call and then jumps to the resolved function on subsequent calls for functions that live in another shared library. The stubs are stored in sections whose type is S_SYMBOL_STUBS and the size of a single stub is stored in the "reserved2" field of the section header. These stubs have no entries in the symbol table of their own, so they end up being attributed to whatever function precedes them unless they are synthesized here.

The name of the function a stub jumps to is found using the indirect symbol table from the LC_DYSYMTAB load command. The "reserved1" field of the section header contains the index of the indirect symbol table entry that describes the first stub in the section, and each subsequent stub is described by the entry that follows. Each indirect symbol table entry is an index into the symbol table where the matching undefined (N_UNDF) symbol supplies the name to use for the stub. Each name gets a "symbol stub for: " prefix prepended to it so that symbolication makes it clear that the address is the stub for a function and not the function itself.

Returns
The number of function infos that were added to Gsym.

Definition at line 93 of file ObjectFileTransformer.cpp.

References llvm::gsym::GsymCreator::addFunctionInfo(), llvm::consumeError(), llvm::MachO::section::flags, llvm::MachO::section_64::flags, llvm::gsym::FunctionInfo, llvm::object::SymbolRef::getName(), llvm::gsym::GsymCreator::getNumFunctionInfos(), llvm::object::BasicSymbolRef::getRawDataRefImpl(), llvm::MachO::INDIRECT_SYMBOL_ABS, llvm::MachO::INDIRECT_SYMBOL_LOCAL, llvm::gsym::GsymCreator::insertString(), llvm::gsym::GsymCreator::IsValidTextAddress(), llvm::logAllUnhandledErrors(), llvm::MachO::N_TYPE, llvm::MachO::N_UNDF, llvm::MachO::dysymtab_command::nindirectsyms, llvm::MachO::section::reserved1, llvm::MachO::section_64::reserved1, llvm::MachO::section::reserved2, llvm::MachO::section_64::reserved2, llvm::MachO::S_SYMBOL_STUBS, llvm::MachO::SECTION_TYPE, and uint64_t.

Referenced by llvm::gsym::ObjectFileTransformer::convert().

◆ getUUID()

Variable Documentation

◆ NT_GNU_BUILD_ID_TAG

uint32_t NT_GNU_BUILD_ID_TAG = 0x03
constexpr

Definition at line 24 of file ObjectFileTransformer.cpp.

Referenced by getUUID().