+ enable weak externals for OpenBSD

* converted the reference to _init in si_dll to be a weak external. This way we
  can support creating shared libraries that link to the C library as well as
  libraries that do not. If libc was linked, the compiler will link in
  crtbeginS.o and crtendS.o; _init is defined in crtbeginS.o and initializes the
  C library and calls all the C static constructors.

git-svn-id: trunk@41751 -
This commit is contained in:
nickysn 2019-03-20 15:13:47 +00:00
parent aad032f133
commit 52a5669117
2 changed files with 7 additions and 2 deletions

View File

@ -346,7 +346,7 @@ interface
systems_indirect_entry_information = systems_darwin+[system_i386_win32,system_x86_64_win64,system_x86_64_linux];
{ all systems for which weak linking has been tested/is supported }
systems_weak_linking = systems_darwin + systems_solaris + systems_linux + systems_android;
systems_weak_linking = systems_darwin + systems_solaris + systems_linux + systems_android + systems_openbsd;
systems_internal_sysinit = [system_i386_win32,system_x86_64_win64,
system_i386_linux,system_powerpc64_linux,system_sparc64_linux,system_x86_64_linux,

View File

@ -16,7 +16,11 @@
{$asmmode gas}
{$ifdef VER3_0}
procedure _init; external name '_init';
{$else VER3_0}
procedure _init; weakexternal name '_init';
{$endif VER3_0}
procedure _FPC_proc___start(argc: LongInt; argv: PPChar; envp: Pointer; para1, para2, para3: QWord); forward;
@ -61,7 +65,8 @@ procedure _FPC_proc___start(argc: LongInt; argv: PPChar; envp: Pointer; para1, p
__progname_storage[I]:=#0;
__progname:=@__progname_storage;
end;
_init;
if Assigned(@_init) then
_init;
PascalMain;
asm
jmp _FPC_proc_haltproc@PLT