From 222f981dd17189cc46d30d248c13d9e50e128797 Mon Sep 17 00:00:00 2001 From: yury Date: Mon, 17 Aug 2020 13:37:55 +0000 Subject: [PATCH] * 8086: Fixed Ofs() for far routines. resultdef of typeconvnode.typecheck_proc_to_procvar() is reused every time you get an address of a proc. So it is forbidden to change the far/near attribute of resultdef - it leads to mess during code generation. Instead it is needed to use separate reusable resultdefs with new flags pc_far_address and pc_offset. git-svn-id: trunk@46470 - --- compiler/i8086/n8086cnv.pas | 12 ++++++++++-- compiler/symdef.pas | 6 ++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/compiler/i8086/n8086cnv.pas b/compiler/i8086/n8086cnv.pas index 89b8065870..5043f053d4 100644 --- a/compiler/i8086/n8086cnv.pas +++ b/compiler/i8086/n8086cnv.pas @@ -70,14 +70,22 @@ implementation begin if resultdef.typ<>procvardef then internalerror(2018040401); - exclude(tprocvardef(resultdef).procoptions,po_far); + if po_far in tprocvardef(resultdef).procoptions then + begin + resultdef:=cprocvardef.getreusableprocaddr(tabstractprocdef(left.resultdef),pc_offset); + exclude(tprocvardef(resultdef).procoptions,po_far); + end; end else if (tcnf_proc_2_procvar_2_voidpointer in convnodeflags) and (current_settings.x86memorymodel in x86_far_code_models) then begin if resultdef.typ<>procvardef then internalerror(2018040402); - include(tprocvardef(resultdef).procoptions,po_far); + if not (po_far in tprocvardef(resultdef).procoptions) then + begin + resultdef:=cprocvardef.getreusableprocaddr(tabstractprocdef(left.resultdef),pc_far_address); + include(tprocvardef(resultdef).procoptions,po_far); + end; end; end; diff --git a/compiler/symdef.pas b/compiler/symdef.pas index 1a76c5a805..e4741ae336 100644 --- a/compiler/symdef.pas +++ b/compiler/symdef.pas @@ -643,6 +643,12 @@ interface pno_mangledname, pno_noparams); tprocnameoptions = set of tprocnameoption; tproccopytyp = (pc_normal, +{$ifdef i8086} + { the address in a far format } + pc_far_address, + { the offset part of the far address } + pc_offset, +{$endif i8086} { creates a procvardef describing only the code pointer of a method/netsted function/... } pc_address_only,