diff options
author | nickysn <nickysn@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2019-06-15 00:30:07 +0000 |
---|---|---|
committer | nickysn <nickysn@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2019-06-15 00:30:07 +0000 |
commit | 65689fe2ab960762906624fa4bd808837b2eda6b (patch) | |
tree | 03663925b42601e096a03f2e7d32136de85ed383 | |
parent | bdbebdd55781f2300efc7dc2ff72bd5beaf656ed (diff) | |
download | fpc-65689fe2ab960762906624fa4bd808837b2eda6b.tar.gz |
+ introduced the TOmfRecord_COMENT_EXPDEF class. Use that to generate export
libraries instead of generating the magic string directly.
git-svn-id: https://svn.freepascal.org/svn/fpc/trunk@42237 3ad0048d-3df7-0310-abae-a5850022a9f2
-rw-r--r-- | compiler/omfbase.pas | 68 | ||||
-rw-r--r-- | compiler/systems/t_win16.pas | 31 |
2 files changed, 83 insertions, 16 deletions
diff --git a/compiler/omfbase.pas b/compiler/omfbase.pas index 2804f5e98f..c3f7eab554 100644 --- a/compiler/omfbase.pas +++ b/compiler/omfbase.pas @@ -357,6 +357,30 @@ interface property Name: string read FName write FName; end; + { TOmfRecord_COMENT_EXPDEF } + + TOmfRecord_COMENT_EXPDEF = class(TOmfRecord_COMENT_Subtype) + private + FExportByOrdinal: Boolean; + FResidentName: Boolean; + FNoData: Boolean; + FParmCount: Integer; + FExportedName: string; + FInternalName: string; + FExportOrdinal: Word; + public + procedure DecodeFrom(ComentRecord: TOmfRecord_COMENT);override; + procedure EncodeTo(ComentRecord: TOmfRecord_COMENT);override; + + property ExportByOrdinal: Boolean read FExportByOrdinal write FExportByOrdinal; + property ResidentName: Boolean read FResidentName write FResidentName; + property NoData: Boolean read FNoData write FNoData; + property ParmCount: Integer read FParmCount write FParmCount; + property ExportedName: string read FExportedName write FExportedName; + property InternalName: string read FInternalName write FInternalName; + property ExportOrdinal: Word read FExportOrdinal write FExportOrdinal; + end; + { TOmfRecord_LNAMES } TOmfRecord_LNAMES = class(TOmfParsedRecord) @@ -1602,6 +1626,50 @@ implementation Chr(Length(Name))+Name; end; + { TOmfRecord_COMENT_EXPDEF } + + procedure TOmfRecord_COMENT_EXPDEF.DecodeFrom(ComentRecord: TOmfRecord_COMENT); + begin + {todo: implement} + internalerror(2019061503); + end; + + procedure TOmfRecord_COMENT_EXPDEF.EncodeTo(ComentRecord: TOmfRecord_COMENT); + var + expflag: Byte; + begin + ComentRecord.CommentClass:=CC_OmfExtension; + + if (ParmCount<0) or (ParmCount>31) then + internalerror(2019061504); + expflag:=ParmCount; + if ExportByOrdinal then + expflag:=expflag or $80; + if ResidentName then + expflag:=expflag or $40; + if NoData then + expflag:=expflag or $20; + + if ExportByOrdinal then + if InternalName=ExportedName then + ComentRecord.CommentString:=Chr(CC_OmfExtension_EXPDEF)+Chr(expflag)+ + Chr(Length(ExportedName))+ExportedName+#0+ + Chr(Byte(ExportOrdinal))+Chr(Byte(ExportOrdinal shr 8)) + else + ComentRecord.CommentString:=Chr(CC_OmfExtension_EXPDEF)+Chr(expflag)+ + Chr(Length(ExportedName))+ExportedName+ + Chr(Length(InternalName))+InternalName+ + Chr(Byte(ExportOrdinal))+Chr(Byte(ExportOrdinal shr 8)) + else + if InternalName=ExportedName then + ComentRecord.CommentString:=Chr(CC_OmfExtension_EXPDEF)+Chr(expflag)+ + Chr(Length(ExportedName))+ExportedName+#0 + else + ComentRecord.CommentString:=Chr(CC_OmfExtension_EXPDEF)+Chr(expflag)+ + Chr(Length(ExportedName))+ExportedName+ + Chr(Length(InternalName))+InternalName; + end; + { TOmfRecord_LNAMES } constructor TOmfRecord_LNAMES.Create; diff --git a/compiler/systems/t_win16.pas b/compiler/systems/t_win16.pas index 3ea0a65083..2ce8b77665 100644 --- a/compiler/systems/t_win16.pas +++ b/compiler/systems/t_win16.pas @@ -163,9 +163,8 @@ var i: Integer; hp: texported_item; ModEnd: TOmfRecord_MODEND; - DllExport_COMENT: TOmfRecord_COMENT; - expflag: Byte; - internal_name: TSymStr; + DllExport_COMENT: TOmfRecord_COMENT=nil; + DllExport_COMENT_EXPDEF: TOmfRecord_COMENT_EXPDEF=nil; begin if EList.Count=0 then exit; @@ -188,30 +187,30 @@ begin hp:=texported_item(EList[i]); { write EXPDEF record } - DllExport_COMENT:=TOmfRecord_COMENT.Create; - DllExport_COMENT.CommentClass:=CC_OmfExtension; - expflag:=0; - if eo_index in hp.options then - expflag:=expflag or $80; - if eo_resident in hp.options then - expflag:=expflag or $40; + DllExport_COMENT_EXPDEF:=TOmfRecord_COMENT_EXPDEF.Create; + DllExport_COMENT_EXPDEF.ExportByOrdinal:=eo_index in hp.options; + DllExport_COMENT_EXPDEF.ResidentName:=eo_resident in hp.options; + DllExport_COMENT_EXPDEF.ExportedName:=hp.name^; if assigned(hp.sym) then case hp.sym.typ of staticvarsym: - internal_name:=tstaticvarsym(hp.sym).mangledname; + DllExport_COMENT_EXPDEF.InternalName:=tstaticvarsym(hp.sym).mangledname; procsym: - internal_name:=tprocdef(tprocsym(hp.sym).ProcdefList[0]).mangledname; + DllExport_COMENT_EXPDEF.InternalName:=tprocdef(tprocsym(hp.sym).ProcdefList[0]).mangledname; else internalerror(2015092701); end else - internal_name:=hp.name^; - DllExport_COMENT.CommentString:=Chr(CC_OmfExtension_EXPDEF)+Chr(expflag)+Chr(Length(hp.name^))+hp.name^+Chr(Length(internal_name))+internal_name; + DllExport_COMENT_EXPDEF.InternalName:=hp.name^; if eo_index in hp.options then - DllExport_COMENT.CommentString:=DllExport_COMENT.CommentString+Chr(Byte(hp.index))+Chr(Byte(hp.index shr 8)); + DllExport_COMENT_EXPDEF.ExportOrdinal:=hp.index; + + DllExport_COMENT:=TOmfRecord_COMENT.Create; + DllExport_COMENT_EXPDEF.EncodeTo(DllExport_COMENT); + FreeAndNil(DllExport_COMENT_EXPDEF); DllExport_COMENT.EncodeTo(RawRecord); + FreeAndNil(DllExport_COMENT); RawRecord.WriteTo(ObjWriter); - DllExport_COMENT.Free; end; { write MODEND record } |