Giter VIP home page Giter VIP logo

vtable-dumper's Introduction

Vtable Dumper

Vtable-Dumper โ€” a tool to list content of virtual tables in a C++ shared library.

Contents

  1. About
  2. Install
  3. Usage

About

The tool is intended for developers of software libraries and maintainers of Linux distributions who are interested in ensuring backward binary compatibility.

The tool is developed by Andrey Ponomarenko.

Install

sudo make install prefix=/usr
Requires
  • libelf
  • libdl
  • libstdc++

Usage

vtable-dumper SHLIB
Example
vtable-dumper /usr/lib64/libstdc++.so.6
Note

Make sure that all dependencies of a target library can be found by ldd. Otherwise dlopen() may fail. Add paths to these libraries to LD_LIBRARY_PATH in this case.

Options
Option Desc
-mangled Show mangled symbol names
-demangled Show de-mangled symbol names
-help Display this help message
-dumpversion Print the tool version
Sample output
Vtable for QIconEnginePlugin
_ZTV17QIconEnginePlugin: 22 entries
0     (int (*)(...)) 0
8     (int (*)(...)) (& _ZTI17QIconEnginePlugin)
16    (int (*)(...)) QIconEnginePlugin::metaObject() const
24    (int (*)(...)) QIconEnginePlugin::qt_metacast(char const*)
32    (int (*)(...)) QIconEnginePlugin::qt_metacall(QMetaObject::Call, int, void**)
40    (int (*)(...)) QIconEnginePlugin::~QIconEnginePlugin()
48    (int (*)(...)) QIconEnginePlugin::~QIconEnginePlugin()
56    (int (*)(...)) QObject::event(QEvent*)
64    (int (*)(...)) QObject::eventFilter(QObject*, QEvent*)
72    (int (*)(...)) QObject::timerEvent(QTimerEvent*)
80    (int (*)(...)) QObject::childEvent(QChildEvent*)
88    (int (*)(...)) QObject::customEvent(QEvent*)
96    (int (*)(...)) QObject::connectNotify(char const*)
104   (int (*)(...)) QObject::disconnectNotify(char const*)
112   (int (*)(...)) __cxa_pure_virtual
120   (int (*)(...)) __cxa_pure_virtual
128   (int (*)(...)) -0x00000000000010
136   (int (*)(...)) (& _ZTI17QIconEnginePlugin)
144   (int (*)(...)) _ZThn16_N17QIconEnginePluginD1Ev
152   (int (*)(...)) _ZThn16_N17QIconEnginePluginD0Ev
160   (int (*)(...)) __cxa_pure_virtual
168   (int (*)(...)) __cxa_pure_virtual

vtable-dumper's People

Contributors

floppym avatar lvc avatar sgayou avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vtable-dumper's Issues

Undecorated v-table entries for inline virtual functions

Sometimes the dladdr function fails to find some symbol names in the v-table.

Output of vtable-dumper /usr/lib64/libQt5Gui.so.5.4.2:

Vtable for QImageTextureGlyphCache
_ZTV23QImageTextureGlyphCache: 10 entries
0     (int (*)(...)) 0
8     (int (*)(...)) (& _ZTI23QImageTextureGlyphCache)
16    (int (*)(...)) QImageTextureGlyphCache::~QImageTextureGlyphCache()
24    (int (*)(...)) QImageTextureGlyphCache::~QImageTextureGlyphCache()
32    (int (*)(...)) QImageTextureGlyphCache::createTextureData(int, int)
40    (int (*)(...)) QImageTextureGlyphCache::resizeTextureData(int, int)
48    (int (*)(...)) 0x32d210
56    (int (*)(...)) QImageTextureGlyphCache::fillTexture(QTextureGlyphCache::Coord const&, unsigned int, QFixed)
64    (int (*)(...)) 0x32d220
72    (int (*)(...)) 0x32d230

The tool can't find symbol names for 0x32d210, 0x32d220 and 0x32d230.

