Skip to content

Commit 7089591

Browse files
committed
fix Issue 21914 - naked assembler functions get wrong offset to parameters
1 parent 250f4d3 commit 7089591

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

dm/src/dmc/cgcod.d

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -826,8 +826,9 @@ Lagain:
826826
{
827827
version (FRAMEPTR)
828828
{
829-
Para.size = ((farfunc ? 2 : 1) + needframe) * REGSIZE;
830-
if (needframe)
829+
bool frame = needframe || tyf & mTYnaked;
830+
Para.size = ((farfunc ? 2 : 1) + frame) * REGSIZE;
831+
if (frame)
831832
EBPtoESP = -REGSIZE;
832833
}
833834
else
@@ -1012,7 +1013,6 @@ else
10121013
// we need BP to reset the stack before return
10131014
// otherwise the return address is lost
10141015
needframe = 1;
1015-
10161016
}
10171017
else if (config.flags & CFGalwaysframe)
10181018
needframe = 1;
@@ -1030,7 +1030,9 @@ else
10301030
anyiasm ||
10311031
Alloca.size
10321032
)
1033+
{
10331034
needframe = 1;
1035+
}
10341036
}
10351037
if (refparam && (anyiasm || I16))
10361038
needframe = 1;

dm/src/dmc/cod3.d

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2252,6 +2252,7 @@ void outswitab(block *b)
22522252
@trusted
22532253
int jmpopcode(elem *e)
22542254
{
2255+
//printf("jmpopcode()\n"); elem_print(e);
22552256
tym_t tym;
22562257
int zero,i,jp,op;
22572258
static immutable ubyte[6][2][2] jops =
@@ -5429,7 +5430,9 @@ void assignaddrc(code *c)
54295430
break;
54305431

54315432
case FLpara:
5432-
//printf("s = %s, Soffset = %d, Para.size = %d, BPoff = %d, EBPtoESP = %d\n", s.Sident.ptr, s.Soffset, Para.size, BPoff, EBPtoESP);
5433+
//printf("s = %s, Soffset = %d, Para.size = %d, BPoff = %d, EBPtoESP = %d, Vpointer = %d\n",
5434+
//s.Sident.ptr, cast(int)s.Soffset, cast(int)Para.size, cast(int)BPoff,
5435+
//cast(int)EBPtoESP, cast(int)c.IEV1.Vpointer);
54335436
soff = Para.size - BPoff; // cancel out add of BPoff
54345437
goto L1;
54355438

0 commit comments

Comments
 (0)