[SOLVED] how to turn off PIC on MIPS? lazarus / 64-FPC development ---------------------------------------------------------------------- Key-Real · 2024-07-11 18:46 Someone set the PIC to default. If I do: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i system_mipsel_ps1_info : tsysteminfo =          (            system     : system_mipsel_ps1;            name         : 'PlayStation 1 for MIPSEL';            shortname    : 'ps1';            flags        : [tf_no_pic_supported];                <--------------            cpu        : cpu_mipsel;  the PIC is not disabled! what to do? ---------------------------------------------------------------------- Key-Real · 2024-07-11 20:16 correction: si_prc.pp compiles with PIC: Code: ASM  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i _start:.ent SI_PRC_$$__FPC_PROC_START$$LONGINT        .set    nomips16        .frame  $sp,112,$ra        .mask   0xC0000000,-44        .fmask  0x00000000,0        .set    noreorder        .set    nomacro        addiu   $sp,$sp,-112        sw      $ra,68($sp)        sw      $fp,64($sp)        addiu   $fp,$sp,112# Using PIC code for a_call_name                                      <----------        lui     $gp,%hi(_gp)                                                       <----------        addiu   $gp,$gp,%lo(_gp)                                      <----------        lw      $t9,%call16(PASCALMAIN)($gp)                      <-----------        jalr    $t9                                                                     <-----------       nop        lw      $fp,64($sp)        lw      $ra,68($sp)        jr    $ra        addiu   $sp,$sp,112        .set    macro        .set    reorder.end SI_PRC_$$__FPC_PROC_START$$LONGINT  my Programm whithout: Code: ASM  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i main:.globl  PASCALMAINPASCALMAIN:.ent main        .set    nomips16      .frame  $sp,104,$ra        .mask   0xC0000000,-36        .fmask  0x00000000,0        .set    noreorder        .set    nomacro        addiu   $sp,$sp,-104        sw      $ra,68($sp)        sw      $fp,64($sp)        addiu   $fp,$sp,104        jal     fpc_initializeunits        nop...  how can this be? ---------------------------------------------------------------------- dbannon · 2024-07-12 00:46 Don't know amything about mips, but the build script for my app is used to make a powerpc64el binary and hardening does not work as it should on that cpu. The hardening is turned ON with a string like this on the fpc command line FPCHARD=" -Cg  -k-pie -k-znow " And when building for power, that is left out. So, that says to me, hardening is off by default, turned on with command line switches. Davo ---------------------------------------------------------------------- Key-Real · 2024-07-12 06:43 ok, it seems the Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i [tf_no_pic_supported]works only for the main program not for units. Is there another switch specially for units? ---------------------------------------------------------------------- tetrastes · 2024-07-12 08:30 https://www.freepascal.org/docs-html/current/prog/progsu111.html ? ---------------------------------------------------------------------- Key-Real · 2024-07-12 08:39 this doesn't work Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i {$SMARTLINK OFF}{$PIC OFF}unit si_prc;interface implementation procedure PascalMain; external name 'PASCALMAIN';  { this function must be the first in this unit which contains code }function _FPC_proc_start: longint; cdecl; public name '_start';begin                PascalMain;end;  beginend.  is compiled: Code: ASM  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i         .file "si_prc.pp"        .module nomips16# Begin asmlist al_procedures .section .text,"ax"        .balign 4.globl  SI_PRC_$$__F PC_PROC_START$$LONGINTSI_PRC_$$__FPC_PROC_START$$LONGINT:.globl  _start_start:.ent SI_PRC_$$__FPC_PROC_START$$LONGINT        .set    nomips16        .frame  $sp,112,$ra        .mask   0xC0000000,-44      .fmask  0x00000000,0        .set    noreorder        .set    nomacro        addiu   $sp,$sp,-112        sw      $ra,68($sp)        sw      $fp,64($sp)        addiu   $fp,$sp,112# Using PIC code for a_call_name        lui     $gp,%hi(_gp)        addiu   $gp,$gp,%lo(_gp)        lw      $t9,%call16(PASCALMAIN)($gp)        jalr    $t9        nop        lw      $fp,64($sp)        lw      $ra,68($sp)        jr      $ra        addiu   $sp,$sp,112        .set    macro        .set    reorder.end SI_PRC_$$__FPC_PROC_START$$LONGINT# End asmlist al_procedures  with PIC code! ---------------------------------------------------------------------- dbannon · 2024-07-12 09:06 The point is Key-Real, PIC is off by default, you turn it ON with either -Cg or the define tetrastes pointed to. So, you should be looking for where, in your code (?) its turned on.  Unless there is some difference with mips ?? Seems unlikely. Davo ---------------------------------------------------------------------- Key-Real · 2024-07-12 09:23 I'm trying to see where it is turned ON, but I can't find it... there is a lots of code. someone hints? ---------------------------------------------------------------------- dbannon · 2024-07-12 10:03 Hmm, I guess it has to that directive that tetrastes pointed to. So, search the source dir for "PIC" ? If you are on linux, cd to top of source tree and type $> grep -niR PIC * I guess there must be some way to search all the code on Windows but I am not the person to ask I am afraid. Have all the units been rebuilt ?  I am not sure if you are using Lazarus here, "clean up and build" would be good. If not, maybe blow away the lib dir in the source dir ? Have you tried a simple hello world app ?  Just to be sure the basics are working ? Davo ---------------------------------------------------------------------- Key-Real · 2024-07-12 10:10 I use SublimeText, so I am making a full search on the whole compiler folder.... It is a lot code to go through. Yes my hello world binary is compiled whitout PIC, only the units I'm under Linux ---------------------------------------------------------------------- dbannon · 2024-07-12 12:31 Quote from: Key-Real on July 12, 2024, 12:10:02 pmYes my hello world binary is compiled whitout PIC, only the units Thats good !  So, its got to be either that one or more units were compiled with the -Cg to fpc OR that directive !  You are almost there Key-Real ! Must be a lot of code ..... Davo ---------------------------------------------------------------------- Key-Real · 2024-07-14 09:02 no it is not so good news because somewhere in current_settings.moduleswitches it was set to cs_create_pic only for units.... so, where? AND why the MIPS developers leave me alone? and yes, I'm almost there, because I had it working and I knew the next steps (except the current issue).... https://www.youtube.com/shorts/gF90iw39Dpo ---------------------------------------------------------------------- Key-Real · 2024-07-14 10:06 After I looked at the commits of the ./compiler/MIPS folder, changes I didn't knew about were made not there. Somebody changed the global compiler behavior like: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TLinkerPS1.InitSysInitUnitName;begin  sysinitunit:='si_prc';            <--------------end;  so I think the forced unit PIC default set was done by not a MIPS developer. ---------------------------------------------------------------------- Key-Real · 2024-07-14 10:24 on the over side, if I look to the compiler commits itself, I cant fined no changes pointing to my issue (at least not form commit messages) ---------------------------------------------------------------------- Key-Real · 2024-07-14 15:00 Where ist the place to Set current_settings.moduleswitches Perhaps ist is messed Up Somethere there ---------------------------------------------------------------------- marcov · 2024-07-14 15:07 mode settings are mostly set by parameters to the compiler, or in per target defaults. Sometimes a look in unit options can explain how to set a certain option. ---------------------------------------------------------------------- PascalDragon · 2024-07-14 19:25 Quote from: Key-Real on July 14, 2024, 11:02:19 ambecause somewhere in current_settings.moduleswitches it was set to cs_create_pic only for units.... so, where? Best case here is to search the compiler's source for cs_create_pic and put a breakpoint (or some kind of debug Writeln) at all Include locations and see which one triggers it. Quote from: Key-Real on July 14, 2024, 11:02:19 amAND why the MIPS developers leave me alone? Because there are none. The MIPS port does not have a dedicated maintainer. ---------------------------------------------------------------------- Laksen · 2024-07-14 21:01 Also, it's hard to help you since you work in an always unlinked repository. And if people track it down it doesn't use any of the typical FPC build mechanisms and a lot of hacks If you are serious about getting support for this, it should be done like other FPC targets, and then maybe people can help ---------------------------------------------------------------------- Key-Real · 2024-07-15 09:19 great success!!!! I found this place (surprise) in the MIPS Target. BUT see: https://forum.lazarus.freepascal.org/index.php/topic,67888.0.html ---------------------------------------------------------------------- Key-Real · 2024-07-15 13:41 @Laksen: ok, If You tell me how it is made for other Targets and what I do wrong, I'm than able to make it better thx for help ---------------------------------------------------------------------- PascalDragon · 2024-07-16 19:20 Quote from: Key-Real on July 15, 2024, 03:41:15 pmok, If You tell me how it is made for other Targets and what I do wrong, I'm than able to make it better More or less what is written here. And you should also generate your link script inside the compiler (look at e.g. TLinkerLinux.WriteResponseFile in systems/t_linux.pas). What is not mentioned is excluding your target from the various fpmake.pp inside packages. Though as a first step it would be enough if a make all OS_TARGET=ps1 CPU_TARGET=mips inside the rtl directory works.