The g++ -fdump-class-hierarchy ./qtextureglyphcache_p.h returns for this class:

Vtable for QImageTextureGlyphCache
QImageTextureGlyphCache::_ZTV23QImageTextureGlyphCache: 10u entries
0     (int (*)(...))0
8     (int (*)(...))(& _ZTI23QImageTextureGlyphCache)
16    (int (*)(...))QImageTextureGlyphCache::~QImageTextureGlyphCache
24    (int (*)(...))QImageTextureGlyphCache::~QImageTextureGlyphCache
32    (int (*)(...))QImageTextureGlyphCache::createTextureData
40    (int (*)(...))QImageTextureGlyphCache::resizeTextureData
48    (int (*)(...))QTextureGlyphCache::glyphPadding
56    (int (*)(...))QImageTextureGlyphCache::fillTexture
64    (int (*)(...))QTextureGlyphCache::maxTextureWidth
72    (int (*)(...))QTextureGlyphCache::maxTextureHeight

The QTextureGlyphCache::* inline virtual methods names are missed in the vtable-dumper output.

Windows instructions are incomplete.

You have Windows instructions for ABI Compliance Checker but not for your other products which ABICC depends on like ABI Dumper and Vtable Dumper.

dump-vtable.c: 2 * undefined behaviour ?

dump-vtable.c:315:46: warning: flag '0' results in undefined behavior with 'p' conversion specifier [-Wformat]

 printf("(int (*)(...)) -%016p\n", (void*) -(ptrdiff_t)vfuncp);

dump-vtable.c:319:45: warning: flag '0' results in undefined behavior with 'p' conversion specifier [-Wformat]

  printf("(int (*)(...)) %016p\n", vfuncp);

Explicit linking against -lstdc++ disqualifies clang w/ libc++

vtable-dumper is explicitly linking to -lstdc++ used to provide __cxa_demangle(). However, libstdc++ is only valid for gcc (and clang with gcc libstdc++). The other compilers provide __cxa_demangle() in other libraries. For example, clang in GNU-free environment uses -lc++ (well, the needed symbol is actually often provided by -lc++abi or -lcxxrt sub-library), in which case -lstdc++ is either going to be wrong (i.e. force dependency on wrong C++ library on system using purely clang suite) or fail (when there is no gcc).

To be honest, I really don't see a point in building vtable-dumper as C if it requires the C++ library anyway. Therefore, the simplest solution to the problem would be to build it using a C++ compiler which in turn will use the correct C++ library for the ecosystem used (and also guarantee correct ABI for __cxa_demangle() calls โ€” it would also be more correct to #include <cxxabi.h> instead of redeclaring the function).

Fix your dependencies...

I want to evaluate the ABI Compliance Checker on Windows but it's number of dependencies is just ridiculous and you don't even provide a script to automate this.

wrong ELF class: ELFCLASS32

Cross compile sample library with arm toolchain:

$ arm-poky-linux-gnueabi-gcc -march=armv7ve -marm -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a7 --sysroot=/opt/poky/1.8.2/sysroots/cortexa7hf-neon-poky-linux-gnueabi -Wl,--version-script version -shared libsample.c -o libsample.so -g -Og -fPIC -DPIC

Use vtable-dumper on library for arm:

$ vtable-dumper libsample.so 
Failed to dlopen libsample.so
libsample.so: cannot open shared object file: No such file or directory
$ vtable-dumper ./libsample.so 
Failed to dlopen ./libsample.so
./libsample.so: wrong ELF class: ELFCLASS32

A couple of things helpful for distro packaging

I have just gotten this accepted into Fedora but there's a couple of things that would be nice:

  1. Makefile support for DESTDIR, since for packaging packages are built and installed as a normal user.
  2. Makefile support for compiler flags (CFLAGS/CXXFLAGS/LDFLAGS). I worked around this using a sed replace of -Wall with %{optflags}.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.