mirror of
https://github.com/QuasarApp/macdependency.git
synced 2025-04-26 20:34:31 +00:00
- Applied all recommended XCode (8) settings. - Removed boost and replaced that code by standard functions. - Implemented name mangling via abi::__cxa_demangle instead of running an external process to use c++filt. - Enabled C++11. Min deployment target is now OSX 10.7. - Some code clean up (e.g. formatting, std namespace).
47 lines
1.0 KiB
C++
47 lines
1.0 KiB
C++
#include "symboltableentry.h"
|
|
#include "macho.h"
|
|
#include "machofile.h"
|
|
|
|
SymbolTableEntry::SymbolTableEntry(MachOFile& file, char* stringTable)
|
|
: file(file), stringTable(stringTable)
|
|
{
|
|
}
|
|
|
|
SymbolTableEntry::~SymbolTableEntry() {
|
|
|
|
}
|
|
|
|
std::string SymbolTableEntry::getName(bool shouldDemangle) const {
|
|
const char *name = getInternalName();
|
|
std::string result = name;
|
|
if (shouldDemangle) {
|
|
int status = 0;
|
|
|
|
// Convert real name to readable string. +1 to skip the leading underscore.
|
|
char *realName = abi::__cxa_demangle(name + 1, nullptr, nullptr, &status);
|
|
if (realName != nullptr)
|
|
result = realName;
|
|
free(realName);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
SymbolTableEntry::Type SymbolTableEntry::getType() const {
|
|
unsigned int type = getInternalType();
|
|
|
|
if (type & N_STAB) {
|
|
return TypeDebug;
|
|
}
|
|
if (type & N_PEXT) {
|
|
return TypePrivateExtern;
|
|
}
|
|
if (type & N_EXT) {
|
|
if ((type & N_TYPE) == N_UNDF)
|
|
return TypeImported;
|
|
else
|
|
return TypeExported;
|
|
}
|
|
else
|
|
return TypeLocal;
|
|
}
|