summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornickysn <nickysn@3ad0048d-3df7-0310-abae-a5850022a9f2>2019-06-14 23:50:48 +0000
committernickysn <nickysn@3ad0048d-3df7-0310-abae-a5850022a9f2>2019-06-14 23:50:48 +0000
commitbdbebdd55781f2300efc7dc2ff72bd5beaf656ed (patch)
tree8fd2474556c6fc8a208f0dc4adc5533b4f6c52be
parent4c484910651f3481a84bc7133e921d784d6e32d8 (diff)
downloadfpc-bdbebdd55781f2300efc7dc2ff72bd5beaf656ed.tar.gz
+ introduced the TOmfRecord_COMENT_IMPDEF class. Use it to encode the IMPDEF
records instead of encoding them directly. git-svn-id: https://svn.freepascal.org/svn/fpc/trunk@42236 3ad0048d-3df7-0310-abae-a5850022a9f2
-rw-r--r--compiler/ogomf.pas25
-rw-r--r--compiler/omfbase.pas47
2 files changed, 63 insertions, 9 deletions
diff --git a/compiler/ogomf.pas b/compiler/ogomf.pas
index 81aade73b6..41a194e3ad 100644
--- a/compiler/ogomf.pas
+++ b/compiler/ogomf.pas
@@ -1334,7 +1334,8 @@ implementation
var
RawRecord: TOmfRawRecord;
Header: TOmfRecord_THEADR;
- DllImport_COMENT: TOmfRecord_COMENT;
+ DllImport_COMENT: TOmfRecord_COMENT=nil;
+ DllImport_COMENT_IMPDEF: TOmfRecord_COMENT_IMPDEF=nil;
ModEnd: TOmfRecord_MODEND;
begin
{ write header record }
@@ -1346,20 +1347,26 @@ implementation
Header.Free;
{ write IMPDEF record }
- DllImport_COMENT:=TOmfRecord_COMENT.Create;
- DllImport_COMENT.CommentClass:=CC_OmfExtension;
+ DllImport_COMENT_IMPDEF:=TOmfRecord_COMENT_IMPDEF.Create;
+ DllImport_COMENT_IMPDEF.InternalName:=mangledname;
+ DllImport_COMENT_IMPDEF.ModuleName:=dllname;
if ordnr <= 0 then
begin
- if afuncname=mangledname then
- DllImport_COMENT.CommentString:=Chr(CC_OmfExtension_IMPDEF)+#0+Chr(Length(mangledname))+mangledname+Chr(Length(dllname))+dllname+#0
- else
- DllImport_COMENT.CommentString:=Chr(CC_OmfExtension_IMPDEF)+#0+Chr(Length(mangledname))+mangledname+Chr(Length(dllname))+dllname+Chr(Length(afuncname))+afuncname;
+ DllImport_COMENT_IMPDEF.ImportByOrdinal:=False;
+ DllImport_COMENT_IMPDEF.Name:=afuncname;
end
else
- DllImport_COMENT.CommentString:=Chr(CC_OmfExtension_IMPDEF)+#1+Chr(Length(mangledname))+mangledname+Chr(Length(dllname))+dllname+Chr(ordnr and $ff)+Chr((ordnr shr 8) and $ff);
+ begin
+ DllImport_COMENT_IMPDEF.ImportByOrdinal:=True;
+ DllImport_COMENT_IMPDEF.Ordinal:=ordnr;
+ end;
+
+ DllImport_COMENT:=TOmfRecord_COMENT.Create;
+ DllImport_COMENT_IMPDEF.EncodeTo(DllImport_COMENT);
+ FreeAndNil(DllImport_COMENT_IMPDEF);
DllImport_COMENT.EncodeTo(RawRecord);
+ FreeAndNil(DllImport_COMENT);
RawRecord.WriteTo(FWriter);
- DllImport_COMENT.Free;
{ write MODEND record }
ModEnd:=TOmfRecord_MODEND.Create;
diff --git a/compiler/omfbase.pas b/compiler/omfbase.pas
index 6c4d312fa9..2804f5e98f 100644
--- a/compiler/omfbase.pas
+++ b/compiler/omfbase.pas
@@ -337,6 +337,26 @@ interface
procedure EncodeTo(ComentRecord: TOmfRecord_COMENT);virtual;abstract;
end;
+ { TOmfRecord_COMENT_IMPDEF }
+
+ TOmfRecord_COMENT_IMPDEF = class(TOmfRecord_COMENT_Subtype)
+ private
+ FImportByOrdinal: Boolean;
+ FInternalName: string;
+ FModuleName: string;
+ FOrdinal: Word;
+ FName: string;
+ public
+ procedure DecodeFrom(ComentRecord: TOmfRecord_COMENT);override;
+ procedure EncodeTo(ComentRecord: TOmfRecord_COMENT);override;
+
+ property ImportByOrdinal: Boolean read FImportByOrdinal write FImportByOrdinal;
+ property InternalName: string read FInternalName write FInternalName;
+ property ModuleName: string read FModuleName write FModuleName;
+ property Ordinal: Word read FOrdinal write FOrdinal;
+ property Name: string read FName write FName;
+ end;
+
{ TOmfRecord_LNAMES }
TOmfRecord_LNAMES = class(TOmfParsedRecord)
@@ -1555,6 +1575,33 @@ implementation
RawRecord.CalculateChecksumByte;
end;
+ { TOmfRecord_COMENT_IMPDEF }
+
+ procedure TOmfRecord_COMENT_IMPDEF.DecodeFrom(ComentRecord: TOmfRecord_COMENT);
+ begin
+ {todo: implement}
+ internalerror(2019061502);
+ end;
+
+ procedure TOmfRecord_COMENT_IMPDEF.EncodeTo(ComentRecord: TOmfRecord_COMENT);
+ begin
+ ComentRecord.CommentClass:=CC_OmfExtension;
+ if ImportByOrdinal then
+ ComentRecord.CommentString:=Chr(CC_OmfExtension_IMPDEF)+#1+
+ Chr(Length(InternalName))+InternalName+
+ Chr(Length(ModuleName))+ModuleName+
+ Chr(Ordinal and $ff)+Chr((Ordinal shr 8) and $ff)
+ else if InternalName=Name then
+ ComentRecord.CommentString:=Chr(CC_OmfExtension_IMPDEF)+#0+
+ Chr(Length(InternalName))+InternalName+
+ Chr(Length(ModuleName))+ModuleName+#0
+ else
+ ComentRecord.CommentString:=Chr(CC_OmfExtension_IMPDEF)+#0+
+ Chr(Length(InternalName))+InternalName+
+ Chr(Length(ModuleName))+ModuleName+
+ Chr(Length(Name))+Name;
+ end;
+
{ TOmfRecord_LNAMES }
constructor TOmfRecord_LNAMES.Create;