I have a shared library that gets initialized by a call to the following function:
extern "C" {
int pa__init(pa_module *m) {
m->userdata = new PAModule(m);
return 0;
}
} // extern "C"
It gets compiled into this (the addresses are compile time offsets):
0000000000064717 <pa__init>:
[...]
64726: bf 40 00 00 00 mov $0x40,%edi
6472b: e8 e0 cb ff ff callq 61310 <operator new(unsigned long)@plt>
64730: 48 89 c3 mov %rax,%rbx
64733: 48 8b 45 d8 mov -0x28(%rbp),%rax
64737: 48 89 c6 mov %rax,%rsi
6473a: 48 89 df mov %rbx,%rdi
6473d: e8 2e e1 ff ff callq 62870 <PAModule::PAModule(pa_module*)@plt>
[...]
This is the disassembly of the PLT function at compile time offset 61310
:
0000000000061310 <operator new(unsigned long)@plt>:
61310: ff 25 a2 c1 66 00 jmpq *0x66c1a2(%rip) # 6cd4b8 <operator new(unsigned long)@@Base+0x57f708>
61316: 68 94 02 00 00 pushq $0x294
6131b: e9 a0 d6 ff ff jmpq 5e9c0 <.plt>
When I am loading the library and this method gets called, I get a segfault at compile time offset 61310
:
#0 0x0000000000061316 in ?? ()
#1 0x00007fd9faae9730 in pa__init (m=0x55f1a750d850) at pa_module.cpp:24
[...]
The value in the GOT at compile time offset 6cd4b8
(relocated at runtime to e.g. 0x7fced7ffa4b8
) is
0x7fced7ffa4b8: 0x00061316
The processor tries to jump to that location. However, this is still the compile time offset (pointing to invalid memory), which is the reason why the program segfaults.
Any ideas why the entries in the GOT do not get relocated when my library is loaded?
Thank you very much!