فهرست منبع

+ First things for win32 export sections

florian 27 سال پیش
والد
کامیت
8210a86724
3فایلهای تغییر یافته به همراه227 افزوده شده و 3 حذف شده
  1. 157 0
      compiler/export.pas
  2. 5 1
      compiler/files.pas
  3. 65 2
      compiler/win_targ.pas

+ 157 - 0
compiler/export.pas

@@ -0,0 +1,157 @@
+{
+    $Id$
+    Copyright (c) 1998 by Florian Klaempfl
+
+    This unit implements an uniform export object
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ ****************************************************************************}
+unit export;
+
+interface
+
+uses
+  cobjects;
+
+type
+   pexported_procedure = ^texported_procedure;
+   texported_procedure = object(tlinkedlist_item)
+      ordnr : word;
+      name,func : pstring;
+      lab : pointer; { should be plabel, but this gaves problems with circular units }
+      constructor init(const n,s : string;o : word);
+      destructor done;virtual;
+   end;
+
+   pexportlib=^texportlib;
+   texportlib=object
+      constructor Init;
+      destructor Done;
+      procedure preparelib(const s:string);virtual;
+      procedure exportprocedure(const func:string;index:longint;const name:string);virtual;
+      procedure generatelib;virtual;
+   end;
+
+var
+   exportlib : pexportlib;
+
+procedure InitExport;
+procedure DoneExport;
+
+implementation
+
+uses
+  systems,verbose,globals
+{$ifdef i386}
+  ,os2_targ
+  ,win_targ
+{$endif}
+  ,lin_targ
+  ;
+
+{****************************************************************************
+                           TImported_procedure
+****************************************************************************}
+
+constructor texported_procedure.init(const n,s : string;o : word);
+begin
+  inherited init;
+  func:=stringdup(n);
+  name:=stringdup(s);
+  ordnr:=o;
+  lab:=nil;
+end;
+
+
+destructor texported_procedure.done;
+begin
+  stringdispose(name);
+  inherited done;
+end;
+
+
+{****************************************************************************
+                              TImportLib
+****************************************************************************}
+
+constructor texportlib.Init;
+begin
+end;
+
+
+destructor texportlib.Done;
+begin
+end;
+
+
+procedure texportlib.preparelib(const s:string);
+begin
+  Message(exec_e_dll_not_supported);
+end;
+
+
+procedure texportlib.exportprocedure(const func : string;index:longint;const name:string);
+begin
+  Message(exec_e_dll_not_supported);
+end;
+
+
+procedure texportlib.generatelib;
+begin
+  Message(exec_e_dll_not_supported);
+end;
+
+
+procedure DoneExport;
+begin
+  if assigned(exportlib) then
+    dispose(exportlib,done);
+end;
+
+
+procedure InitExport;
+begin
+  case target_info.target of
+{$ifdef i386}
+{    target_i386_Linux :
+      importlib:=new(pimportliblinux,Init);
+}
+    target_i386_Win32 :
+      exportlib:=new(pexportlibwin32,Init);
+{
+    target_i386_OS2 :
+      exportlib:=new(pexportlibos2,Init);
+}
+{$endif i386}
+{$ifdef m68k}
+{
+    target_m68k_Linux :
+      importlib:=new(pimportliblinux,Init);
+}
+{$endif m68k}
+    else
+      exportlib:=new(pexportlib,Init);
+  end;
+end;
+
+
+end.
+{
+  $Log$
+  Revision 1.1  1998-10-27 10:22:34  florian
+    + First things for win32 export sections
+
+}

+ 5 - 1
compiler/files.pas

@@ -142,6 +142,7 @@ unit files;
           loaded_from   : pmodule;
           uses_imports  : boolean;  { Set if the module imports from DLL's.}
           imports       : plinkedlist;
+          _exports      : plinkedlist;
 
           sourcefiles   : pfilemanager;
           linksharedlibs,
@@ -1022,7 +1023,10 @@ unit files;
 end.
 {
   $Log$
-  Revision 1.67  1998-10-26 22:23:29  peter
+  Revision 1.68  1998-10-27 10:22:34  florian
+    + First things for win32 export sections
+
+  Revision 1.67  1998/10/26 22:23:29  peter
     + fixpath() has an extra option to allow a ./ as path
 
   Revision 1.66  1998/10/19 18:07:11  peter

+ 65 - 2
compiler/win_targ.pas

@@ -25,7 +25,7 @@ unit win_targ;
 
   interface
 
-  uses import;
+  uses import,export;
 
   type
     pimportlibwin32=^timportlibwin32;
@@ -36,6 +36,14 @@ unit win_targ;
       procedure generatesmartlib;
     end;
 
+    pexportlibwin32=^texportlibwin32;
+    texportlibwin32=object(texportlib)
+      procedure preparelib(const s:string);virtual;
+      procedure exportprocedure(const func : string;
+        index : longint;const name : string);virtual;
+      procedure generatelib;virtual;
+    end;
+
     { sets some flags of the executable }
     procedure postprocessexecutable(n : string);
 
@@ -349,6 +357,58 @@ unit win_targ;
            end;
       end;
 
+    procedure texportlibwin32.preparelib(const s:string);
+
+      begin
+         if not(assigned(exportssection)) then
+           exportssection:=new(paasmoutput,init);
+      end;
+
+    procedure texportlibwin32.exportprocedure(const func : string;
+      index : longint;const name : string);
+
+      begin
+      end;
+
+    procedure texportlibwin32.generatelib;
+
+      var
+         ordinal_base,entries,named_entries : longint;
+         l1,l2,l3,l4 : plabel;
+
+      begin
+         ordinal_base:=0;
+         getlabel(l1);
+         getlabel(l2);
+         getlabel(l3);
+         getlabel(l4);
+         { export flags }
+         exportssection^.concat(new(pai_const,init_32bit(0)));
+         { date/time stamp }
+         exportssection^.concat(new(pai_const,init_32bit(0)));
+         { major version }
+         exportssection^.concat(new(pai_const,init_16bit(0)));
+         { minor version }
+         exportssection^.concat(new(pai_const,init_16bit(0)));
+         { pointer to dll name }
+         importssection^.concat(new(pai_const,init_rva(strpnew(lab2str(l1)))));
+         { ordinal base }
+         exportssection^.concat(new(pai_const,init_32bit(0)));
+         { number of entries }
+         exportssection^.concat(new(pai_const,init_32bit(entries)));
+         { number of named entries }
+         exportssection^.concat(new(pai_const,init_32bit(named_entries)));
+         { address of export address table }
+         importssection^.concat(new(pai_const,init_rva(strpnew(lab2str(l2)))));
+         { address of name pointer pointers }
+         importssection^.concat(new(pai_const,init_rva(strpnew(lab2str(l3)))));
+         { address of ordinal number pointers }
+         importssection^.concat(new(pai_const,init_rva(strpnew(lab2str(l4)))));
+
+         { the name }
+         importssection^.concat(new(pai_label,init(l1)));
+         importssection^.concat(new(pai_string,init(current_module^.modulename^+target_os.sharedlibext+#0)));
+      end;
 
     procedure postprocessexecutable(n : string);
 
@@ -390,7 +450,10 @@ unit win_targ;
 end.
 {
   $Log$
-  Revision 1.11  1998-10-22 17:54:09  florian
+  Revision 1.12  1998-10-27 10:22:35  florian
+    + First things for win32 export sections
+
+  Revision 1.11  1998/10/22 17:54:09  florian
     + switch $APPTYPE for win32 added
 
   Revision 1.10  1998/10/22 15:18:51  florian