Browse Source

powerpc-morphos: enable 'section' keyword support, and force the startup code to be in the .text section, to fix linking external objects with unnamed sections on this platform

Karoly Balogh 2 years ago
parent
commit
3695bb5da5
2 changed files with 7 additions and 2 deletions
  1. 1 1
      compiler/systems.pas
  2. 6 1
      rtl/morphos/si_prc.pp

+ 1 - 1
compiler/systems.pas

@@ -318,7 +318,7 @@ interface
        systems_freertos = [system_xtensa_freertos,system_arm_freertos];
 
        { all systems that allow section directive }
-       systems_allow_section = systems_embedded+systems_freertos+systems_wasm;
+       systems_allow_section = systems_embedded+systems_freertos+systems_wasm+[system_powerpc_morphos];
 
        { systems that uses dotted function names as descriptors }
        systems_dotted_function_names = [system_powerpc64_linux]+systems_aix;

+ 6 - 1
rtl/morphos/si_prc.pp

@@ -36,7 +36,12 @@ var
 procedure PascalMainEntry; cdecl; forward;
 
 { this function must be the first in this unit which contains code }
-function _FPC_proc_start: longint; cdecl; public name '_start';
+{ the startup code is forced to be in .text section, because the default
+  linker script of MorphOS' GNU LD puts .text section first, and then
+  all .text.* section, so if we link any object with an unnamed .text
+  section, this won't be at the start of the executable, and we get
+  crashes. (KB) }
+function _FPC_proc_start: longint; cdecl; public name '_start'; section '.text';
 var
   sst: TStackSwapStruct;
   newStack: Pointer;