vtable

C++ vtable resolving with virtual inheritance

余生长醉 提交于 2019-12-06 05:06:30
I was curious about C++ and virtual inheritance - in particular, the way that vtable conflicts are resolved between bass and child classes. I won't pretend to understand the specifics on how they work, but what I've gleamed so far is that their is a small delay caused by using virtual functions due to that resolution. My question then is if the base class is blank - ie, its virtual functions are defined as: virtual void doStuff() = 0; Does this mean that the resolution is not necessary, because there's only one set of functions to pick from? Forgive me if this is an stupid question - as I said

Building a COM object vtable in x86 assembly

夙愿已清 提交于 2019-12-06 04:04:28
问题 I am building a COM object in x86 assembly using NASM. I understand COM quite well and I understand x86 assembly pretty well, but getting the two to mesh is getting me hung up... (by the way, if you're thinking of attempting to dissuade me from using x86 assembly, please refrain, I have very particular reasons why I'm building this in x86 assembly!) I am trying to build a vtable to use in my COM object, but I keep getting strange pointers, rather than actual pointers to my functions. (I'm

Do C++ POD types have RTTI?

懵懂的女人 提交于 2019-12-06 03:15:56
问题 As I understand how RTTI is implemented in various C++ compilers (such as GCC), a pointer to the type_info data is stored in the vtable data of each class. And also as mentioned here, POD type may not have a vtable . But if POD types may not have a vtable then where is the pointer to the type_info stored? I know it is implementation-specific, but it would be better to be aware of a C++ compiler (such as GCC) internals. 回答1: There are two kinds of types (for the purposes of RTTI): polymorphic

replacement for “fvtable-gc” in GCC

蹲街弑〆低调 提交于 2019-12-05 18:18:33
Is there any replacement for 'fvtable-gc' options in GCCv4.7.1 (it was supported in GCCv3.x)? I want to remove unused virtual functions during linkage process. fvtable-gc Emit special relocations for vtables and virtual function references so that the linker can identify unused virtual functions and zero out vtable slots that refer to them. This is most useful with -ffunction-sections and -Wl,--gc-sections, in order to also discard the functions themselves. Looks like the feature was too buggy, so it has been removed several years ago. I don't think there is an equivalent replacement. Though I

Using reflection to override virtual method tables in C#

别等时光非礼了梦想. 提交于 2019-12-05 14:25:19
Is there a way to change the virtual methods tables in C#? like change where a virtual method is pointing? class A { public virtual void B() { Console.WriteLine("B"); } } class Program { public static void MyB(A a) { Console.WriteLine("MyB"); } public static void Main(string[] Args) { A a = new A(); // Do some reflection voodoo to change the virtual methods table here to make B point to MyB a.B(); // Will print MyB } } Take a look at LinFu . On Linfu's author's Blog there's an example of using LinFu.AOP to intercept and change calls even to methods of classes that you don't control directly.

Is there any way to dump the class layout of a g++ compiled program

孤街浪徒 提交于 2019-12-05 02:04:16
问题 When compiling with g++, -fdump-class-hierarchy exports the program's vtables in a (more or less) human-readable format. However, the resulting file only contains information about the vtable but not about the class layout itself. I'd like to get a comprehensive list of the layout of all my program's classes. clang offers the -cc1 -fdump-record-layouts arguments to achieve this. The MS compiler can be called using -d1reportAllClassLayout. Is there any g++ switch that does this? 回答1: If the

What causes “java.lang.IncompatibleClassChangeError: vtable stub”?

社会主义新天地 提交于 2019-12-05 00:03:08
问题 What causes "java.lang.IncompatibleClassChangeError: vtable stub"? In our application, we have seen this error pop up randomly and very seldom (just twice so far, and we run it a lot). It is not readily reproducible, even when restarting the app, using the same jvm/jars without rebuilding. As for our build process, we clean all classes/jars and rebuild them, so it's not the same problem as others have encountered where they made a change in one class and didn't recompile some other dependent

Detect the the vtable offset of a specific virtual function (using Visual C++)

你。 提交于 2019-12-04 19:06:01
Can the vtable offset of a specific virtual function be inspected? Why? I'd like to be able to detect unintentional binary compatibility breaks (see http://techbase.kde.org/Policies/Binary_Compatibility_Issues_With_C%2B%2B for what I mean by binary compatibility). I'm aware of the undocumented and unsupported technique of "/d1reportSingleClassLayout" (http://blogs.msdn.com/b/vcblog/archive/2007/05/17/diagnosing-hidden-odr-violations-in-visual-c-and-fixing-lnk2022.aspx), and I plan to use this technique, but I'd like to also use some simple compile time or run time checks if possible. Inspired

c++: Does a vtable contains pointers to non-virtual functions?

早过忘川 提交于 2019-12-04 10:55:14
问题 vtable contains pointers to virtual functions of that class. Does it also contains pointers to non-virtual functions as well? Thx! 回答1: It's an implementation detail, but no. If an implementation put pointers to non-virtual functions into a vtable it couldn't use these pointers for making function calls because it would often cause incorrect non-virtual functions to be called. When a non-virtual function is called the implementation must use the static type of the object on which the function

Building a COM object vtable in x86 assembly

与世无争的帅哥 提交于 2019-12-04 10:11:02
I am building a COM object in x86 assembly using NASM. I understand COM quite well and I understand x86 assembly pretty well, but getting the two to mesh is getting me hung up... (by the way, if you're thinking of attempting to dissuade me from using x86 assembly, please refrain, I have very particular reasons why I'm building this in x86 assembly!) I am trying to build a vtable to use in my COM object, but I keep getting strange pointers, rather than actual pointers to my functions. (I'm thinking that I'm getting relative offsets or that NASM is embedding temporary values in there and they're