Browse Source

* exports info handling refactored, -E will be passed to ld if necessary

git-svn-id: trunk@1922 -
florian 19 years ago
parent
commit
a1189a9d64
4 changed files with 30 additions and 9 deletions
  1. 3 4
      compiler/pexports.pas
  2. 3 4
      compiler/pmodules.pas
  3. 1 0
      compiler/ppu.pas
  4. 23 1
      compiler/systems/t_linux.pas

+ 3 - 4
compiler/pexports.pas

@@ -1,5 +1,5 @@
 {
-    Copyright (c) 1998-2002 by Florian Klaempfl
+    Copyright (c) 1998-2005 by Florian Klaempfl
 
     This unit handles the exports parsing
 
@@ -28,8 +28,6 @@ interface
     { reads an exports statement in a library }
     procedure read_exports;
 
-    var
-      BinaryContainsExports: boolean = false;
 implementation
 
     uses
@@ -38,6 +36,7 @@ implementation
        { global }
        globals,tokens,verbose,
        systems,
+       ppu,fmodule,
        { symtable }
        symconst,symbase,symtype,symsym,
        { pass 1 }
@@ -78,7 +77,7 @@ implementation
         end;
 
       begin
-         BinaryContainsExports:=true;
+         current_module.flags:=current_module.flags or uf_has_exports;
          DefString:='';
          InternalProcName:='';
          consume(_EXPORTS);

+ 3 - 4
compiler/pmodules.pas

@@ -1418,7 +1418,7 @@ implementation
            DLL will include the edata section }
          if assigned(exportlib) and
             (target_info.system in [system_i386_win32,system_i386_wdosx]) and
-            BinaryContainsExports then
+            ((current_module.flags or uf_has_exports)<>0) then
            asmlist[al_procedures].concat(tai_const.create_sym(exportlib.edatalabel));
 
          If resourcestrings.ResStrCount>0 then
@@ -1551,10 +1551,9 @@ implementation
             if (not current_module.is_unit) then
              begin
                if DLLSource then
-                linker.MakeSharedLibrary
+                 linker.MakeSharedLibrary
                else
-                linker.MakeExecutable;
-               BinaryContainsExports:=false;
+                 linker.MakeExecutable;
              end;
           end;
       end;

+ 1 - 0
compiler/ppu.pas

@@ -150,6 +150,7 @@ const
   uf_local_symtable = $20000; { this unit has a local symtable stored }
   uf_uses_variants  = $40000; { this unit uses variants }
   uf_has_resourcefiles = $80000; { this unit has external resources (using $R directive)}
+  uf_has_exports = $100000;   { this module or a used unit has exports }
 
 
 type

+ 23 - 1
compiler/systems/t_linux.pas

@@ -242,7 +242,7 @@ begin
   with Info do
    begin
      ExeCmd[1]:='ld '+platform_select+' $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP -L. -o $EXE $RES';
-     DllCmd[1]:='ld '+platform_select+' $OPT $INIT $FINI $SONAME -shared -L. -o $EXE $RES';
+     DllCmd[1]:='ld '+platform_select+' $OPT $INIT $FINI $SONAME -shared -L. -o $EXE $RES -E';
      DllCmd[2]:='strip --strip-unneeded $EXE';
 {$ifdef m68k}
      libctype:=glibc2;
@@ -571,6 +571,23 @@ begin
 end;
 
 
+function contains_exports : boolean;
+  var
+    hp : tused_unit;
+  begin
+    result:=((current_module.flags and uf_has_exports)=uf_has_exports);
+    if not result then
+      begin
+      hp:=tused_unit(usedunits.first);
+      While Assigned(hp) and not result do
+        begin
+          result:=((hp.u.flags and uf_has_exports)=uf_has_exports);
+          hp:=tused_unit(hp.next);
+        end;
+      end;
+  end;
+
+
 function TLinkerLinux.MakeExecutable:boolean;
 var
   binstr : String;
@@ -618,6 +635,11 @@ begin
   Replace(cmdstr,'$STRIP',StripStr);
   Replace(cmdstr,'$GCSECTIONS',GCSectionsStr);
   Replace(cmdstr,'$DYNLINK',DynLinkStr);
+
+  { create dynamic symbol table? }
+  if contains_exports then
+    cmdstr:=cmdstr+' -E';
+
   success:=DoExec(FindUtil(utilsprefix+BinStr),CmdStr,true,false);
 
 { Remove ReponseFile }