I'm trying to track down an issues that a handful of users are reporting. I cannot reproduce it at the moment, but I suspect the issue is related to the use of PIC and inline assembly.
PIC uses the Global Offset Table (GOT), and the inline assembly must preserve EBX
and RBX
according to the ABI. I've audited the code, and it appears to preserve EBX
and RBX
as required. But that does not mean the generated code is consistent with expectations because GCC will interleave instructions as it sees fit. All GCC guarantees is consecutiveness (i.e., my ASM will not be reordered).
I want to instrument debug builds with code similar to the following:
volatile void* got1 = GlobalOffsetTablePointer();
// Call a routine that uses inline assembly
volatile void* got2 = GlobalOffsetTablePointer();
assert(got1 = got2);
The problem I am experiencing is I cannot locate the function GlobalOffsetTablePointer
. I already have a suspicion for bad interactions with inline assembly, so I am trying to avoid more inline assembly to fetch the GOT pointer.
Is the Global Offset Table (GOT) pointer available from C/C++? If so, how do I access it?