mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-18 02:29:19 +02:00
* tcg.a_load_cgparaloc_ref checks the size of the ref exactly to avoid overwriting of adjacent data
git-svn-id: trunk@36951 -
This commit is contained in:
parent
9b3e0a80df
commit
43b017bde0
@ -1103,7 +1103,7 @@ implementation
|
||||
caller side and needs to be stored with those bytes at the
|
||||
start of the reference -> don't shift right }
|
||||
else if (paraloc.shiftval<0) and
|
||||
((-paraloc.shiftval) in [1,2,4]) then
|
||||
((-paraloc.shiftval) in [8,16,32]) then
|
||||
begin
|
||||
a_op_const_reg_reg(list,OP_SHR,OS_INT,-paraloc.shiftval,paraloc.register,paraloc.register);
|
||||
{ convert to a register of 1/2/4 bytes in size, since the
|
||||
@ -1113,7 +1113,79 @@ implementation
|
||||
hreg:=getintregister(list,cgsize);
|
||||
a_load_reg_reg(list,OS_INT,cgsize,paraloc.register,hreg);
|
||||
end;
|
||||
a_load_reg_ref(list,paraloc.size,cgsize,hreg,ref);
|
||||
{ use the exact size to avoid overwriting of adjacent data }
|
||||
if tcgsize2size[cgsize]<=sizeleft then
|
||||
a_load_reg_ref(list,paraloc.size,cgsize,hreg,ref)
|
||||
else
|
||||
case sizeleft of
|
||||
1,2,4,8:
|
||||
a_load_reg_ref(list,paraloc.size,int_cgsize(sizeleft),hreg,ref);
|
||||
3:
|
||||
begin
|
||||
if target_info.endian=endian_big then
|
||||
begin
|
||||
href:=ref;
|
||||
inc(href.offset,2);
|
||||
a_load_reg_ref(list,paraloc.size,OS_8,hreg,href);
|
||||
a_op_const_reg_reg(list,OP_SHR,OS_INT,8,hreg,hreg);
|
||||
a_load_reg_ref(list,paraloc.size,OS_16,hreg,ref);
|
||||
end
|
||||
else
|
||||
{ little endian not implemented yet }
|
||||
Internalerror(2017081301);
|
||||
end;
|
||||
5:
|
||||
begin
|
||||
if target_info.endian=endian_big then
|
||||
begin
|
||||
href:=ref;
|
||||
inc(href.offset,4);
|
||||
a_load_reg_ref(list,paraloc.size,OS_8,hreg,href);
|
||||
a_op_const_reg_reg(list,OP_SHR,OS_INT,8,hreg,hreg);
|
||||
a_load_reg_ref(list,paraloc.size,OS_32,hreg,ref);
|
||||
end
|
||||
else
|
||||
{ little endian not implemented yet }
|
||||
Internalerror(2017081302);
|
||||
end;
|
||||
6:
|
||||
begin
|
||||
if target_info.endian=endian_big then
|
||||
begin
|
||||
href:=ref;
|
||||
inc(href.offset,4);
|
||||
a_load_reg_ref(list,paraloc.size,OS_16,hreg,href);
|
||||
a_op_const_reg_reg(list,OP_SHR,OS_INT,16,hreg,hreg);
|
||||
a_load_reg_ref(list,paraloc.size,OS_32,hreg,ref);
|
||||
end
|
||||
else
|
||||
{ little endian not implemented yet }
|
||||
Internalerror(2017081303);
|
||||
end;
|
||||
7:
|
||||
begin
|
||||
if target_info.endian=endian_big then
|
||||
begin
|
||||
href:=ref;
|
||||
inc(href.offset,6);
|
||||
a_load_reg_ref(list,paraloc.size,OS_8,hreg,href);
|
||||
|
||||
a_op_const_reg_reg(list,OP_SHR,OS_INT,8,hreg,hreg);
|
||||
href:=ref;
|
||||
inc(href.offset,4);
|
||||
a_load_reg_ref(list,paraloc.size,OS_16,hreg,href);
|
||||
|
||||
a_op_const_reg_reg(list,OP_SHR,OS_INT,16,hreg,hreg);
|
||||
a_load_reg_ref(list,paraloc.size,OS_32,hreg,ref);
|
||||
end
|
||||
else
|
||||
{ little endian not implemented yet }
|
||||
Internalerror(2017081304);
|
||||
end;
|
||||
else
|
||||
{ other sizes not allowed }
|
||||
Internalerror(2017080901);
|
||||
end;
|
||||
end;
|
||||
LOC_MMREGISTER :
|
||||
begin
|
||||
|
Loading…
Reference in New Issue
Block a user