Browse Source

--- Merging r14241 into '.':
U compiler/systems.pas
--- Merging r14279 into '.':
U compiler/Makefile
U compiler/Makefile.fpc
--- Merging r14288 into '.':
U compiler/systems/t_sunos.pas
--- Merging r14294 into '.':
G compiler/systems/t_sunos.pas
--- Merging r14356 into '.':
G compiler/systems/t_sunos.pas
--- Merging r14387 into '.':
U compiler/systems/i_sunos.pas
--- Merging r14388 into '.':
U compiler/expunix.pas
--- Merging r14389 into '.':
U compiler/x86/rax86att.pas
--- Merging r14391 into '.':
U rtl/solaris/x86_64/start.inc

# revisions: 14241,14279,14288,14294,14356,14387,14388,14389,14391
------------------------------------------------------------------------
r14241 | pierre | 2009-11-21 17:30:25 +0100 (Sat, 21 Nov 2009) | 1 line
Changed paths:
M /trunk/compiler/systems.pas

* Set solaris default for x86_64 compiler if on solaris system
------------------------------------------------------------------------
------------------------------------------------------------------------
r14279 | florian | 2009-11-27 16:22:15 +0100 (Fri, 27 Nov 2009) | 1 line
Changed paths:
M /trunk/compiler/Makefile
M /trunk/compiler/Makefile.fpc

+ first patches to support mips/mipsel in the compiler makefile
------------------------------------------------------------------------
------------------------------------------------------------------------
r14288 | pierre | 2009-11-29 21:15:00 +0100 (Sun, 29 Nov 2009) | 1 line
Changed paths:
M /trunk/compiler/systems/t_sunos.pas

* remove path for sparc
------------------------------------------------------------------------
------------------------------------------------------------------------
r14294 | pierre | 2009-12-01 14:52:46 +0100 (Tue, 01 Dec 2009) | 1 line
Changed paths:
M /trunk/compiler/systems/t_sunos.pas

* modify native likner args for library creation
------------------------------------------------------------------------
------------------------------------------------------------------------
r14356 | pierre | 2009-12-07 23:27:59 +0100 (Mon, 07 Dec 2009) | 1 line
Changed paths:
M /trunk/compiler/systems/t_sunos.pas

* fix native linker end group delimiter
------------------------------------------------------------------------
------------------------------------------------------------------------
r14387 | pierre | 2009-12-10 13:46:19 +0100 (Thu, 10 Dec 2009) | 1 line
Changed paths:
M /trunk/compiler/systems/i_sunos.pas

* add tf_needs_symbol_type for x86_64 solaris
------------------------------------------------------------------------
------------------------------------------------------------------------
r14388 | pierre | 2009-12-10 13:47:40 +0100 (Thu, 10 Dec 2009) | 1 line
Changed paths:
M /trunk/compiler/expunix.pas

* handle i386/x86_64 solaris pic as for linux
------------------------------------------------------------------------
------------------------------------------------------------------------
r14389 | pierre | 2009-12-10 14:07:44 +0100 (Thu, 10 Dec 2009) | 1 line
Changed paths:
M /trunk/compiler/x86/rax86att.pas

* accept @PLT for pic functions
------------------------------------------------------------------------
------------------------------------------------------------------------
r14391 | pierre | 2009-12-10 14:23:20 +0100 (Thu, 10 Dec 2009) | 1 line
Changed paths:
M /trunk/rtl/solaris/x86_64/start.inc

* Adapt start.inc to pic code
------------------------------------------------------------------------

git-svn-id: branches/fixes_2_4@14732 -

marco 15 years ago
parent
commit
443ff1dfdf

+ 34 - 4
compiler/Makefile

@@ -1,8 +1,8 @@
 #
-# Don't edit, this file is generated by FPCMake Version 2.0.0 [2009/11/17]
+# Don't edit, this file is generated by FPCMake Version 2.0.0 [2009/11/27]
 #
 default: all
-MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-haiku i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-solaris x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-darwin arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded avr-embedded armeb-linux armeb-embedded
+MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-haiku i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-solaris x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-darwin arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded avr-embedded armeb-linux armeb-embedded mipsel-linux
 BSDs = freebsd netbsd openbsd darwin
 UNIXs = linux $(BSDs) solaris qnx haiku
 LIMIT83fs = go32v2 os2 emx watcom
