mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2026-01-06 10:50:55 +01:00
+ patch by Sven Barth to add native NT rtl support to the compiler, resolves #14886
git-svn-id: trunk@14565 -
This commit is contained in:
parent
9896f48317
commit
34227e811d
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -522,6 +522,7 @@ compiler/systems/i_haiku.pas svneol=native#text/plain
|
||||
compiler/systems/i_linux.pas svneol=native#text/plain
|
||||
compiler/systems/i_macos.pas svneol=native#text/plain
|
||||
compiler/systems/i_morph.pas svneol=native#text/plain
|
||||
compiler/systems/i_nativent.pas svneol=native#text/pascal
|
||||
compiler/systems/i_nds.pas svneol=native#text/plain
|
||||
compiler/systems/i_nwl.pas svneol=native#text/plain
|
||||
compiler/systems/i_nwm.pas svneol=native#text/plain
|
||||
@ -545,6 +546,7 @@ compiler/systems/t_haiku.pas svneol=native#text/plain
|
||||
compiler/systems/t_linux.pas svneol=native#text/plain
|
||||
compiler/systems/t_macos.pas svneol=native#text/plain
|
||||
compiler/systems/t_morph.pas svneol=native#text/plain
|
||||
compiler/systems/t_nativent.pas svneol=native#text/pascal
|
||||
compiler/systems/t_nds.pas svneol=native#text/plain
|
||||
compiler/systems/t_nwl.pas svneol=native#text/plain
|
||||
compiler/systems/t_nwm.pas svneol=native#text/plain
|
||||
|
||||
@ -110,6 +110,9 @@ uses
|
||||
{$ifdef symbian}
|
||||
,i_symbian
|
||||
{$endif symbian}
|
||||
{$ifdef nativent}
|
||||
,i_nativent
|
||||
{$endif nativent}
|
||||
,globtype;
|
||||
|
||||
function Compile(const cmd:string):longint;
|
||||
|
||||
@ -77,6 +77,9 @@ implementation
|
||||
{$ifndef NOTARGETSYMBIAN}
|
||||
,t_symbian
|
||||
{$endif}
|
||||
{$ifndef NOTARGETNATIVENT}
|
||||
,t_nativent
|
||||
{$endif}
|
||||
|
||||
{**************************************
|
||||
Assemblers
|
||||
|
||||
@ -333,6 +333,7 @@ implementation
|
||||
COFF_STYP_DATA = $0040;
|
||||
COFF_STYP_BSS = $0080;
|
||||
|
||||
PE_SUBSYSTEM_NATIVE = 1;
|
||||
PE_SUBSYSTEM_WINDOWS_GUI = 2;
|
||||
PE_SUBSYSTEM_WINDOWS_CUI = 3;
|
||||
PE_SUBSYSTEM_WINDOWS_CE_GUI = 9;
|
||||
@ -2084,7 +2085,13 @@ const pemagic : array[0..3] of byte = (
|
||||
sechdr.nrelocs:=0;
|
||||
sechdr.relocpos:=0;
|
||||
if win32 then
|
||||
sechdr.flags:=peencodesechdrflags(SecOptions,SecAlign)
|
||||
begin
|
||||
if (target_info.system in systems_nativent) and
|
||||
(apptype = app_native) then
|
||||
sechdr.flags:=peencodesechdrflags(SecOptions,SecAlign) or PE_SCN_MEM_NOT_PAGED
|
||||
else
|
||||
sechdr.flags:=peencodesechdrflags(SecOptions,SecAlign);
|
||||
end
|
||||
else
|
||||
sechdr.flags:=djencodesechdrflags(SecOptions);
|
||||
FWriter.write(sechdr,sizeof(sechdr));
|
||||
@ -2302,13 +2309,18 @@ const pemagic : array[0..3] of byte = (
|
||||
peoptheader.SizeOfImage:=Align(CurrMemPos,SectionMemAlign);
|
||||
peoptheader.SizeOfHeaders:=textExeSec.DataPos;
|
||||
peoptheader.CheckSum:=0;
|
||||
if target_info.system in system_wince then
|
||||
peoptheader.Subsystem:=PE_SUBSYSTEM_WINDOWS_CE_GUI
|
||||
if (target_info.system in systems_nativent) and (not IsSharedLibrary or (apptype = app_native)) then
|
||||
{ Although I did not really test this, it seems that Subsystem is
|
||||
not checked in DLLs except for maybe drivers}
|
||||
peoptheader.Subsystem:=PE_SUBSYSTEM_NATIVE
|
||||
else
|
||||
if apptype=app_gui then
|
||||
peoptheader.Subsystem:=PE_SUBSYSTEM_WINDOWS_GUI
|
||||
if target_info.system in system_wince then
|
||||
peoptheader.Subsystem:=PE_SUBSYSTEM_WINDOWS_CE_GUI
|
||||
else
|
||||
peoptheader.Subsystem:=PE_SUBSYSTEM_WINDOWS_CUI;
|
||||
if apptype=app_gui then
|
||||
peoptheader.Subsystem:=PE_SUBSYSTEM_WINDOWS_GUI
|
||||
else
|
||||
peoptheader.Subsystem:=PE_SUBSYSTEM_WINDOWS_CUI;
|
||||
peoptheader.DllCharacteristics:=0;
|
||||
peoptheader.SizeOfStackReserve:=stacksize;
|
||||
peoptheader.SizeOfStackCommit:=$1000;
|
||||
@ -2906,7 +2918,7 @@ const pemagic : array[0..3] of byte = (
|
||||
idtxt : 'PECOFF';
|
||||
asmbin : '';
|
||||
asmcmd : '';
|
||||
supported_targets : [system_i386_win32];
|
||||
supported_targets : [system_i386_win32,system_i386_nativent];
|
||||
flags : [af_outputbinary,af_smartlink_sections];
|
||||
labelprefix : '.L';
|
||||
comment : '';
|
||||
|
||||
@ -2224,7 +2224,10 @@ begin
|
||||
system_arm_gba:
|
||||
target_unsup_features:=[f_threading,f_commandargs,f_fileio,f_textio,f_consoleio,f_dynlibs];
|
||||
system_arm_nds:
|
||||
target_unsup_features:=[f_threading,f_commandargs,f_fileio,f_textio,f_consoleio,f_dynlibs]
|
||||
target_unsup_features:=[f_threading,f_commandargs,f_fileio,f_textio,f_consoleio,f_dynlibs];
|
||||
system_i386_nativent:
|
||||
// until these features are implemented, they are disabled in the compiler
|
||||
target_unsup_features:=[f_threading,f_processes,f_fileio,f_textio,f_consoleio,f_commandargs,f_stackcheck];
|
||||
else
|
||||
target_unsup_features:=[];
|
||||
end;
|
||||
|
||||
@ -2372,7 +2372,7 @@ const
|
||||
*)
|
||||
if assigned(pd.import_name) then
|
||||
begin
|
||||
if target_info.system in (system_all_windows +
|
||||
if target_info.system in (system_all_windows + systems_nativent +
|
||||
[system_i386_emx, system_i386_os2]) then
|
||||
{ cprefix is not used in DLL imports under Windows or OS/2 }
|
||||
result:=pd.import_name^
|
||||
|
||||
@ -233,7 +233,7 @@ unit scandir;
|
||||
begin
|
||||
if not (target_info.system in system_all_windows + [system_i386_os2,
|
||||
system_i386_emx, system_powerpc_macos,
|
||||
system_arm_nds]) then
|
||||
system_arm_nds] + systems_nativent) then
|
||||
begin
|
||||
if m_delphi in current_settings.modeswitches then
|
||||
Message(scan_n_app_type_not_support)
|
||||
@ -252,7 +252,7 @@ unit scandir;
|
||||
apptype:=app_gui
|
||||
else if hs='CONSOLE' then
|
||||
apptype:=app_cui
|
||||
else if (hs='NATIVE') and (target_info.system in system_windows) then
|
||||
else if (hs='NATIVE') and (target_info.system in system_windows + systems_nativent) then
|
||||
apptype:=app_native
|
||||
else if (hs='FS') and (target_info.system in [system_i386_os2,
|
||||
system_i386_emx]) then
|
||||
|
||||
@ -149,7 +149,8 @@ interface
|
||||
system_arm_darwin, { 64 }
|
||||
system_x86_64_solaris, { 65 }
|
||||
system_mips_linux, { 66 }
|
||||
system_mipsel_linux { 67 }
|
||||
system_mipsel_linux, { 67 }
|
||||
system_i386_nativent { 68 }
|
||||
);
|
||||
|
||||
type
|
||||
@ -449,6 +450,9 @@ interface
|
||||
{ all symbian systems }
|
||||
systems_symbian = [system_i386_symbian,system_arm_symbian];
|
||||
|
||||
{ all native nt systems }
|
||||
systems_nativent = [system_i386_nativent];
|
||||
|
||||
{ all systems for which istack must be at a 16 byte boundary
|
||||
when calling a function }
|
||||
system_needs_16_byte_stack_alignment = [
|
||||
@ -457,7 +461,7 @@ interface
|
||||
system_x86_64_win64,
|
||||
system_x86_64_linux,
|
||||
system_x86_64_freebsd,
|
||||
system_x86_64_solaris];
|
||||
system_x86_64_solaris];
|
||||
|
||||
|
||||
cpu2str : array[TSystemCpu] of string[10] =
|
||||
|
||||
106
compiler/systems/i_nativent.pas
Normal file
106
compiler/systems/i_nativent.pas
Normal file
@ -0,0 +1,106 @@
|
||||
{
|
||||
Copyright (c) 2009 by Sven Barth
|
||||
|
||||
This unit implements support information structures for nativent
|
||||
Based on Peter Vreman's i_win
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
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. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
****************************************************************************
|
||||
}
|
||||
{ This unit implements support information structures for nativent. }
|
||||
unit i_nativent;
|
||||
|
||||
{$i fpcdefs.inc}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
systems;
|
||||
|
||||
const
|
||||
system_i386_nativent_info : tsysteminfo =
|
||||
(
|
||||
system : system_i386_NATIVENT;
|
||||
name : 'Native NT for i386';
|
||||
shortname : 'NativeNT';
|
||||
flags : [tf_files_case_aware,tf_use_function_relative_addresses,tf_smartlink_library
|
||||
,tf_smartlink_sections{,tf_section_threadvars}{,tf_needs_dwarf_cfi},
|
||||
tf_no_pic_supported,
|
||||
tf_no_generic_stackcheck{,tf_has_winlike_resources},tf_under_development,
|
||||
tf_dwarf_only_local_labels];
|
||||
cpu : cpu_i386;
|
||||
unit_env : 'NTUNITS';
|
||||
extradefines : 'NATIVENT,UNICODE';
|
||||
exeext : '.exe';
|
||||
defext : '.def';
|
||||
scriptext : '.bat';
|
||||
smartext : '.sl';
|
||||
unitext : '.ppu';
|
||||
unitlibext : '.ppl';
|
||||
asmext : '.s';
|
||||
objext : '.o';
|
||||
resext : '.res';
|
||||
resobjext : '.or';
|
||||
sharedlibext : '.dll';
|
||||
staticlibext : '.a';
|
||||
staticlibprefix : 'libp';
|
||||
sharedlibprefix : '';
|
||||
sharedClibext : '.dll';
|
||||
staticClibext : '.a';
|
||||
staticClibprefix : 'lib';
|
||||
sharedClibprefix : '';
|
||||
importlibprefix : 'libimp';
|
||||
importlibext : '.a';
|
||||
Cprefix : '_';
|
||||
newline : #13#10;
|
||||
dirsep : '\';
|
||||
assem : as_i386_pecoff;
|
||||
assemextern : as_gas;
|
||||
link : nil;
|
||||
linkextern : nil;
|
||||
ar : ar_gnu_ar;
|
||||
res : res_gnu_windres;
|
||||
dbg : dbg_stabs;
|
||||
script : script_dos;
|
||||
endian : endian_little;
|
||||
alignment :
|
||||
(
|
||||
procalign : 16;
|
||||
loopalign : 4;
|
||||
jumpalign : 0;
|
||||
constalignmin : 0;
|
||||
constalignmax : 16;
|
||||
varalignmin : 0;
|
||||
varalignmax : 16;
|
||||
localalignmin : 4;
|
||||
localalignmax : 8;
|
||||
recordalignmin : 0;
|
||||
recordalignmax : 4;
|
||||
maxCrecordalign : 16
|
||||
);
|
||||
first_parm_offset : 8;
|
||||
stacksize : 16*1024*1024;
|
||||
abi : abi_default;
|
||||
);
|
||||
|
||||
implementation
|
||||
|
||||
initialization
|
||||
{$ifdef CPU86}
|
||||
{$ifdef NATIVENT}
|
||||
set_source_info(system_i386_nativent_info);
|
||||
{$endif NATIVENT}
|
||||
{$endif CPU86}
|
||||
end.
|
||||
94
compiler/systems/t_nativent.pas
Normal file
94
compiler/systems/t_nativent.pas
Normal file
@ -0,0 +1,94 @@
|
||||
{
|
||||
Copyright (c) 2009 by Sven Barth
|
||||
|
||||
This unit implements support import,export,link routines
|
||||
for the Native NT Target
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
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. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
****************************************************************************
|
||||
}
|
||||
unit t_nativent;
|
||||
|
||||
{$i fpcdefs.inc}
|
||||
|
||||
interface
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
SysUtils,
|
||||
cutils,
|
||||
ogbase,ogcoff,
|
||||
globtype,globals,systems,verbose,
|
||||
import,export,link,t_win,i_nativent;
|
||||
|
||||
|
||||
type
|
||||
TImportLibNativeNT=class(TImportLibWin)
|
||||
end;
|
||||
|
||||
TExportLibNativeNT=class(TExportLibWin)
|
||||
end;
|
||||
|
||||
TInternalLinkerNativeNT = class(TInternalLinkerWin)
|
||||
constructor create;override;
|
||||
procedure ConcatEntryName; override;
|
||||
end;
|
||||
|
||||
{****************************************************************************
|
||||
TInternalLinkerNativeNT
|
||||
****************************************************************************}
|
||||
|
||||
constructor TInternalLinkerNativeNT.create;
|
||||
begin
|
||||
inherited create;
|
||||
CExeoutput:=TPECoffexeoutput;
|
||||
CObjInput:=TPECoffObjInput;
|
||||
end;
|
||||
|
||||
procedure TInternalLinkerNativeNT.ConcatEntryName;
|
||||
begin
|
||||
with LinkScript do
|
||||
begin
|
||||
if IsSharedLibrary then
|
||||
begin
|
||||
// for now we use {$apptype native} for kernel mode code
|
||||
if apptype=app_native then
|
||||
Concat('ENTRYNAME _NtDriverEntry')
|
||||
else
|
||||
Concat('ENTRYNAME _DLLMainStartup')
|
||||
end
|
||||
else
|
||||
Concat('ENTRYNAME _NtProcessStartup');
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
{*****************************************************************************
|
||||
Initialize
|
||||
*****************************************************************************}
|
||||
|
||||
initialization
|
||||
{$ifdef i386}
|
||||
{ NativeNT }
|
||||
RegisterInternalLinker(system_i386_nativent_info,TInternalLinkerNativeNT);
|
||||
RegisterImport(system_i386_nativent,TImportLibNativeNT);
|
||||
RegisterExport(system_i386_nativent,TExportLibNativeNT);
|
||||
// RegisterRes(res_gnu_windres_info,TWinLikeResourceFile);
|
||||
RegisterTarget(system_i386_nativent_info);
|
||||
{$endif i386}
|
||||
end.
|
||||
@ -68,6 +68,7 @@ interface
|
||||
constructor create;override;
|
||||
procedure DefaultLinkScript;override;
|
||||
procedure InitSysInitUnitName;override;
|
||||
procedure ConcatEntryName; virtual;
|
||||
end;
|
||||
|
||||
TExternalLinkerWin=class(texternallinker)
|
||||
@ -958,20 +959,8 @@ implementation
|
||||
Comment(V_Error,'Import library not found for '+S);
|
||||
end;
|
||||
if IsSharedLibrary then
|
||||
begin
|
||||
Concat('ISSHAREDLIBRARY');
|
||||
if apptype=app_gui then
|
||||
Concat('ENTRYNAME _DLLWinMainCRTStartup')
|
||||
else
|
||||
Concat('ENTRYNAME _DLLMainCRTStartup');
|
||||
end
|
||||
else
|
||||
begin
|
||||
if apptype=app_gui then
|
||||
Concat('ENTRYNAME _WinMainCRTStartup')
|
||||
else
|
||||
Concat('ENTRYNAME _mainCRTStartup');
|
||||
end;
|
||||
Concat('ISSHAREDLIBRARY');
|
||||
ConcatEntryName;
|
||||
if not ImageBaseSetExplicity then
|
||||
begin
|
||||
if IsSharedLibrary then
|
||||
@ -1062,6 +1051,28 @@ implementation
|
||||
GlobalInitSysInitUnitName(self);
|
||||
end;
|
||||
|
||||
procedure TInternalLinkerWin.ConcatEntryName;
|
||||
begin
|
||||
with LinkScript do
|
||||
begin
|
||||
if IsSharedLibrary then
|
||||
begin
|
||||
Concat('ISSHAREDLIBRARY');
|
||||
if apptype=app_gui then
|
||||
Concat('ENTRYNAME _DLLWinMainCRTStartup')
|
||||
else
|
||||
Concat('ENTRYNAME _DLLMainCRTStartup');
|
||||
end
|
||||
else
|
||||
begin
|
||||
if apptype=app_gui then
|
||||
Concat('ENTRYNAME _WinMainCRTStartup')
|
||||
else
|
||||
Concat('ENTRYNAME _mainCRTStartup');
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
{****************************************************************************
|
||||
TExternalLinkerWin
|
||||
|
||||
@ -339,7 +339,8 @@ interface
|
||||
asmcmd : '--32 -o $OBJ $ASM';
|
||||
supported_targets : [system_i386_GO32V2,system_i386_linux,system_i386_Win32,system_i386_freebsd,system_i386_solaris,system_i386_beos,
|
||||
system_i386_netbsd,system_i386_Netware,system_i386_qnx,system_i386_wdosx,system_i386_openbsd,
|
||||
system_i386_netwlibc,system_i386_wince,system_i386_embedded,system_i386_symbian,system_i386_haiku,system_x86_6432_linux];
|
||||
system_i386_netwlibc,system_i386_wince,system_i386_embedded,system_i386_symbian,system_i386_haiku,system_x86_6432_linux,
|
||||
system_i386_nativent];
|
||||
flags : [af_allowdirect,af_needar,af_smartlink_sections,af_supports_dwarf];
|
||||
labelprefix : '.L';
|
||||
comment : '# ';
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -966,6 +966,12 @@ SHAREDLIBEXT=.dll
|
||||
SHORTSUFFIX=symbian
|
||||
endif
|
||||
|
||||
# NativeNT
|
||||
ifeq ($(OS_TARGET),NativeNT)
|
||||
SHAREDLIBEXT=.dll
|
||||
SHORTSUFFIX=nativent
|
||||
endif
|
||||
|
||||
else
|
||||
# long version for 1.0.x - target specific extensions
|
||||
|
||||
|
||||
@ -70,7 +70,7 @@ interface
|
||||
o_linux,o_go32v2,o_win32,o_os2,o_freebsd,o_beos,o_haiku,o_netbsd,
|
||||
o_amiga,o_atari, o_solaris, o_qnx, o_netware, o_openbsd,o_wdosx,
|
||||
o_palmos,o_macos,o_darwin,o_emx,o_watcom,o_morphos,o_netwlibc,
|
||||
o_win64,o_wince,o_gba,o_nds,o_embedded,o_symbian
|
||||
o_win64,o_wince,o_gba,o_nds,o_embedded,o_symbian,o_nativent
|
||||
);
|
||||
|
||||
TTargetSet=array[tcpu,tos] of boolean;
|
||||
@ -92,14 +92,14 @@ interface
|
||||
'linux','go32v2','win32','os2','freebsd','beos','haiku','netbsd',
|
||||
'amiga','atari','solaris', 'qnx', 'netware','openbsd','wdosx',
|
||||
'palmos','macos','darwin','emx','watcom','morphos','netwlibc',
|
||||
'win64','wince','gba','nds','embedded','symbian'
|
||||
'win64','wince','gba','nds','embedded','symbian','nativent'
|
||||
);
|
||||
|
||||
OSSuffix : array[TOS] of string=(
|
||||
'_linux','_go32v2','_win32','_os2','_freebsd','_beos','_haiku','_netbsd',
|
||||
'_amiga','_atari','_solaris', '_qnx', '_netware','_openbsd','_wdosx',
|
||||
'_palmos','_macos','_darwin','_emx','_watcom','_morphos','_netwlibc',
|
||||
'_win64','_wince','_gba','_nds','_embedded','_symbian'
|
||||
'_win64','_wince','_gba','_nds','_embedded','_symbian','_nativent'
|
||||
);
|
||||
|
||||
{ This table is kept OS,Cpu because it is easier to maintain (PFV) }
|
||||
@ -132,7 +132,8 @@ interface
|
||||
{ gba } ( false, false, false, false, false, true, false, false, false, false, false, false, false, false),
|
||||
{ nds } ( false, false, false, false, false, true, false, false, false, false, false, false, false, false),
|
||||
{ embedded }( true, true, true, true, true, true, true, true, true , false, false, false, false, false),
|
||||
{ symbian } ( true, false, false, false, false, true, false, false, false, false, false, false, false, false)
|
||||
{ symbian } ( true, false, false, false, false, true, false, false, false, false, false, false, false, false),
|
||||
{ nativent }( true, false, false, false, false, false, false, false, false, false, false, false, false, false)
|
||||
);
|
||||
|
||||
type
|
||||
|
||||
Loading…
Reference in New Issue
Block a user