diff options
author | Keith Smiley <keithbsmiley@gmail.com> | 2022-02-07 17:33:32 -0800 |
---|---|---|
committer | Keith Smiley <keithbsmiley@gmail.com> | 2022-02-13 09:24:47 -0800 |
commit | a6e1b3c5c223e4868ab77d6d66b62f136b12febc (patch) | |
tree | 775e1872bbdbb3f382c74777108fd2c8e5a7f6e8 /llvm/lib/Object/MachOObjectFile.cpp | |
parent | c45c53bbae2801123776983dbd36a751284fa097 (diff) | |
download | llvm-a6e1b3c5c223e4868ab77d6d66b62f136b12febc.zip llvm-a6e1b3c5c223e4868ab77d6d66b62f136b12febc.tar.gz llvm-a6e1b3c5c223e4868ab77d6d66b62f136b12febc.tar.bz2 |
[ObjectYAML][MachO] Add LC_FUNCTION_STARTS support
This adds support for encoding and decoding the LC_FUNCTION_STARTS load
command payload.
Differential Revision: https://reviews.llvm.org/D119205
Diffstat (limited to 'llvm/lib/Object/MachOObjectFile.cpp')
-rw-r--r-- | llvm/lib/Object/MachOObjectFile.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/llvm/lib/Object/MachOObjectFile.cpp b/llvm/lib/Object/MachOObjectFile.cpp index 909a4cf..85f3824 100644 --- a/llvm/lib/Object/MachOObjectFile.cpp +++ b/llvm/lib/Object/MachOObjectFile.cpp @@ -1303,7 +1303,6 @@ MachOObjectFile::MachOObjectFile(MemoryBufferRef Object, bool IsLittleEndian, } const char *DyldIdLoadCmd = nullptr; - const char *FuncStartsLoadCmd = nullptr; const char *SplitInfoLoadCmd = nullptr; const char *CodeSignDrsLoadCmd = nullptr; const char *CodeSignLoadCmd = nullptr; @@ -4663,6 +4662,21 @@ ArrayRef<uint8_t> MachOObjectFile::getDyldInfoExportsTrie() const { return makeArrayRef(Ptr, DyldInfo.export_size); } +SmallVector<uint64_t> MachOObjectFile::getFunctionStarts() const { + if (!FuncStartsLoadCmd) + return {}; + + auto InfoOrErr = + getStructOrErr<MachO::linkedit_data_command>(*this, FuncStartsLoadCmd); + if (!InfoOrErr) + return {}; + + MachO::linkedit_data_command Info = InfoOrErr.get(); + SmallVector<uint64_t, 8> FunctionStarts; + this->ReadULEB128s(Info.dataoff, FunctionStarts); + return std::move(FunctionStarts); +} + ArrayRef<uint8_t> MachOObjectFile::getUuid() const { if (!UuidLoadCmd) return None; |