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 that contains addresses of all virtual functions, and stores a pointer to the vtable in each object of my class.
Now, if my code is position-independent, the compiler cannot know addresses of virtual functions (or any function, for that matter). So what does it do?
I would like to know what real compilers do (not what is theoretically possible); i am mostly interested in linux 32-bit platforms but other platforms are slightly interesting too.
There are two options:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With