@@ -267,7 +267,7 @@ PACKAGESDIR:=$(wildcard $(FPCDIR) $(FPCDIR)/packages $(FPCDIR)/packages/base $(F
 override PACKAGE_NAME=compiler
 override PACKAGE_VERSION=2.2.2
 unexport FPC_VERSION FPC_COMPILERINFO
-CYCLETARGETS=i386 powerpc sparc arm x86_64 powerpc64 m68k armeb
+CYCLETARGETS=i386 powerpc sparc arm x86_64 powerpc64 m68k armeb # mipsel mips
 ALLTARGETS=$(CYCLETARGETS)
 ifdef ALPHA
 PPC_TARGET=alpha
@@ -296,6 +296,12 @@ endif
 ifdef ARMEB
 PPC_TARGET=armeb
 endif
+ifdef MIPS
+PPC_TARGET=mips
+endif
+ifdef MIPSEL
+PPC_TARGET=mipsel
+endif
 ifndef PPC_TARGET
 PPC_TARGET=$(CPU_TARGET)
 endif
@@ -561,6 +567,9 @@ endif
 ifeq ($(FULL_TARGET),armeb-embedded)
 override TARGET_DIRS+=utils
 endif
+ifeq ($(FULL_TARGET),mipsel-linux)
+override TARGET_DIRS+=utils
+endif
 ifeq ($(FULL_TARGET),i386-linux)
 override TARGET_PROGRAMS+=pp
 endif
@@ -738,6 +747,9 @@ endif
 ifeq ($(FULL_TARGET),armeb-embedded)
 override TARGET_PROGRAMS+=pp
 endif
+ifeq ($(FULL_TARGET),mipsel-linux)
+override TARGET_PROGRAMS+=pp
+endif
 override INSTALL_FPCPACKAGE=y
 ifeq ($(FULL_TARGET),i386-linux)
 override COMPILER_INCLUDEDIR+=$(CPC_TARGET)
@@ -916,6 +928,9 @@ endif
 ifeq ($(FULL_TARGET),armeb-embedded)
 override COMPILER_INCLUDEDIR+=$(CPC_TARGET)
 endif
+ifeq ($(FULL_TARGET),mipsel-linux)
+override COMPILER_INCLUDEDIR+=$(CPC_TARGET)
+endif
 ifeq ($(FULL_TARGET),i386-linux)
 override COMPILER_UNITDIR+=$(COMPILERSOURCEDIR)
 endif
@@ -1093,6 +1108,9 @@ endif
 ifeq ($(FULL_TARGET),armeb-embedded)
 override COMPILER_UNITDIR+=$(COMPILERSOURCEDIR)
 endif
+ifeq ($(FULL_TARGET),mipsel-linux)
+override COMPILER_UNITDIR+=$(COMPILERSOURCEDIR)
+endif
 ifeq ($(FULL_TARGET),i386-linux)
 override COMPILER_TARGETDIR+=.
 endif
@@ -1270,6 +1288,9 @@ endif
 ifeq ($(FULL_TARGET),armeb-embedded)
 override COMPILER_TARGETDIR+=.
 endif
+ifeq ($(FULL_TARGET),mipsel-linux)
+override COMPILER_TARGETDIR+=.
+endif
 ifeq ($(FULL_TARGET),i386-linux)
 override COMPILER_UNITTARGETDIR+=$(CPU_UNITDIR)/units/$(FULL_TARGET)
 endif
@@ -1447,6 +1468,9 @@ endif
 ifeq ($(FULL_TARGET),armeb-embedded)
 override COMPILER_UNITTARGETDIR+=$(CPU_UNITDIR)/units/$(FULL_TARGET)
 endif
+ifeq ($(FULL_TARGET),mipsel-linux)
+override COMPILER_UNITTARGETDIR+=$(CPU_UNITDIR)/units/$(FULL_TARGET)
+endif
 ifdef REQUIRE_UNITSDIR
 override UNITSDIR+=$(REQUIRE_UNITSDIR)
 endif
@@ -2391,6 +2415,9 @@ endif
 ifeq ($(FULL_TARGET),armeb-embedded)
 REQUIRE_PACKAGES_RTL=1
 endif
+ifeq ($(FULL_TARGET),mipsel-linux)
+REQUIRE_PACKAGES_RTL=1
+endif
 ifdef REQUIRE_PACKAGES_RTL
 PACKAGEDIR_RTL:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /rtl/Makefile.fpc,$(PACKAGESDIR))))))
 ifneq ($(PACKAGEDIR_RTL),)
