mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-14 19:39:31 +02:00
+ x86_64 processor specific solaris files
git-svn-id: trunk@14235 -
This commit is contained in:
parent
af85e45b67
commit
2480a6bad1
3
.gitattributes
vendored
3
.gitattributes
vendored
@ -7092,6 +7092,9 @@ rtl/solaris/termiosproc.inc svneol=native#text/plain
|
||||
rtl/solaris/unxconst.inc svneol=native#text/plain
|
||||
rtl/solaris/unxfunc.inc svneol=native#text/plain
|
||||
rtl/solaris/unxsockh.inc svneol=native#text/plain
|
||||
rtl/solaris/x86_64/sighnd.inc svneol=native#text/plain
|
||||
rtl/solaris/x86_64/sighndh.inc svneol=native#text/plain
|
||||
rtl/solaris/x86_64/start.inc svneol=native#text/plain
|
||||
rtl/sparc/int64p.inc svneol=native#text/plain
|
||||
rtl/sparc/makefile.cpu svneol=native#text/plain
|
||||
rtl/sparc/math.inc svneol=native#text/plain
|
||||
|
@ -1,8 +1,8 @@
|
||||
#
|
||||
# Don't edit, this file is generated by FPCMake Version 2.0.0 [2009/11/12]
|
||||
# Don't edit, this file is generated by FPCMake Version 2.0.0 [2009/11/17]
|
||||
#
|
||||
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-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
|
||||
BSDs = freebsd netbsd openbsd darwin
|
||||
UNIXs = linux $(BSDs) solaris qnx haiku
|
||||
LIMIT83fs = go32v2 os2 emx watcom
|
||||
@ -411,6 +411,9 @@ endif
|
||||
ifeq ($(FULL_TARGET),x86_64-freebsd)
|
||||
override TARGET_UNITS+=$(SYSTEMUNIT) unixtype ctypes strings objpas macpas heaptrc lineinfo lnfodwrf baseunix unixutil termio unix initc cmem crt printer sysutils typinfo math fgl classes matrix varutils charset ucomplex getopts errors sockets terminfo dl dynlibs video mouse keyboard variants types dateutils sysconst strutils fmtbcd rtlconsts cthreads dos objects cwstring fpintres $(CPU_UNITS)
|
||||
endif
|
||||
ifeq ($(FULL_TARGET),x86_64-solaris)
|
||||
override TARGET_UNITS+=$(SYSTEMUNIT) unixtype ctypes strings objpas macpas heaptrc lineinfo lnfodwrf baseunix unixutil termio unix initc cmem crt printer sysutils typinfo math fgl classes matrix varutils charset ucomplex getopts errors sockets terminfo dl dynlibs video mouse keyboard variants types dateutils sysconst strutils fmtbcd rtlconsts cthreads dos objects cwstring fpintres $(CPU_UNITS)
|
||||
endif
|
||||
ifeq ($(FULL_TARGET),x86_64-darwin)
|
||||
override TARGET_UNITS+=$(SYSTEMUNIT) unixtype ctypes strings objpas macpas heaptrc lineinfo lnfodwrf baseunix unixutil termio unix initc cmem crt printer sysutils typinfo math fgl classes matrix varutils charset ucomplex getopts errors sockets terminfo dl dynlibs video mouse keyboard variants types dateutils sysconst strutils fmtbcd rtlconsts cthreads dos objects cwstring fpintres $(CPU_UNITS)
|
||||
endif
|
||||
@ -585,6 +588,9 @@ endif
|
||||
ifeq ($(FULL_TARGET),x86_64-freebsd)
|
||||
override TARGET_IMPLICITUNITS+=exeinfo
|
||||
endif
|
||||
ifeq ($(FULL_TARGET),x86_64-solaris)
|
||||
override TARGET_IMPLICITUNITS+=exeinfo
|
||||
endif
|
||||
ifeq ($(FULL_TARGET),x86_64-darwin)
|
||||
override TARGET_IMPLICITUNITS+=exeinfo
|
||||
endif
|
||||
@ -759,6 +765,9 @@ endif
|
||||
ifeq ($(FULL_TARGET),x86_64-freebsd)
|
||||
override TARGET_RSTS+=math varutils typinfo classes variants dateutils sysconst rtlconst
|
||||
endif
|
||||
ifeq ($(FULL_TARGET),x86_64-solaris)
|
||||
override TARGET_RSTS+=math varutils typinfo classes variants dateutils sysconst rtlconst
|
||||
endif
|
||||
ifeq ($(FULL_TARGET),x86_64-darwin)
|
||||
override TARGET_RSTS+=math varutils typinfo classes variants dateutils sysconst rtlconst
|
||||
endif
|
||||
@ -934,6 +943,9 @@ endif
|
||||
ifeq ($(FULL_TARGET),x86_64-freebsd)
|
||||
override COMPILER_INCLUDEDIR+=$(INC) $(PROCINC) $(UNIXINC) $(OSPROCINC)
|
||||
endif
|
||||
ifeq ($(FULL_TARGET),x86_64-solaris)
|
||||
override COMPILER_INCLUDEDIR+=$(INC) $(PROCINC) $(UNIXINC) $(OSPROCINC)
|
||||
endif
|
||||
ifeq ($(FULL_TARGET),x86_64-darwin)
|
||||
override COMPILER_INCLUDEDIR+=$(INC) $(PROCINC) $(UNIXINC) $(OSPROCINC)
|
||||
endif
|
||||
@ -1108,6 +1120,9 @@ endif
|
||||
ifeq ($(FULL_TARGET),x86_64-freebsd)
|
||||
override COMPILER_SOURCEDIR+=$(INC) $(PROCINC) $(UNIXINC) $(COMMON)
|
||||
endif
|
||||
ifeq ($(FULL_TARGET),x86_64-solaris)
|
||||
override COMPILER_SOURCEDIR+=$(INC) $(PROCINC) $(UNIXINC) $(COMMON)
|
||||
endif
|
||||
ifeq ($(FULL_TARGET),x86_64-darwin)
|
||||
override COMPILER_SOURCEDIR+=$(INC) $(PROCINC) $(UNIXINC) $(COMMON)
|
||||
endif
|
||||
|
84
rtl/solaris/x86_64/sighnd.inc
Normal file
84
rtl/solaris/x86_64/sighnd.inc
Normal file
@ -0,0 +1,84 @@
|
||||
{
|
||||
This file is part of the Free Pascal run time library.
|
||||
Copyright (c) 1999-2000 by Michael Van Canneyt,
|
||||
member of the Free Pascal development team.
|
||||
|
||||
Signal handler is arch dependant due to processor to language
|
||||
exception conversion.
|
||||
|
||||
See the file COPYING.FPC, included in this distribution,
|
||||
for details about the copyright.
|
||||
|
||||
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.
|
||||
|
||||
**********************************************************************}
|
||||
|
||||
const
|
||||
FPE_INTDIV = 1;
|
||||
FPE_INTOVF = 2;
|
||||
FPE_FLTDIV = 3;
|
||||
FPE_FLTOVF = 4;
|
||||
FPE_FLTUND = 5;
|
||||
FPE_FLTRES = 6;
|
||||
FPE_FLTINV = 7;
|
||||
FPE_FLTSUB = 8;
|
||||
|
||||
|
||||
procedure SignalToRunerror(sig : longint; SigInfo: PSigInfo; SigContext: PSigContext);public name '_FPC_DEFAULTSIGHANDLER';cdecl;
|
||||
var
|
||||
res : word;
|
||||
addr : pointer;
|
||||
frame : pointer;
|
||||
begin
|
||||
res:=0;
|
||||
if assigned(sigcontext) then
|
||||
begin
|
||||
addr := pointer(sigcontext^.uc_mcontext.gregs[REG_PC]);
|
||||
frame := pointer(sigcontext^.uc_mcontext.gregs[REG_FP])
|
||||
end
|
||||
else
|
||||
begin
|
||||
addr := nil;
|
||||
frame := nil;
|
||||
end;
|
||||
case sig of
|
||||
SIGFPE :
|
||||
begin
|
||||
case siginfo^.si_code of
|
||||
FPE_INTDIV:
|
||||
res:=200;
|
||||
FPE_INTOVF:
|
||||
res:=205;
|
||||
FPE_FLTDIV:
|
||||
res:=200;
|
||||
FPE_FLTOVF:
|
||||
res:=205;
|
||||
FPE_FLTUND:
|
||||
res:=206;
|
||||
else
|
||||
res:=207;
|
||||
end;
|
||||
end;
|
||||
SIGILL,
|
||||
SIGSEGV :
|
||||
begin
|
||||
res:=216;
|
||||
end;
|
||||
SIGBUS :
|
||||
begin
|
||||
res:=214;
|
||||
end;
|
||||
SIGINT:
|
||||
res:=217;
|
||||
SIGQUIT:
|
||||
res:=233;
|
||||
end;
|
||||
reenable_signal(sig);
|
||||
{ give runtime error at the position where the signal was raised }
|
||||
if res<>0 then
|
||||
HandleErrorAddrFrame(res,addr,frame);
|
||||
end;
|
||||
|
||||
|
251
rtl/solaris/x86_64/sighndh.inc
Normal file
251
rtl/solaris/x86_64/sighndh.inc
Normal file
@ -0,0 +1,251 @@
|
||||
{
|
||||
This file is part of the Free Pascal run time library.
|
||||
Copyright (c) 2009 by Pierre Muller,
|
||||
member of the Free Pascal development team.
|
||||
|
||||
Sigcontext and Sigaction for amd64/i386 CPUs
|
||||
|
||||
Adapted from
|
||||
http://cvs.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/uts/intel/sys/regset.h
|
||||
|
||||
See the file COPYING.FPC, included in this distribution,
|
||||
for details about the copyright.
|
||||
|
||||
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.
|
||||
|
||||
**********************************************************************}
|
||||
|
||||
{$packrecords C}
|
||||
|
||||
{$packrecords C}
|
||||
|
||||
const
|
||||
{ i386/amd64 definition }
|
||||
|
||||
{
|
||||
#if defined(__amd64)
|
||||
#define _NGREG 28
|
||||
#else
|
||||
#define _NGREG 19
|
||||
#endif
|
||||
}
|
||||
{$ifdef x86_64 }
|
||||
_NGREG = 28;
|
||||
{$else i386 }
|
||||
_NGREG = 19;
|
||||
{$endif i386 }
|
||||
_NGREG32 = 19;
|
||||
_NGREG64 = 28;
|
||||
|
||||
{$ifdef x86_64}
|
||||
(* AMD64 layout
|
||||
#define REG_GSBASE 27
|
||||
#define REG_FSBASE 26
|
||||
#define REG_DS 25
|
||||
#define REG_ES 24
|
||||
|
||||
#define REG_GS 23
|
||||
#define REG_FS 22
|
||||
#define REG_SS 21
|
||||
#define REG_RSP 20
|
||||
#define REG_RFL 19
|
||||
#define REG_CS 18
|
||||
#define REG_RIP 17
|
||||
#define REG_ERR 16
|
||||
#define REG_TRAPNO 15
|
||||
#define REG_RAX 14
|
||||
#define REG_RCX 13
|
||||
#define REG_RDX 12
|
||||
#define REG_RBX 11
|
||||
#define REG_RBP 10
|
||||
#define REG_RSI 9
|
||||
#define REG_RDI 8
|
||||
#define REG_R8 7
|
||||
#define REG_R9 6
|
||||
#define REG_R10 5
|
||||
#define REG_R11 4
|
||||
#define REG_R12 3
|
||||
#define REG_R13 2
|
||||
#define REG_R14 1
|
||||
#define REG_R15 0
|
||||
*)
|
||||
REG_R15 = 0;
|
||||
REG_R14 = 1;
|
||||
REG_R13 = 2;
|
||||
REG_R12 = 3;
|
||||
REG_R11 = 4;
|
||||
REG_R10 = 5;
|
||||
REG_R9 = 6;
|
||||
REG_R8 = 7;
|
||||
REG_RDI = 8;
|
||||
REG_RSI = 9;
|
||||
REG_RBP = 10;
|
||||
REG_RBX = 11;
|
||||
REG_RDX = 12;
|
||||
REG_RCX = 13;
|
||||
REG_RAX = 14;
|
||||
REG_TRAPNO = 15;
|
||||
REG_ERR = 16;
|
||||
REG_RIP = 17;
|
||||
REG_CS = 18;
|
||||
REG_RFL = 19;
|
||||
REG_RSP = 20;
|
||||
REG_SS = 21;
|
||||
REG_FS = 22;
|
||||
REG_GS = 23;
|
||||
REG_ES = 24;
|
||||
REG_DS = 25;
|
||||
REG_FSBASE = 26;
|
||||
REG_GSBASE = 27;
|
||||
|
||||
{$else i386}
|
||||
(* I386 layout
|
||||
#define SS 18 /* only stored on a privilege transition */
|
||||
#define UESP 17 /* only stored on a privilege transition */
|
||||
#define EFL 16
|
||||
#define CS 15
|
||||
#define EIP 14
|
||||
#define ERR 13
|
||||
#define TRAPNO 12
|
||||
#define EAX 11
|
||||
#define ECX 10
|
||||
#define EDX 9
|
||||
#define EBX 8
|
||||
#define ESP 7
|
||||
#define EBP 6
|
||||
#define ESI 5
|
||||
#define EDI 4
|
||||
#define DS 3
|
||||
#define ES 2
|
||||
#define FS 1
|
||||
#define GS 0
|
||||
*)
|
||||
REG_GS = 0;
|
||||
REG_FS = 1;
|
||||
REG_ES = 2;
|
||||
REG_DS = 3;
|
||||
REG_EDI = 4;
|
||||
REG_ESI = 5;
|
||||
REG_EBP = 6;
|
||||
REG_ESP = 7;
|
||||
REG_EBX = 8;
|
||||
REG_EDX = 9;
|
||||
REG_ECX = 10;
|
||||
REG_EAX = 11;
|
||||
REG_TRAPNO = 12;
|
||||
REG_ERR = 13;
|
||||
REG_EIP = 14;
|
||||
REG_CS = 15;
|
||||
REG_EFL = 16;
|
||||
REG_UESP = 17; (* only stored on a privilege transition *)
|
||||
REG_SS = 18; (* only stored on a privilege transition *)
|
||||
{$endif i386}
|
||||
|
||||
|
||||
{$ifdef x86_64 }
|
||||
REG_PC = REG_RIP;
|
||||
REG_FP = REG_RBP;
|
||||
REG_SP = REG_RSP;
|
||||
REG_PS = REG_RFL;
|
||||
REG_R0 = REG_RAX;
|
||||
REG_R1 = REG_RDX;
|
||||
{$else /* __i386 */ }
|
||||
REG_PC = REG_EIP;
|
||||
REG_FP = REG_EBP;
|
||||
REG_SP = REG_UESP;
|
||||
REG_PS = REG_EFL;
|
||||
REG_R0 = REG_EAX;
|
||||
REG_R1 = REG_EDX;
|
||||
{$endif }
|
||||
|
||||
type
|
||||
{$ifdef x86_64}
|
||||
TGReg = cint64;
|
||||
{$else}
|
||||
TGReg = cint32;
|
||||
{$endif}
|
||||
TGReg32 = cint32;
|
||||
TGReg64 = cint64;
|
||||
|
||||
TGRegSet = array[0.._NGREG-1] of TGReg;
|
||||
TGRegSet32 = array[0.._NGREG32-1] of TGReg32;
|
||||
TGRegSet64 = array[0.._NGREG64-1] of TGReg64;
|
||||
|
||||
|
||||
|
||||
type
|
||||
FPU_SAVE_TYPE = (fnsave_type, fxsave_type);
|
||||
|
||||
TFPURegs = record
|
||||
case longint of
|
||||
0: ( fpuregs: array[0..31] of cardinal);
|
||||
1: ( fpudregs: array[0..15] of double);
|
||||
end;
|
||||
|
||||
PFQ = ^TFQ;
|
||||
TFQ = record
|
||||
fpq_addr : ^cuint;
|
||||
fpq_instr : cuint;
|
||||
end;
|
||||
|
||||
(* struct fpchip_state {
|
||||
uint32_t state[27]; /* 287/387 saved state */
|
||||
uint32_t status; /* saved at exception */
|
||||
uint32_t mxcsr; /* SSE control and status */
|
||||
uint32_t xstatus; /* SSE mxcsr at exception */
|
||||
uint32_t __pad[2]; /* align to 128-bits */
|
||||
upad128_t xmm[8]; /* %xmm0-%xmm7 */
|
||||
} fpchip_state;
|
||||
*)
|
||||
TUpad128 = record
|
||||
case longint of
|
||||
0: (_q : extended;);
|
||||
1: (_l : array [0..4-1] of cuint32;);
|
||||
end;
|
||||
|
||||
TFPChip_State = record
|
||||
state : array [0..27-1] of cuint32;
|
||||
status : cuint32;
|
||||
mxcsr : cuint32;
|
||||
xstatus : cuint32;
|
||||
__pad : array [0..1] of cuint32;
|
||||
xmm : array [0..8-1] of TUpad128;
|
||||
end;
|
||||
|
||||
TFP_emul_space = record
|
||||
fp_emul : array [0..248-1] of cuint8;
|
||||
fp_epad : array [0..1] of cuint8;
|
||||
end;
|
||||
|
||||
TFPU = record
|
||||
case longint of
|
||||
0: (fpchip_state : TFPChip_state;);
|
||||
1: (fp_emul_space : TFP_emul_space;);
|
||||
2: (f_fpregs : Array[0..130-1] of cuint32;);
|
||||
end;
|
||||
|
||||
TFPRegSet = TFPU;
|
||||
|
||||
TMContext = record
|
||||
gregs : TGRegSet;
|
||||
fpregs : TFPRegSet;
|
||||
end;
|
||||
|
||||
TStack = record
|
||||
ss_sp : pointer;
|
||||
ss_size : size_t;
|
||||
ss_flags : cint;
|
||||
end;
|
||||
|
||||
PSigContext = ^TSigContext;
|
||||
TSigContext = record
|
||||
uc_flags : cuint;
|
||||
uc_link : PSigContext;
|
||||
uc_sigmask : sigset_t;
|
||||
uc_stack : TStack;
|
||||
uc_mcontext : TMContext;
|
||||
__uc_filler : array[0..5-1] of clong;
|
||||
end;
|
||||
|
254
rtl/solaris/x86_64/start.inc
Normal file
254
rtl/solaris/x86_64/start.inc
Normal file
@ -0,0 +1,254 @@
|
||||
{
|
||||
This file is part of the Free Pascal run time library.
|
||||
Copyright (c) 2009 by Pierre Muller,
|
||||
member of the Free Pascal development team.
|
||||
|
||||
Program startup
|
||||
Adapted from source code on opensolaris 2.11
|
||||
|
||||
See the file COPYING.FPC, included in this distribution,
|
||||
for details about the copyright.
|
||||
|
||||
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.
|
||||
|
||||
**********************************************************************}
|
||||
|
||||
(*
|
||||
/*
|
||||
* CDDL HEADER START
|
||||
*
|
||||
* The contents of this file are subject to the terms of the
|
||||
* Common Development and Distribution License (the "License").
|
||||
* You may not use this file except in compliance with the License.
|
||||
*
|
||||
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
||||
* or http://www.opensolaris.org/os/licensing.
|
||||
* See the License for the specific language governing permissions
|
||||
* and limitations under the License.
|
||||
*
|
||||
* When distributing Covered Code, include this CDDL HEADER in each
|
||||
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
||||
* If applicable, add the following below this CDDL HEADER, with the
|
||||
* fields enclosed by brackets "[]" replaced with your own identifying
|
||||
* information: Portions Copyright [yyyy] [name of copyright owner]
|
||||
*
|
||||
* CDDL HEADER END
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
*)
|
||||
|
||||
(*
|
||||
/*
|
||||
* This crt1.o module is provided as the bare minimum required to build
|
||||
* a 64-bit executable with gcc. It is installed in /usr/lib/amd64
|
||||
* where it will be picked up by gcc, along with crti.o and crtn.o
|
||||
*/
|
||||
|
||||
.ident "%Z%%M% %I% %E% SMI"
|
||||
|
||||
.file "crt1.s"
|
||||
|
||||
.globl _start
|
||||
|
||||
/* global entities defined elsewhere but used here */
|
||||
.globl main
|
||||
.globl __fpstart
|
||||
.globl exit
|
||||
.globl _exit
|
||||
.weak _DYNAMIC
|
||||
*)
|
||||
type
|
||||
TCdeclProcedure = procedure; cdecl;
|
||||
function atexit(proc:TCdeclProcedure):longint;cdecl;external 'c' name 'atexit'{ @plt };
|
||||
procedure C_exit;cdecl;external 'c' name 'exit';
|
||||
procedure _exit;cdecl;external 'c' name '_exit';
|
||||
//procedure _fini;cdecl;external 'c' name '_fini';
|
||||
//procedure __fpstart;cdecl;external 'c' name '__fpstart'{ @plt };
|
||||
//procedure __fsr;cdecl;external 'c' name '__fsr';
|
||||
//procedure _init;cdecl;external 'c' name '_init';
|
||||
procedure PascalMain;cdecl;external name 'PASCALMAIN';
|
||||
|
||||
|
||||
{vars are not correctly transformed :(
|
||||
var
|
||||
_DYNAMIC : longint; cvar; external;
|
||||
__Argv : pointer; cvar; external;
|
||||
environ : pointer; cvar; external;
|
||||
__get_exit_frame_monitor_ptr : pointer; cvar; external;
|
||||
__do_exit_code_ptr : pointer; cvar; external;
|
||||
}
|
||||
|
||||
(*
|
||||
.section .data
|
||||
|
||||
.weak environ
|
||||
.set environ,_environ
|
||||
.globl _environ
|
||||
.type _environ,@object
|
||||
.size _environ,8
|
||||
.align 8
|
||||
_environ:
|
||||
.8byte 0x0
|
||||
|
||||
.globl __environ_lock
|
||||
.type __environ_lock,@object
|
||||
.size __environ_lock,24
|
||||
.align 8
|
||||
__environ_lock:
|
||||
.zero 24
|
||||
|
||||
.globl ___Argv
|
||||
.type ___Argv,@object
|
||||
.size ___Argv,8
|
||||
.align 8
|
||||
___Argv:
|
||||
.8byte 0x0
|
||||
|
||||
|
||||
.globl __longdouble_used
|
||||
.section .data
|
||||
.align 8
|
||||
.type __longdouble_used,@object
|
||||
.size __longdouble_used,4
|
||||
__longdouble_used:
|
||||
.4byte 0
|
||||
|
||||
*)
|
||||
var
|
||||
_environ : pointer; cvar;
|
||||
__environ_lock : Array[0..24-1] of byte; cvar;
|
||||
___Argv : pointer;cvar;
|
||||
__longdouble_used : longint; cvar;
|
||||
|
||||
procedure _DYNAMIC;cdecl;external 'c' name '_DYNAMIC'; { should be weak }
|
||||
|
||||
(*
|
||||
/*
|
||||
* The SVR4/i386 ABI (pages 3-29) says that when the entry
|
||||
* point runs registers' %rbp, %rsp, %rdx values are specified
|
||||
* the following:
|
||||
*
|
||||
* %rbp The content of this register is unspecified at
|
||||
* process initialization time, but the user code should mark
|
||||
* the deepest stack frame by setting the frame pointer to zero.
|
||||
* No other frame's %ebp should have a zero value.
|
||||
*
|
||||
* %rsp Performing its usual job, the stack pointer holds the address
|
||||
* of the bottom of the stack, which is guaranteed to be
|
||||
* quadword aligned.
|
||||
*
|
||||
* The stack contains the arguments and environment:
|
||||
* ...
|
||||
* envp[0] (16+(8*argc))(%rsp)
|
||||
* NULL (8+(8*argc))(%rsp)
|
||||
* ...
|
||||
* argv[0] 8(%rsp)
|
||||
* argc 0(%rsp)
|
||||
*
|
||||
* %rdx In a conforming program, this register contains a function
|
||||
* pointer that the application should register with atexit(BA_OS).
|
||||
* This function is used for shared object termination code
|
||||
* [see Dynamic Linking in Chapter 5 of the System V ABI].
|
||||
*
|
||||
*/
|
||||
*)
|
||||
procedure _start;assembler;nostackframe;public name '_start';
|
||||
asm
|
||||
(*
|
||||
/*
|
||||
* Allocate a NULL return address and a NULL previous %rbp as if
|
||||
* there was a genuine call to _start.
|
||||
*/
|
||||
*)
|
||||
pushq $0x0
|
||||
pushq $0x0
|
||||
movq %rsp,%rbp
|
||||
(*
|
||||
/*
|
||||
* The stack now is
|
||||
*
|
||||
* envp[0] (32+(8*argc))(%rsp) - (A)
|
||||
* NULL (24+(8*argc))(%rsp)
|
||||
* ...
|
||||
* argv[0] 24(%rbp) - (B)
|
||||
* argc 16(%rbp)
|
||||
* 0 8(%rbp)
|
||||
* 0 0(%rbp)
|
||||
*/
|
||||
*)
|
||||
movq $_DYNAMIC,%rax
|
||||
testq %rax,%rax
|
||||
je .Label1
|
||||
movq %rdx,%rdi { register rt_do_exit }
|
||||
call atexit
|
||||
.Label1:
|
||||
(* What should we do about this?
|
||||
movq $_fini,%rdi
|
||||
call atexit *)
|
||||
(*
|
||||
/*
|
||||
* Calculate the location of the envp array by adding the size of
|
||||
* the argv array to the start of the argv array.
|
||||
*/
|
||||
*)
|
||||
movq 0x16(%rbp),%rax
|
||||
movq %rax,argc
|
||||
movq _environ,%rcx
|
||||
testq %rcx,%rcx
|
||||
jne .Label3
|
||||
lea 0x20(%rbp,%rax,8),%rcx
|
||||
.Label3:
|
||||
movl %rcx,_environ
|
||||
// Specificc to Free Pascal
|
||||
movl %rcx,envp
|
||||
(*
|
||||
/*
|
||||
* Force stack alignment - below here there must have been an even
|
||||
* number of un-popped pushq instructions whenever a call is reached
|
||||
*/
|
||||
*)
|
||||
andq $-16,%rsp
|
||||
pushq %rdx
|
||||
leaq 24(%rbp),%rdx { argv (B) }
|
||||
movq %rdx,___Argv
|
||||
mov %rdx,argv
|
||||
pushq %rcx
|
||||
pushq %rdx
|
||||
pushq %rax
|
||||
(* Should this be done, and where?
|
||||
call __fpstart
|
||||
call _init *)
|
||||
popq %rdi
|
||||
popq %rsi
|
||||
popq %rdx
|
||||
popq %rcx
|
||||
call PASCALMAIN { main(argc,argv,envp) }
|
||||
pushq %rax
|
||||
pushq %rax
|
||||
movq %rax,%rdi { and call exit }
|
||||
call C_exit
|
||||
popq %rdi
|
||||
popq %rdi
|
||||
call _exit { if user redefined exit, call _exit }
|
||||
hlt
|
||||
end;
|
||||
|
||||
(*
|
||||
/*
|
||||
* The following is here in case any object module compiled with cc -p
|
||||
* was linked into this module.
|
||||
*/
|
||||
.globl _mcount
|
||||
.section .text
|
||||
.align 8
|
||||
.type _mcount,@function
|
||||
_mcount:
|
||||
ret
|
||||
.size _mcount, .-_mcount
|
||||
*)
|
Loading…
Reference in New Issue
Block a user