Daniël Mantione schrieb:
Op Sat, 6 Jan 2007, schreef Florian Klaempfl:
Daniël Mantione schrieb:
Op Sat, 6 Jan 2007, schreef Florian Klaempfl:
As of revision 5831, I've enabled -Cg for x86_64-linux building. This
means
all code is built with PIC so you can build libraries without
recompiling the
fpc rtl etc. However, this might have some downsides: first, pic'ed
code is
slightly slower, second, pic support still might contain bugs so
please share
your findings and opinions.
How difficult do you think it is to use RIP relative addresses to access
How should this look like?
Assume we have:
var global:byte;
procedure z;
begin
global:=1;
end;
Referencing to z without PIC would be an absolute memory access,
preventing us to place z in memory where we want without breaking the
code.
Well, to be correct it allows to map physical pages with code at
different virtual address in different processes. Without PIC they could
be only relocated for one address.
Normally with -Cg we do something like:
call FPC_GETEIPINEBX
add rbx,dword global_offset_table
mov [rbx + offset_of_global_in_datasegment].byte,1
... to get access to the variable. With x64_64 you can do:
mov [global wrt rip].byte,1
The assembler must translate this to:
mov [rip-data_segment_distance+offset_of_global_in_datasegment].byte,1
... where offset_of_global_in_datasegment is a constant and
data_segment_distance symbol that is resolved by the linker.
Well, amd64 does this basically but it stores only the address to the
actual data rip relative so you need an additional redirection. This
point is stored in the got section. I wonder indeed if one could abuse
the got to actually store data :)
_______________________________________________
fpc-devel maillist - [email protected]
http://lists.freepascal.org/mailman/listinfo/fpc-devel