@@ -3171,6 +3198,9 @@ endif
 ifeq ($(FULL_TARGET),armeb-embedded)
 TARGET_DIRS_UTILS=1
 endif
+ifeq ($(FULL_TARGET),mipsel-linux)
+TARGET_DIRS_UTILS=1
+endif
 ifdef TARGET_DIRS_UTILS
 utils_all:
 	$(MAKE) -C utils all
@@ -3285,7 +3315,7 @@ INSTALLEXEFILE=$(PPCROSSNAME)
 else
 INSTALLEXEFILE=$(EXENAME)
 endif
-PPC_TARGETS=i386 m68k powerpc sparc arm armeb x86_64 powerpc64 alpha vis ia64
+PPC_TARGETS=i386 m68k powerpc sparc arm armeb x86_64 powerpc64 alpha vis ia64 mips mipsel
 .PHONY: $(PPC_TARGETS)
 $(PPC_TARGETS):
 	$(MAKE) PPC_TARGET=$@ CPU_UNITDIR=$@ all

+ 8 - 2
compiler/Makefile.fpc

@@ -32,7 +32,7 @@ fpcdir=..
 unexport FPC_VERSION FPC_COMPILERINFO
 
 # Which platforms are ready for inclusion in the cycle
-CYCLETARGETS=i386 powerpc sparc arm x86_64 powerpc64 m68k armeb
+CYCLETARGETS=i386 powerpc sparc arm x86_64 powerpc64 m68k armeb # mipsel mips
 
 # All supported targets used for clean
 ALLTARGETS=$(CYCLETARGETS)
@@ -65,6 +65,12 @@ endif
 ifdef ARMEB
 PPC_TARGET=armeb
 endif
+ifdef MIPS
+PPC_TARGET=mips
+endif
+ifdef MIPSEL
+PPC_TARGET=mipsel
+endif
 
 # Default is to generate a compiler for the same
 # platform as CPU_TARGET (a native compiler)
@@ -260,7 +266,7 @@ endif
 # CPU targets
 #####################################################################
 
-PPC_TARGETS=i386 m68k powerpc sparc arm armeb x86_64 powerpc64 alpha vis ia64
+PPC_TARGETS=i386 m68k powerpc sparc arm armeb x86_64 powerpc64 alpha vis ia64 mips mipsel
 
 .PHONY: $(PPC_TARGETS)
 

+ 1 - 1
compiler/expunix.pas

@@ -152,7 +152,7 @@ begin
            current_asmdata.asmlists[al_procedures].concat(Tai_symbol.Createname_global(hp2.name^,AT_FUNCTION,0));
            if (cs_create_pic in current_settings.moduleswitches) and
              { other targets need to be checked how it works }
-             (target_info.system in [system_i386_freebsd,system_x86_64_freebsd,system_x86_64_linux,system_i386_linux]) then
+             (target_info.system in [system_i386_freebsd,system_x86_64_freebsd,system_x86_64_linux,system_i386_linux,system_x86_64_solaris,system_i386_solaris]) then
              begin
 {$ifdef x86}
                sym:=current_asmdata.RefAsmSymbol(pd.mangledname);

+ 4 - 0
compiler/systems.pas

@@ -868,6 +868,10 @@ begin
     default_target(system_x86_64_freebsd);
     {$define default_target_set}
    {$endif}
+   {$ifdef solaris}
+    default_target(system_x86_64_solaris);
+    {$define default_target_set}
+   {$endif}
    {$ifdef darwin}
     default_target(system_x86_64_darwin);
     {$define default_target_set}

+ 2 - 1
compiler/systems/i_sunos.pas

@@ -99,7 +99,8 @@ unit i_sunos;
             system       : system_x86_64_solaris;
             name         : 'Solaris for x86-64';
             shortname    : 'solaris';
