Hi,
Environment: Lazarus 1.2.4 / FPC 2.6.4 / Win 7 64bit / Intel Core i5 430M @2.27 GHz
What do I have to do to convince the compiler to use 64 bit relocation for the inline assembler? Background is as follows.
I do keep some statistics counter in the general VAR definition
unit Main;
...
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Menus;
type
...
var
LongCalc: TLongCalc;
Add_LLEU_Counter: QWORD; // Counter for calls to add low level
Add_LLEU_TotalTime: QWORD; // Total time spend (in CPU clocks)
Add_LLEU_LastTime: QWORD; // Time spend (in CPU clocks) on last call
Add_LLEU_MinTime: QWORD; // Lowest time spend on all calls
When I access these from within the inline assembler like
function Add_LLEU // Add Low Level Even Unsigned
(
Op1: pLimb; // first summand
Op2: pLimb; // second summand
Res: pLimb; // resulting sum
Size: QWORD // number of limb to work
):QWORD; // Carry
begin
{$IFNDEF ASM_VERSION} // Use Pascal only if assembly version is not avail
{$ifdef KEEP_STATS} // Inline statistics to be used
asm
rdtsc; // Read time-stamp-counter from core
shl RDX, 32; // Convert to 64 bit
or RAX, RDX;
mov qword ptr [Add_LLEU_LastTime], RAX; // Initialize this
inc qword ptr [Add_LLEU_Counter] // One more activation counted
end ['RAX', 'RDX'];
{$endif}
I do get the linker warning on 32bit absolute relocation used
LongCalculator.lpr(20,1) Warning: Object file "main.o" contains 32-bit absolute relocation to symbol ".bss.n_u_main_add_lleu_counter".
This means that I can only reliably run the code in the lower 4GByte of a virtual address range. As long as I keep the debugger info included Windows will start the program as required - but as soon as I remove debug info the program gets executed above that space and consequently stops with a SIGSEGV.
Any ideas what I can do about this? I read what I could find in the documentation but couldn't find something usefull. Maybe there is doc available somewhere and I just haven't found it yet - linking me to where I should read on would then be highly appreciated.
Regards,
Jens
[02.08.2014] Edit: typos, rephrasing