> I don't see anything wrong here since the function pointer may not
> be the same as the address of the function body:
Probably nothing wrong, I just could not find anything saying that
that treatment of R_386_PC32 was valid. The psabi just says it is "S +
A - P".
Btw, C compilers use the "load from got" code, so the it is 'g' that
returns what in C is the function pointer. For example, compiling
void f();
void *g() { return f; }
with gcc 4.9 (-Os -fPIC -m32) produces
g:
call __
x86.get_pc_thunk.cx
addl $_GLOBAL_OFFSET_TABLE_, %ecx
movl f@GOT(%ecx), %eax
ret
Cheers,
Rafael