-            flags        : [tf_needs_symbol_size,tf_under_development,
+            flags        : [tf_needs_symbol_size,tf_needs_symbol_type,
+			    tf_under_development,
                             tf_files_case_sensitive,tf_use_function_relative_addresses,
                             tf_requires_proper_alignment,tf_smartlink_library,
                             tf_has_winlike_resources];

+ 13 - 10
compiler/systems/t_sunos.pas

@@ -118,9 +118,6 @@ implementation
 Constructor TLinkersolaris.Create;
 begin
   Inherited Create;
-{$ifndef x86_64}
-  use_gnu_ld:=true;
-{$endif}
 
   if cs_link_native in init_settings.globalswitches then
     use_gnu_ld:=false
@@ -148,10 +145,16 @@ procedure TLinkersolaris.SetDefaultInfo;
 const
   gld = 'gld -m elf_x86_64 ';
   solaris_ld = '/usr/bin/ld -64 ';
-{$else}
+{$endif}
+{$ifdef i386}
 const
   gld = 'gld ';
   solaris_ld = '/usr/bin/ld ';
+{$endif }
+{$ifdef sparc}
+const
+  gld = 'gld ';
+  solaris_ld = 'ld ';
 {$endif}
 begin
   Glibc2:=false;
@@ -163,7 +166,7 @@ begin
      ExeCmd[2]:=solaris_ld + '$OPT $DYNLINK $STATIC $STRIP -L . -o $EXE $RESDATA';
      DllCmd[1]:=gld + '$OPT $INITFINI -shared -L. -o $EXE $RES';
      DllCmd[2]:='gstrip --strip-unneeded $EXE';
-     DllCmd[3]:=solaris_ld + '$OPT $INITFINI -M $VERSIONFILE -shared -L. -o $EXE $RESDATA';
+     DllCmd[3]:=solaris_ld + '$OPT $INITFINI -M $VERSIONFILE -G -Bdynamic -L. -o $EXE $RESDATA';
      DynamicLinker:=''; { Gnu uses the default }
      Glibc21:=false;
 {$ELSE}
@@ -412,7 +415,7 @@ begin
         S:=StaticLibFiles.GetFirst;
         LinkRes.AddFileName(maybequoted(s))
       end;
-     linkres.add('(-'); 
+     linkres.add('-)'); 
    end;
 
   { Write sharedlibraries like -l<lib>, also add the needed dynamic linker
@@ -522,10 +525,10 @@ begin
   Replace(cmdstr,'$STATIC',StaticStr);
   Replace(cmdstr,'$STRIP',StripStr);
   Replace(cmdstr,'$DYNLINK',DynLinkStr);
-  if use_gnu_ld then
+  if BinStr[1]<>'/' then
     success:=DoExec(FindUtil(utilsprefix+BinStr),CmdStr,true,false)
   else { Using utilsprefix has no sense on /usr/bin/ld }
-    success:=DoExec(FindUtil(BinStr),Trim(CmdStr),true,false);
+    success:=DoExec(BinStr,Trim(CmdStr),true,false);
 
 { Remove ReponseFile }
 {$IFNDEF LinkTest}
@@ -589,10 +592,10 @@ begin
       linkres.free;
       Replace(cmdstr,'$RESDATA',linkstr);
     end;
-  if use_gnu_ld then
+  if BinStr[1]<>'/' then
     success:=DoExec(FindUtil(utilsprefix+BinStr),CmdStr,true,false)
   else { Using utilsprefix has no sense on /usr/bin/ld }
-    success:=DoExec(FindUtil(BinStr),Trim(CmdStr),true,false);
+    success:=DoExec(BinStr,Trim(CmdStr),true,false);
 
 
 { Strip the library ? }

+ 2 - 1
compiler/x86/rax86att.pas

@@ -278,7 +278,8 @@ Implementation
               if actasmtoken=AS_ID then
                 begin
 {$ifdef x86_64}
-                  if actasmpattern='GOTPCREL' then
+                  if (actasmpattern='GOTPCREL') or
+		     (actasmpattern='PLT') then
 {$endif x86_64}
 {$ifdef i386}
                   if actasmpattern='GOT' then

+ 53 - 16
rtl/solaris/x86_64/start.inc

@@ -121,12 +121,14 @@ __longdouble_used:
 
 *)
 var
-  _environ : pointer; cvar;
-  __environ_lock : Array[0..24-1] of byte; cvar;
-  ___Argv : pointer;cvar;
-  __longdouble_used : longint; cvar;
+  _environ : pointer; cvar; public;
+  __environ_lock : Array[0..24-1] of byte; cvar; public;
+  ___Argv : pointer;cvar; public;
+  __longdouble_used : longint; cvar; public;
+var
+  _DYNAMIC : pointer;cvar;weakexternal;
 
-procedure _DYNAMIC;cdecl;external 'c' name '_DYNAMIC'; { should be weak }
+//procedure _DYNAMIC;cdecl;external 'c' name '_DYNAMIC'; { should be weak }
 
 (*
 /*
@@ -182,11 +184,15 @@ asm
  *	  0			0(%rbp)
  */
 *)
+{$ifdef FPC_PIC}
+   movq   _DYNAMIC@GOTPCREL(%rip),%rax
+{$else FPC_PIC}
    movq   $_DYNAMIC,%rax
+{$endif FPC_PIC}
    testq  %rax,%rax
    je     .Label1
    movq   %rdx,%rdi { register rt_do_exit }
-   call   atexit
+   call   atexit{$ifdef FPC_PIC}@PLT{$endif}
 .Label1:
 (* What should we do about this?
    movq   $_fini,%rdi
@@ -198,15 +204,36 @@ asm
  */
 *)
    movq   0x10(%rbp),%rax
-   movl   %eax,argc
-   movq   _environ,%rcx
+{$ifdef FPC_PIC}
+   movq   argc@GOTPCREL(%rip),%rcx
+{$else FPC_PIC}
+   movq   $argc,%rcx
+{$endif FPC_PIC}
+   movl   %eax,(%rcx)
+{$ifdef FPC_PIC}
+   movq   _environ@GOTPCREL(%rip),%rcx
+   movq   (%rcx),%rcx
+{$else FPC_PIC}
+   movq   _environ{$ifdef FPC_HAS_RIP_RELATIVE}(%rip){$endif},%rcx
+{$endif FPC_PIC}
    testq  %rcx,%rcx
    jne    .Label3
    lea    0x20(%rbp,%rax,8),%rcx
 .Label3:
-   movq   %rcx,_environ
-   // Specificc to Free Pascal
-   movq   %rcx,envp
+{$ifdef FPC_PIC}
+   movq   _environ@GOTPCREL(%rip),%rbx
+   movq   %rcx,(%rbx)
+{$else FPC_PIC}
+   movq   %rcx,_environ{$ifdef FPC_HAS_RIP_RELATIVE}(%rip){$endif}
+{$endif FPC_PIC}
+   // Specific to Free Pascal
+{$ifdef FPC_PIC}
+   movq   envp@GOTPCREL(%rip),%rbx
+   movq   %rcx,(%rbx)
+{$else FPC_PIC}
+   movq   %rcx,envp{$ifdef FPC_HAS_RIP_RELATIVE}(%rip){$endif}
+{$endif FPC_PIC}
+
 (*
 /*
  * Force stack alignment - below here there must have been an even
@@ -216,8 +243,18 @@ asm
    andq   $-16,%rsp
    pushq  %rdx
    leaq   24(%rbp),%rdx   { argv (B) }
-   movq   %rdx,___Argv
-   mov    %rdx,argv
+{$ifdef FPC_PIC}
+   movq   ___Argv@GOTPCREL(%rip),%rbx
+   movq   %rdx,(%rbx)
+{$else FPC_PIC}
+   movq   %rdx,___Argv{$ifdef FPC_HAS_RIP_RELATIVE}(%rip){$endif}
+{$endif FPC_PIC}
+{$ifdef FPC_PIC}
+   movq   argv@GOTPCREL(%rip),%rbx
+{$else FPC_PIC}
+   movq   $argv,%rbx
+{$endif FPC_PIC}
+   movq    %rdx,(%rbx)
    pushq   %rcx
    pushq   %rdx
    pushq   %rax
@@ -228,14 +265,14 @@ asm
    popq   %rsi
    popq   %rdx
    popq   %rcx
-   call   PASCALMAIN      { main(argc,argv,envp) }
+   call   PASCALMAIN{$ifdef FPC_PIC}@PLT{$endif}      { main(argc,argv,envp) }
    pushq  %rax
    pushq  %rax
    movq   %rax,%rdi	  { and call exit }
-   call   C_exit
+   call   C_exit{$ifdef FPC_PIC}@PLT{$endif}
    popq   %rdi
    popq   %rdi
-   call   _exit		  { if user redefined exit, call _exit }
+   call   _exit{$ifdef FPC_PIC}@PLT{$endif}	  { if user redefined exit, call _exit }
    hlt
 end;