From 2fdef04a28b97b6bb16570cf3ab4ebba15c4e297 Mon Sep 17 00:00:00 2001 From: nickysn Date: Tue, 28 May 2019 15:39:43 +0000 Subject: [PATCH] * invoke _csu_finish before __init in the OpenBSD i386 C library startup code git-svn-id: trunk@42132 - --- rtl/openbsd/i386/si_c.inc | 7 +++++-- rtl/openbsd/i386/si_g.inc | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/rtl/openbsd/i386/si_c.inc b/rtl/openbsd/i386/si_c.inc index abdeb5d0d6..2c13374c35 100644 --- a/rtl/openbsd/i386/si_c.inc +++ b/rtl/openbsd/i386/si_c.inc @@ -18,6 +18,7 @@ procedure __init; cdecl; external name '__init'; procedure c_exit(exit_code: cint); cdecl; noreturn; external name 'exit'; +function _csu_finish(_argv: PPChar; _envp: PPChar; _cleanup: TCdeclProcedure): PPPChar; cdecl; external name '_csu_finish'; procedure _FPC_proc___start(argc: LongInt; argv: PPChar; envp: Pointer; cleanup: TCdeclProcedure); cdecl; forward; @@ -41,9 +42,11 @@ function _strrchr(str: PChar; character: LongInt): PChar; forward; procedure _FPC_proc___start(argc: LongInt; argv: PPChar; envp: Pointer; cleanup: TCdeclProcedure); cdecl; var I: SizeUInt; + environp: PPPChar; begin - environ:=envp; - operatingsystem_parameter_envp:=envp; + environp:=_csu_finish(argv, envp, cleanup); + environ:=environp^; + operatingsystem_parameter_envp:=environ; operatingsystem_parameter_argc:=argc; operatingsystem_parameter_argv:=argv; if argv[0]<>nil then diff --git a/rtl/openbsd/i386/si_g.inc b/rtl/openbsd/i386/si_g.inc index d09b84421b..976a128df8 100644 --- a/rtl/openbsd/i386/si_g.inc +++ b/rtl/openbsd/i386/si_g.inc @@ -25,6 +25,7 @@ function atexit(proc: TCdeclProcedure): cint; cdecl; external name 'atexit'; procedure _monstartup(lowpc, highpc: u_long); cdecl; external name '_monstartup'; procedure __init; cdecl; external name '__init'; procedure c_exit(exit_code: cint); cdecl; noreturn; external name 'exit'; +function _csu_finish(_argv: PPChar; _envp: PPChar; _cleanup: TCdeclProcedure): PPPChar; cdecl; external name '_csu_finish'; procedure _FPC_proc___start(argc: LongInt; argv: PPChar; envp: Pointer; cleanup: TCdeclProcedure); cdecl; forward; @@ -48,9 +49,11 @@ function _strrchr(str: PChar; character: LongInt): PChar; forward; procedure _FPC_proc___start(argc: LongInt; argv: PPChar; envp: Pointer; cleanup: TCdeclProcedure); cdecl; var I: SizeUInt; + environp: PPPChar; begin - environ:=envp; - operatingsystem_parameter_envp:=envp; + environp:=_csu_finish(argv, envp, cleanup); + environ:=environp^; + operatingsystem_parameter_envp:=environ; operatingsystem_parameter_argc:=argc; operatingsystem_parameter_argv:=argv; if argv[0]<>nil then