* link to crtbegin.o/crtend.o instead of crtbeginS.o/crtendS.o when creating

normal OpenBSD programs (not shared libraries) that link to the C library,
  even when PIC code generation has been turned on. This is what gcc and clang
  do on this platform.

git-svn-id: trunk@41740 -
This commit is contained in:
nickysn 2019-03-19 16:36:38 +00:00
parent d1a91a380b
commit 34a8032e11
2 changed files with 10 additions and 4 deletions

View File

@ -616,7 +616,10 @@ begin
begin
if librarysearchpath.FindFile('crti.o',false,s) then
LinkRes.AddFileName(s);
if cs_create_pic in current_settings.moduleswitches then
if ((cs_create_pic in current_settings.moduleswitches) and
not (target_info.system in systems_openbsd)) or
(current_module.islibrary and
(target_info.system in systems_openbsd)) then
begin
if librarysearchpath.FindFile('crtbeginS.o',false,s) then
LinkRes.AddFileName(s);
@ -740,7 +743,10 @@ begin
if linklibc and
not IsDarwin Then
begin
if cs_create_pic in current_settings.moduleswitches then
if ((cs_create_pic in current_settings.moduleswitches) and
not (target_info.system in systems_openbsd)) or
(current_module.islibrary and
(target_info.system in systems_openbsd)) then
Fl1:=librarysearchpath.FindFile('crtendS.o',false,s1)
else
Fl1:=librarysearchpath.FindFile('crtend.o',false,s1);

View File

@ -28,7 +28,7 @@ var
procedure _mcleanup; cdecl; external name '_mcleanup';
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 __init; cdecl; external name '__init';
procedure _FPC_proc___start(argc: LongInt; argv: PPChar; envp: Pointer; para1, para2, para3: QWord); forward;
@ -75,7 +75,7 @@ procedure _FPC_proc___start(argc: LongInt; argv: PPChar; envp: Pointer; para1, p
end;
atexit(@_mcleanup);
monstartup(u_long(@_eprol),u_long(@_etext));
_init;
__init;
PascalMain;
asm
jmp _FPC_proc_haltproc