diff options
author | Michael J. Spencer <bigcheesegs@gmail.com> | 2011-10-17 23:54:46 +0000 |
---|---|---|
committer | Michael J. Spencer <bigcheesegs@gmail.com> | 2011-10-17 23:54:46 +0000 |
commit | 9b2b812fea4df160437e7b7d56e38f6335189ad0 (patch) | |
tree | aa3bfb402beebb9c71d8a7a64fb253eccdf0a8ac /lib/Object/MachOObjectFile.cpp | |
parent | c38c36a8c44bd32bdfc2e48ab3e447f6dc1547bd (diff) |
Object: Add isSymbolAbsolute and getSymbolSection.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142317 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Object/MachOObjectFile.cpp')
-rw-r--r-- | lib/Object/MachOObjectFile.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/lib/Object/MachOObjectFile.cpp b/lib/Object/MachOObjectFile.cpp index c757dd3590..472e0727c3 100644 --- a/lib/Object/MachOObjectFile.cpp +++ b/lib/Object/MachOObjectFile.cpp @@ -242,6 +242,43 @@ error_code MachOObjectFile::isSymbolWeak(DataRefImpl Symb, bool &Res) const { return object_error::success; } +error_code MachOObjectFile::isSymbolAbsolute(DataRefImpl Symb, bool &Res) const{ + uint8_t n_type; + if (MachOObj->is64Bit()) { + InMemoryStruct<macho::Symbol64TableEntry> Entry; + getSymbol64TableEntry(Symb, Entry); + n_type = Entry->Type; + } else { + InMemoryStruct<macho::SymbolTableEntry> Entry; + getSymbolTableEntry(Symb, Entry); + n_type = Entry->Type; + } + + Res = (n_type & MachO::NlistMaskType) == MachO::NListTypeAbsolute; + return object_error::success; +} + +error_code MachOObjectFile::getSymbolSection(DataRefImpl Symb, + section_iterator &Res) const { + uint8_t index; + if (MachOObj->is64Bit()) { + InMemoryStruct<macho::Symbol64TableEntry> Entry; + getSymbol64TableEntry(Symb, Entry); + index = Entry->SectionIndex; + } else { + InMemoryStruct<macho::SymbolTableEntry> Entry; + getSymbolTableEntry(Symb, Entry); + index = Entry->SectionIndex; + } + + if (index == 0) + Res = end_sections(); + else + Res = section_iterator(SectionRef(Sections[index], this)); + + return object_error::success; +} + error_code MachOObjectFile::getSymbolType(DataRefImpl Symb, SymbolRef::Type &Res) const { uint8_t n_type; |