Forráskód Böngészése

* fixed argc/argv/envp catching for darwin/x86 (not really nice, but
works)

git-svn-id: trunk@2848 -

Jonas Maebe 19 éve
szülő
commit
a90e3b3e1d
4 módosított fájl, 20 hozzáadás és 13 törlés
  1. 10 7
      compiler/ncgutil.pas
  2. 1 0
      compiler/options.pas
  3. 1 2
      compiler/pmodules.pas
  4. 8 4
      rtl/bsd/system.pp

+ 10 - 7
compiler/ncgutil.pas

@@ -1689,13 +1689,6 @@ implementation
         { call startup helpers from main program }
         if (current_procinfo.procdef.proctypeoption=potype_proginit) then
          begin
-           if (target_info.system in [system_powerpc_darwin,system_i386_darwin,system_powerpc_macos]) and
-              not(current_module.islibrary) then
-             begin
-              { the parameters are already in the right registers }
-              cg.a_call_name(list,target_info.cprefix+'FPC_SYSTEMMAIN');
-             end;
-
            { initialize units }
            cg.allocallcpuregisters(list);
            cg.a_call_name(list,'FPC_INITIALIZEUNITS');
@@ -1787,6 +1780,16 @@ implementation
 
         if (current_procinfo.procdef.proctypeoption=potype_proginit) then
           begin
+           if (target_info.system in [system_powerpc_darwin,system_i386_darwin,system_powerpc_macos]) and
+              not(current_module.islibrary) then
+             begin
+              list.concat(tai_section.create(sec_code,'',4));
+              list.concat(tai_symbol.createname_global(
+                target_info.cprefix+mainaliasname,AT_FUNCTION,0));
+              { keep argc, argv and envp properly on the stack }
+              cg.a_jmp_name(list,target_info.cprefix+'FPC_SYSTEMMAIN');
+             end;
+
             { Reference all DEBUGINFO sections from the main .text section }
             if (cs_debuginfo in aktmoduleswitches) then
               debuginfo.referencesections(list);

+ 1 - 0
compiler/options.pas

@@ -1795,6 +1795,7 @@ begin
 { Temporary defines, until things settle down }
   { "main" symbol is generated in the main program, and left out of the system unit }
   def_system_macro('FPC_DARWIN_PASCALMAIN');
+  def_system_macro('FPC_DARWIN_JMP_MAIN');
   def_system_macro('COMPPROCINLINEFIXED');
   def_system_macro('PARAOUTFILE');
 

+ 1 - 2
compiler/pmodules.pas

@@ -1293,8 +1293,7 @@ implementation
             if not(target_info.system in [system_powerpc_darwin,system_i386_darwin]) then
               pd.aliasnames.insert('PASCALMAIN');
           end
-         else if (target_info.system = system_i386_netware) or
-                 (target_info.system = system_i386_netwlibc) then
+         else if (target_info.system in [system_i386_netware,system_i386_netwlibc,system_powerpc_macos,system_powerpc_darwin,system_i386_darwin]) then
            begin
              pd:=create_main_proc('PASCALMAIN',potype_proginit,current_module.localsymtable);
            end

+ 8 - 4
rtl/bsd/system.pp

@@ -218,11 +218,15 @@ end;
 {$ifdef Darwin}
 
 {$ifndef FPC_DARWIN_PASCALMAIN}
-procedure pascalmain; external name 'PASCALMAIN';
-
+procedure pascalmain;external name 'PASCALMAIN';
 { Main entry point in C style, needed to capture program parameters. }
+
 procedure main(argcparam: Longint; argvparam: ppchar; envpparam: ppchar); cdecl; [public];
 {$else FPC_DARWIN_PASCALMAIN}
+
+{$ifdef FPC_DARWIN_JMP_MAIN}
+procedure pascalmain;cdecl;external name 'PASCALMAIN';
+{$endif}
 procedure FPC_SYSTEMMAIN(argcparam: Longint; argvparam: ppchar; envpparam: ppchar); cdecl; [public];
 {$endif FPC_DARWIN_PASCALMAIN}
 
@@ -230,9 +234,9 @@ begin
   argc:= argcparam;
   argv:= argvparam;
   envp:= envpparam;
-{$ifndef FPC_DARWIN_PASCALMAIN}
+{$if not defined(FPC_DARWIN_PASCALMAIN) or defined(FPC_DARWIN_JMP_MAIN)}
   pascalmain;  {run the pascal main program}
-{$endif FPC_DARWIN_PASCALMAIN}
+{$endif}
 end;
 {$endif Darwin}
 {$endif FPC_USE_LIBC}