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