From 4fe8654fe4802626ec08df663acf47d95a0e14ff Mon Sep 17 00:00:00 2001
From: marco <marco@freepascal.org>
Date: Sun, 15 Jan 2006 15:22:29 +0000
Subject: [PATCH]  * shared lib i_ and t_ changes. Some small comments cleanup
 to t_

git-svn-id: trunk@2297 -
---
 compiler/systems/i_bsd.pas |  6 +++++-
 compiler/systems/t_bsd.pas | 36 +++++++++++++++++++++++-------------
 2 files changed, 28 insertions(+), 14 deletions(-)

diff --git a/compiler/systems/i_bsd.pas b/compiler/systems/i_bsd.pas
index cd7c954bc8..3a9f6bf209 100644
--- a/compiler/systems/i_bsd.pas
+++ b/compiler/systems/i_bsd.pas
@@ -35,7 +35,11 @@ unit i_bsd;
             system       : system_i386_FreeBSD;
             name         : 'FreeBSD/ELF for i386';
             shortname    : 'FreeBSD';
-            flags        : [tf_pic_uses_got,tf_files_case_sensitive,tf_use_function_relative_addresses];
+            flags        : [tf_pic_uses_got,tf_files_case_sensitive,tf_use_function_relative_addresses,
+            {$ifdef segment_threadvars}
+                                        tf_section_threadvars,
+            {$endif segment_threadvars}
+                           tf_needs_symbol_type,tf_needs_symbol_size {,tf_smartlink_sections}];
             cpu          : cpu_i386;
             unit_env     : 'BSDUNITS';
             extradefines : 'UNIX;BSD;HASUNIX';
diff --git a/compiler/systems/t_bsd.pas b/compiler/systems/t_bsd.pas
index 070aaadb70..b70fcf47e0 100644
--- a/compiler/systems/t_bsd.pas
+++ b/compiler/systems/t_bsd.pas
@@ -206,10 +206,13 @@ begin
 end;
 
 
-procedure texportlibbsd.generatelib;
+procedure texportlibbsd.generatelib;  // straight t_linux copy for now.
 var
   hp2 : texported_item;
+  sym : tasmsymbol;
+  r : treference;
 begin
+  new_section(asmlist[al_procedures],sec_code,'',0);
   hp2:=texported_item(current_module._exports.first);
   while assigned(hp2) do
    begin
@@ -220,19 +223,26 @@ begin
           is declared with cdecl }
         if tprocsym(hp2.sym).first_procdef.mangledname<>hp2.name^ then
          begin
-{$ifdef i386}
            { place jump in al_procedures }
-           asmlist[al_procedures].concat(Tai_align.Create_op(4,$90));
+           asmlist[al_procedures].concat(tai_align.create(target_info.alignment.procalign));
            asmlist[al_procedures].concat(Tai_symbol.Createname_global(hp2.name^,AT_FUNCTION,0));
-           asmlist[al_procedures].concat(Taicpu.Op_sym(A_JMP,S_NO,objectlibrary.newasmsymbol(tprocsym(hp2.sym).first_procdef.mangledname,AB_EXTERNAL,AT_FUNCTION)));
+           if (cs_create_pic in aktmoduleswitches) and
+             { other targets need to be checked how it works }
+             (target_info.system in [system_i386_freebsd]) then
+             begin
+{$ifdef x86}
+               sym:=objectlibrary.newasmsymbol(tprocsym(hp2.sym).first_procdef.mangledname,AB_EXTERNAL,AT_FUNCTION);
+               reference_reset_symbol(r,sym,0);
+               if cs_create_pic in aktmoduleswitches then
+                 r.refaddr:=addr_pic
+               else
+                 r.refaddr:=addr_full;
+               asmlist[al_procedures].concat(taicpu.op_ref(A_JMP,S_NO,r));
+{$endif x86}
+             end
+           else
+             cg.a_jmp_name(asmlist[al_procedures],tprocsym(hp2.sym).first_procdef.mangledname);
            asmlist[al_procedures].concat(Tai_symbol_end.Createname(hp2.name^));
-{$endif i386}
-{$ifdef powerpc}
-           asmlist[al_procedures].concat(Tai_align.create(16));
-           asmlist[al_procedures].concat(Tai_symbol.Createname_global(hp2.name^,AT_FUNCTION,0));
-           asmlist[al_procedures].concat(Taicpu.Op_sym(A_B,objectlibrary.newasmsymbol(tprocsym(hp2.sym).first_procdef.mangledname,AB_EXTERNAL,AT_FUNCTION)));
-           asmlist[al_procedures].concat(Tai_symbol_end.Createname(hp2.name^));
-{$endif powerpc}
          end;
       end
      else
@@ -243,7 +253,7 @@ end;
 
 
 {*****************************************************************************
-                                  TLINKERLINUX
+                                  TLINKERBSD
 *****************************************************************************}
 
 Constructor TLinkerBSD.Create;
@@ -457,7 +467,7 @@ begin
         else
          begin
            linklibc:=true;
-           linkdynamic:=false; { libc will include the ld-linux for us }
+           linkdynamic:=false; { libc will include the ld-* for us }
          end;
       end;
      { be sure that libc is the last lib }