Merge "Add option to print mangled function names" am: 823a8a6a89
am: 3ecfd17851
Change-Id: Ic7a5eb811cc25efb2a3b0d9565b6a308ab6ba1dd
This commit is contained in:
@@ -126,7 +126,7 @@ bool ELFSharedObject<ELFT>::cacheELFSections() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename ELFT>
|
template <typename ELFT>
|
||||||
void ELFSharedObject<ELFT>::printVTables() const {
|
void ELFSharedObject<ELFT>::printVTables(bool Mangled) const {
|
||||||
for (const VTable &Vtable : mVTables) {
|
for (const VTable &Vtable : mVTables) {
|
||||||
if (Vtable.getVTableSize() == 0)
|
if (Vtable.getVTableSize() == 0)
|
||||||
continue;
|
continue;
|
||||||
@@ -138,9 +138,12 @@ void ELFSharedObject<ELFT>::printVTables() const {
|
|||||||
<< " entries"
|
<< " entries"
|
||||||
<< "\n";
|
<< "\n";
|
||||||
for (const VFunction &Vfunction : Vtable) {
|
for (const VFunction &Vfunction : Vtable) {
|
||||||
|
std::string VfunctionName = (Mangled ?
|
||||||
|
Vfunction.getMangledName() :
|
||||||
|
Vfunction.getDemangledName());
|
||||||
outs() << Vfunction.getOffset()
|
outs() << Vfunction.getOffset()
|
||||||
<< " (int (*)(...)) "
|
<< " (int (*)(...)) "
|
||||||
<< Vfunction.getDemangledName()
|
<< VfunctionName
|
||||||
<< "\n";
|
<< "\n";
|
||||||
}
|
}
|
||||||
outs() << "\n"
|
outs() << "\n"
|
||||||
|
|||||||
@@ -42,7 +42,9 @@ using llvm::outs;
|
|||||||
class SharedObject {
|
class SharedObject {
|
||||||
public:
|
public:
|
||||||
static std::unique_ptr<SharedObject> create(const ObjectFile *);
|
static std::unique_ptr<SharedObject> create(const ObjectFile *);
|
||||||
virtual void printVTables() const = 0;
|
/* Print mangled names if the argument is true; demangled if false.
|
||||||
|
*/
|
||||||
|
virtual void printVTables(bool) const = 0;
|
||||||
virtual ~SharedObject() = 0;
|
virtual ~SharedObject() = 0;
|
||||||
private:
|
private:
|
||||||
virtual bool getVTables() = 0;
|
virtual bool getVTables() = 0;
|
||||||
@@ -105,7 +107,7 @@ private:
|
|||||||
template<typename ELFT>
|
template<typename ELFT>
|
||||||
class ELFSharedObject : public SharedObject {
|
class ELFSharedObject : public SharedObject {
|
||||||
public:
|
public:
|
||||||
void printVTables() const override;
|
void printVTables(bool) const override;
|
||||||
bool getVTables() override;
|
bool getVTables() override;
|
||||||
~ELFSharedObject();
|
~ELFSharedObject();
|
||||||
ELFSharedObject(const ELFObjectFile<ELFT> *);
|
ELFSharedObject(const ELFObjectFile<ELFT> *);
|
||||||
|
|||||||
@@ -42,6 +42,10 @@ opt<std::string> FilePath(
|
|||||||
Positional, Required, cat(VTableDumperCategory),
|
Positional, Required, cat(VTableDumperCategory),
|
||||||
desc("shared_library.so"));
|
desc("shared_library.so"));
|
||||||
|
|
||||||
|
opt<bool> Mangled(
|
||||||
|
"mangled", cat(VTableDumperCategory),
|
||||||
|
desc("Show mangled symbol names"));
|
||||||
|
|
||||||
static void HideIrrelevantCommandLineOptions() {
|
static void HideIrrelevantCommandLineOptions() {
|
||||||
for (StringMapEntry<Option *> &P : getRegisteredOptions()) {
|
for (StringMapEntry<Option *> &P : getRegisteredOptions()) {
|
||||||
if (P.second->Category == &VTableDumperCategory) {
|
if (P.second->Category == &VTableDumperCategory) {
|
||||||
@@ -80,6 +84,6 @@ int main(int argc, char **argv) {
|
|||||||
outs() << "Couldn't create ELFObjectFile \n";
|
outs() << "Couldn't create ELFObjectFile \n";
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
SoFile->printVTables();
|
SoFile->printVTables(Mangled);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user