diff --git a/compiler/i386/cputarg.pas b/compiler/i386/cputarg.pas index f4c3254ec7..54e5f7982e 100644 --- a/compiler/i386/cputarg.pas +++ b/compiler/i386/cputarg.pas @@ -80,6 +80,9 @@ implementation {$ifndef NOTARGETNATIVENT} ,t_nativent {$endif} + {$ifndef NOTARGETEMBEDDED} + ,t_embed + {$endif} {************************************** Assemblers diff --git a/compiler/ogelf.pas b/compiler/ogelf.pas index ec0199e5a6..416cd4a95a 100644 --- a/compiler/ogelf.pas +++ b/compiler/ogelf.pas @@ -1229,7 +1229,7 @@ implementation asmbin : ''; asmcmd : ''; supported_targets : [system_i386_linux,system_i386_beos,system_i386_freebsd,system_i386_haiku,system_i386_Netware,system_i386_netwlibc, - system_i386_solaris]; + system_i386_solaris,system_i386_embedded]; flags : [af_outputbinary,af_smartlink_sections,af_supports_dwarf]; labelprefix : '.L'; comment : ''; diff --git a/compiler/systems/i_embed.pas b/compiler/systems/i_embed.pas index 6fcdae822e..e64b206f08 100644 --- a/compiler/systems/i_embed.pas +++ b/compiler/systems/i_embed.pas @@ -152,6 +152,68 @@ unit i_embed; abi : abi_default ); + system_i386_embedded_info : tsysteminfo = + ( + system : system_i386_embedded; + name : 'Embedded'; + shortname : 'embedded'; + flags : [tf_needs_symbol_size,tf_files_case_sensitive + ,tf_smartlink_sections]; + cpu : cpu_i386; + unit_env : ''; + extradefines : ''; + exeext : ''; + defext : '.def'; + scriptext : '.sh'; + smartext : '.sl'; + unitext : '.ppu'; + unitlibext : '.ppl'; + asmext : '.s'; + objext : '.o'; + resext : '.res'; + resobjext : '.or'; + sharedlibext : '.so'; + staticlibext : '.a'; + staticlibprefix : 'libp'; + sharedlibprefix : 'lib'; + sharedClibext : '.so'; + staticClibext : '.a'; + staticClibprefix : 'lib'; + sharedClibprefix : 'lib'; + importlibprefix : 'libimp'; + importlibext : '.a'; + Cprefix : ''; + newline : #10; + dirsep : '/'; + assem : as_i386_elf32; + assemextern : as_gas; + link : nil; + linkextern : nil; + ar : ar_gnu_ar; + res : res_none; + dbg : dbg_stabs; + script : script_unix; + endian : endian_little; + alignment : + ( + procalign : 16; + loopalign : 4; + jumpalign : 0; + constalignmin : 0; + constalignmax : 8; + varalignmin : 0; + varalignmax : 16; + localalignmin : 4; + localalignmax : 8; + recordalignmin : 0; + recordalignmax : 16; + maxCrecordalign : 4 + ); + first_parm_offset : 8; + stacksize : 4096; + abi : abi_default + ); + implementation initialization @@ -165,4 +227,9 @@ initialization set_source_info(system_avr_embedded_info); {$endif embedded} {$endif CPUAVR} +{$ifdef CPUI386} + {$ifdef embedded} + set_source_info(system_i386_embedded_info); + {$endif embedded} +{$endif CPUI386} end. diff --git a/compiler/systems/t_embed.pas b/compiler/systems/t_embed.pas index d411b4bf1e..c84540349a 100644 --- a/compiler/systems/t_embed.pas +++ b/compiler/systems/t_embed.pas @@ -82,11 +82,11 @@ Var begin WriteResponseFile:=False; linklibc:=(SharedLibFiles.Find('c')<>nil); -{$ifdef ARM} +{$if defined(ARM) or defined(i386)} prtobj:=''; -{$else ARM} +{$else} prtobj:='prt0'; -{$endif ARM} +{$endif} cprtobj:='cprt0'; if linklibc then prtobj:=cprtobj; @@ -293,6 +293,41 @@ begin Add('_end = .;'); end; {$endif ARM} +{$ifdef i386} + with linkres do + begin + Add('ENTRY(_START)'); + Add('SECTIONS'); + Add('{'); + Add(' . = 0x100000;'); + Add(' .text ALIGN (0x1000) :'); + Add(' {'); + Add(' KEEP(*(.init, .init.*))'); + Add(' *(.text, .text.*)'); + Add(' *(.strings)'); + Add(' *(.rodata, .rodata.*)'); + Add(' *(.comment)'); + Add(' _etext = .;'); + Add(' }'); + Add(' .data ALIGN (0x1000) :'); + Add(' {'); + Add(' _data = .;'); + Add(' *(.data, .data.*)'); + Add(' KEEP (*(.fpc .fpc.n_version .fpc.n_links))'); + Add(' _edata = .;'); + Add(' }'); + Add(' . = ALIGN(4);'); + Add(' .bss :'); + Add(' {'); + Add(' _bss_start = .;'); + Add(' *(.bss, .bss.*)'); + Add(' *(COMMON)'); + Add(' }'); + Add('_bss_end = . ;'); + Add('}'); + Add('_end = .;'); + end; +{$endif I386} { Write and Close response } linkres.writetodisk; @@ -354,7 +389,7 @@ begin DeleteFile(outputexedir+Info.ResName); { Post process } - if success then + if success and (target_info.system=system_arm_embedded) then begin success:=DoExec(FindUtil(utilsprefix+'objcopy'),'-O ihex '+ ChangeFileExt(current_module.exefilename^,'.elf')+' '+ @@ -379,4 +414,9 @@ initialization RegisterExternalLinker(system_avr_embedded_info,TlinkerEmbedded); RegisterTarget(system_avr_embedded_info); {$endif avr} + +{$ifdef i386} + RegisterExternalLinker(system_i386_embedded_info,TlinkerEmbedded); + RegisterTarget(system_i386_embedded_info); +{$endif i386} end. diff --git a/rtl/embedded/Makefile b/rtl/embedded/Makefile index 70fc81e897..1acdbe2778 100644 --- a/rtl/embedded/Makefile +++ b/rtl/embedded/Makefile @@ -1,5 +1,5 @@ # -# Don't edit, this file is generated by FPCMake Version 2.0.0 [2010/09/29] +# Don't edit, this file is generated by FPCMake Version 2.0.0 [2011/01/11] # 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 i386-nativent i386-iphonesim 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 @@ -282,6 +282,9 @@ SYSINIT_UNITS= ifeq ($(ARCH),arm) CPU_UNITS=lpc21x4 at91sam7x256 stellaris stm32f103 endif +ifeq ($(ARCH),i386) +CPU_UNITS=multiboot +endif OBJPASDIR=$(RTL)/objpas GRAPHDIR=$(INC)/graph ifeq ($(FULL_TARGET),i386-linux) diff --git a/rtl/embedded/Makefile.fpc b/rtl/embedded/Makefile.fpc index 98c0fe9d37..341c5eed9b 100644 --- a/rtl/embedded/Makefile.fpc +++ b/rtl/embedded/Makefile.fpc @@ -51,6 +51,10 @@ ifeq ($(ARCH),arm) CPU_UNITS=lpc21x4 at91sam7x256 stellaris stm32f103 endif +ifeq ($(ARCH),i386) +CPU_UNITS=multiboot +endif + # Paths OBJPASDIR=$(RTL)/objpas GRAPHDIR=$(INC)/graph