Ver código fonte

* exporting of symbols from linux programs, i.e. exports clause in
programs allowed

git-svn-id: trunk@855 -

florian 20 anos atrás
pai
commit
a3e330526d
5 arquivos alterados com 47 adições e 2 exclusões
  1. 2 0
      .gitattributes
  2. 8 1
      compiler/psub.pas
  3. 3 1
      compiler/systems/t_linux.pas
  4. 18 0
      tests/webtbs/tw3964.pp
  5. 16 0
      tests/webtbs/uw3964.pp

+ 2 - 0
.gitattributes

@@ -6121,6 +6121,7 @@ tests/webtbs/tw3931a.pp svneol=native#text/plain
 tests/webtbs/tw3939.pp svneol=native#text/plain
 tests/webtbs/tw3953a.pp svneol=native#text/plain
 tests/webtbs/tw3953b.pp svneol=native#text/plain
+tests/webtbs/tw3964.pp -text
 tests/webtbs/tw3967.pp svneol=native#text/plain
 tests/webtbs/tw3968.pp svneol=native#text/plain
 tests/webtbs/tw3970.pp svneol=native#text/plain
@@ -6197,6 +6198,7 @@ tests/webtbs/uw3356.pp svneol=native#text/plain
 tests/webtbs/uw3429.pp svneol=native#text/plain
 tests/webtbs/uw3474a.pp svneol=native#text/plain
 tests/webtbs/uw3474b.pp svneol=native#text/plain
+tests/webtbs/uw3964.pp -text
 tests/webtbs/uw3968.pp svneol=native#text/plain
 tests/webtbs/uw4140.pp svneol=native#text/plain
 utils/Makefile svneol=native#text/plain

+ 8 - 1
compiler/psub.pas

@@ -1382,7 +1382,14 @@ implementation
                         consume_all_until(_SEMICOLON);
                      end
                    else if islibrary or
-                           (target_info.system in [system_i386_WIN32,system_i386_wdosx,system_i386_Netware,system_i386_netwlibc,system_arm_wince]) then
+                     (target_info.system in [
+                     system_i386_win32,
+                     system_i386_wdosx,
+                     system_i386_Netware,
+                     system_i386_netwlibc,
+                     system_arm_wince,
+                     system_x86_64_win64,
+                     system_ia64_win64]+system_linux) then
                      read_exports
                    else
                      begin

+ 3 - 1
compiler/systems/t_linux.pas

@@ -203,7 +203,7 @@ procedure TLinkerLinux.SetDefaultInfo;
 }
 
 const
-{$ifdef i386}   platform_select='-b elf32-i386 -m elf_i386';{$endif} 
+{$ifdef i386}   platform_select='-b elf32-i386 -m elf_i386';{$endif}
 {$ifdef x86_64} platform_select='-b elf64-x86-64 -m elf_x86_64';{$endif}
 {$ifdef powerpc}platform_select='-b elf32-powerpc -m elf32ppclinux';{$endif}
 {$ifdef sparc}  platform_select='-b elf32-sparc -m elf32_sparc';{$endif}
@@ -627,6 +627,8 @@ begin
 { Strip the library ? }
   if success and (cs_link_strip in aktglobalswitches) then
    begin
+     { only remove non global symbols and debugging info for a library }
+     Info.DllCmd[2]:='strip --discard-all --strip-debug $EXE';
      SplitBinCmd(Info.DllCmd[2],binstr,cmdstr);
      Replace(cmdstr,'$EXE',maybequoted(current_module.sharedlibfilename^));
      success:=DoExec(FindUtil(utilsprefix+binstr),cmdstr,true,false);

+ 18 - 0
tests/webtbs/tw3964.pp

@@ -0,0 +1,18 @@
+{ %target=linux }
+{$mode objfpc}
+
+{$linklib libuw3964}
+
+function testfunc : longint;public name 'testfunc';
+begin
+  result:=1234;
+end;
+
+function f : longint;external name 'f';
+
+exports
+  testfunc name 'testfunc';
+
+begin
+  writeln(f);
+end.

+ 16 - 0
tests/webtbs/uw3964.pp

@@ -0,0 +1,16 @@
+{ %target=linux }
+{$mode objfpc}
+library uw3964;
+
+  function testfunc : longint;external name 'testfunc';
+
+  function f : longint;public;
+    begin
+      result:=testfunc;
+    end;
+
+  exports
+    f;
+
+begin
+end.