Consider the following program:
#include <iostream>
class A {
public:
A() {}
virtual void a() {};
};
class B : public A { };
int main() {
B();
}
GCC (tested 4.4.0, 8.3.0 and 9.1) generates the following Code for B::B()
(godbolt link):
call A::A() [base object constructor]
movl $vtable for B+16, %edx
Note that it does a 32-bit move in a 64-bit program. How can GCC be sure that the .text
section storing the vtable will end up in a 32-bit address?