How are virtual functions implemented in position-independent code?
I know that if my class has virtual functions, the compiler usually generates a vtable for it containing the addresses of all virtual functions and stores a pointer to vtable in every object of my class.
Now, if my code is position-independent, the compiler cannot know the addresses of virtual functions (or any function, for that matter). So what is he doing?
I would like to know what real compilers do (and not what is theoretically possible); I'm most interested in 32-bit Linux platforms, but other platforms are also a little interesting.
c ++ gcc virtual-functions dynamic-linking vtable
anatolyg
source share