diff options
author | nickysn <nickysn@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2021-04-27 23:11:09 +0000 |
---|---|---|
committer | nickysn <nickysn@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2021-04-27 23:11:09 +0000 |
commit | a491c935588745154b576226b73833bac78fcb6e (patch) | |
tree | 973289073fb5d21573a6be2b5cfeba9abd2a9472 /compiler/systems | |
parent | 38b5e0606069cc5985e995e1da5b6855db67f507 (diff) | |
parent | ae5b0de491a91321675f73eae5db628d068f4e05 (diff) | |
download | fpc-unicodekvm.tar.gz |
* synchronized with trunkunicodekvm
git-svn-id: https://svn.freepascal.org/svn/fpc/branches/unicodekvm@49282 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'compiler/systems')
-rw-r--r-- | compiler/systems/t_bsd.pas | 6 | ||||
-rw-r--r-- | compiler/systems/t_freertos.pas | 19 | ||||
-rw-r--r-- | compiler/systems/t_nds.pas | 2 | ||||
-rw-r--r-- | compiler/systems/t_sinclairql.pas | 19 |
4 files changed, 38 insertions, 8 deletions
diff --git a/compiler/systems/t_bsd.pas b/compiler/systems/t_bsd.pas index 915e57be82..99a4b8ca97 100644 --- a/compiler/systems/t_bsd.pas +++ b/compiler/systems/t_bsd.pas @@ -482,12 +482,14 @@ begin (tf_smartlink_sections in target_info.flags) then GCSectionsStr:='--gc-sections'; - if(cs_profile in current_settings.moduleswitches) or + if (cs_profile in current_settings.moduleswitches) or ((Info.DynamicLinker<>'') and ((not SharedLibFiles.Empty) or (target_info.system in systems_openbsd))) then - DynLinkStr:='-dynamic-linker='+Info.DynamicLinker; + DynLinkStr:='-dynamic-linker='+Info.DynamicLinker; + if rlinkpath<>'' then + DynLinkStr:=DynLinkStr+' --rpath-link '+rlinkpath; if CShared Then begin DynLinKStr:=DynLinkStr+' --shared' diff --git a/compiler/systems/t_freertos.pas b/compiler/systems/t_freertos.pas index 027d29f15c..2c815cfbed 100644 --- a/compiler/systems/t_freertos.pas +++ b/compiler/systems/t_freertos.pas @@ -955,6 +955,8 @@ var t: Text; hp: TCmdStrListItem; filepath: TCmdStr; + i,j: integer; + lib: AnsiString; {$endif XTENSA} begin {$ifdef XTENSA} @@ -1139,6 +1141,20 @@ begin if ioresult<>0 then exit; + { extract libraries from linker options and add to static libraries list } + Info.ExtraOptions:=trim(Info.ExtraOptions); + i := pos('-l', Info.ExtraOptions); + while i > 0 do + begin + j:=pos(' ',Info.ExtraOptions); + if j=0 then + j:=length(Info.ExtraOptions)+1; + lib:=copy(Info.ExtraOptions,i+2,j-i-2); + AddStaticCLibrary(lib); + delete(Info.ExtraOptions,i,j); + trim(Info.ExtraOptions); + i := pos('-l', Info.ExtraOptions); + end; hp:=TCmdStrListItem(StaticLibFiles.First); while assigned(hp) do begin @@ -1256,8 +1272,7 @@ begin Replace(cmdstr,'$GCSECTIONS',GCSectionsStr); Replace(cmdstr,'$DYNLINK',DynLinkStr); end; - if success and not(cs_link_nolink in current_settings.globalswitches) then - success:=DoExec(FindUtil(utilsprefix+BinStr),cmdstr,true,false); + success:=DoExec(FindUtil(utilsprefix+BinStr),cmdstr,true,false); { Remove ReponseFile } if success and not(cs_link_nolink in current_settings.globalswitches) then diff --git a/compiler/systems/t_nds.pas b/compiler/systems/t_nds.pas index 2ee6a516cd..1cc0afb5fd 100644 --- a/compiler/systems/t_nds.pas +++ b/compiler/systems/t_nds.pas @@ -57,7 +57,7 @@ begin SharedLibFiles.doubles:=true; StaticLibFiles.doubles:=true; // set arm9 as default apptype - if (apptype <> app_arm9) or (apptype <> app_arm7) then + if (apptype <> app_arm9) and (apptype <> app_arm7) then apptype:=app_arm9; end; diff --git a/compiler/systems/t_sinclairql.pas b/compiler/systems/t_sinclairql.pas index 1e16e4ebab..444fd3aa5b 100644 --- a/compiler/systems/t_sinclairql.pas +++ b/compiler/systems/t_sinclairql.pas @@ -115,7 +115,7 @@ begin end else begin - ExeCmd[1]:='vlink -b rawseg -q $FLAGS $GCSECTIONS $OPT $STRIP $MAP -o $EXE -T $RES'; + ExeCmd[1]:='vlink $QLFLAGS $FLAGS $GCSECTIONS $OPT $STRIP $MAP -o $EXE -T $RES'; end; end; end; @@ -245,6 +245,7 @@ var DynLinkStr : string; GCSectionsStr : string; FlagsStr : string; + QLFlagsStr: string; MapStr : string; ExeName: string; fd,fs: file; @@ -258,6 +259,7 @@ var QLHeader: TQLHeader; XTccData: TXTccData; BinSize: longint; + RelocSize: longint; DataSpace: DWord; begin StripStr:=''; @@ -276,6 +278,10 @@ begin begin if create_smartlink_sections then GCSectionsStr:='-gc-all'; + if sinclairql_vlink_experimental then + QLFlagsStr:='-b sinclairql -q -'+lower(sinclairql_metadata_format)+' -stack='+tostr(StackSize) + else + QLFlagsStr:='-b rawseg -q'; end; ExeName:=current_module.exefilename; @@ -292,18 +298,20 @@ begin Replace(cmdstr,'$STRIP',StripStr); Replace(cmdstr,'$GCSECTIONS',GCSectionsStr); Replace(cmdstr,'$DYNLINK',DynLinkStr); + Replace(cmdstr,'$QLFLAGS',QLFlagsStr); MakeSinclairQLExe:=DoExec(BinStr,CmdStr,true,false); { Kludge: With the above linker script, vlink will produce two files. The main binary and the relocation info. Here we copy the two together. (KB) } - if MakeSinclairQLExe then + if MakeSinclairQLExe and not sinclairql_vlink_experimental then begin QLHeader:=DefaultQLHeader; XTccData:=DefaultXTccData; BinSize:=0; + RelocSize:=0; bufsize:=16384; {$push} {$i-} @@ -321,13 +329,18 @@ begin assign(fd,ExeName); rewrite(fd,1); + assign(fs,ExeName+'.'+ProgramHeaderName+'.rel'+ProgramHeaderName); + reset(fs,1); + RelocSize := FileSize(fs); + close(fs); + assign(fs,ExeName+'.'+ProgramHeaderName); reset(fs,1); BinSize := FileSize(fs); { We assume .bss size is total size indicated by linker minus emmited binary. DataSpace size is .bss + stack space } - DataSpace := NToBE(DWord(HeaderSize - BinSize + StackSize)); + DataSpace := NToBE(DWord(max((HeaderSize - BinSize) - RelocSize + StackSize,0))); { Option: prepend QEmuLator and QPC2 v5 compatible header to EXE } if sinclairql_metadata_format='QHDR' then |