* experimental fix for #8210

git-svn-id: trunk@6948 -
This commit is contained in:
florian 2007-03-21 19:19:30 +00:00
parent 442598d9f8
commit 8c8042aaf0
3 changed files with 81 additions and 4 deletions

1
.gitattributes vendored
View File

@ -6793,6 +6793,7 @@ tests/test/tintfdef.pp svneol=native#text/plain
tests/test/tintuint.pp svneol=native#text/plain
tests/test/tlibrary1.pp svneol=native#text/plain
tests/test/tlibrary2.pp svneol=native#text/plain
tests/test/tlibrary3.pp svneol=native#text/plain
tests/test/tmacbool.pp svneol=native#text/plain
tests/test/tmacfunret.pp svneol=native#text/plain
tests/test/tmaclocalprocparam.pp svneol=native#text/plain

View File

@ -425,10 +425,22 @@ begin
{ try to add crti and crtbegin if linking to C }
if linklibc then
begin
if librarysearchpath.FindFile('crtbegin.o',false,s) then
AddFileName(s);
{ x86_64 requires this to use entry/exit code with pic,
see also issue #8210 regarding a discussion
no idea about the other non i386 CPUs (FK)
}
{$ifdef x86_64}
if current_module.islibrary then
begin
if librarysearchpath.FindFile('crtbeginS.o',false,s) then
AddFileName(s);
end
else
{$endif x86_64}
if librarysearchpath.FindFile('crtbegin.o',false,s) then
AddFileName(s);
if librarysearchpath.FindFile('crti.o',false,s) then
AddFileName(s);
AddFileName(s);
end;
{ main objectfiles }
while not ObjectFiles.Empty do
@ -490,7 +502,17 @@ begin
{ objects which must be at the end }
if linklibc and (libctype<>uclibc) then
begin
found1:=librarysearchpath.FindFile('crtend.o',false,s1);
{ x86_64 requires this to use entry/exit code with pic,
see also issue #8210 regarding a discussion
no idea about the other non i386 CPUs (FK)
}
{$ifdef x86_64}
if current_module.islibrary then
found1:=librarysearchpath.FindFile('crtendS.o',false,s1)
else
{$else x86_64}
found1:=librarysearchpath.FindFile('crtend.o',false,s1);
{$endif x86_64}
found2:=librarysearchpath.FindFile('crtn.o',false,s2);
if found1 or found2 then
begin

54
tests/test/tlibrary3.pp Normal file
View File

@ -0,0 +1,54 @@
{ %NORUN }
{ %SKIPTARGET=macos }
{$ifdef CPUX86_64}
{$ifndef WINDOWS}
{$PIC+}
{$endif WINDOWS}
{$endif CPUX86_64}
{ The .so of the library needs to be in the current dir when
testing the loading at runtime }
{$ifdef mswindows}
{$define supported}
{$define supportidx}
{$endif win32}
{$ifdef Unix}
{$define supported}
{$endif Unix}
{$ifndef fpc}
{$define supported}
{$endif}
{$ifdef supported}
library bug;
uses
initc;
const
publicname='TestName';
publicindex = 1234;
procedure Test;export;
begin
// writeln('Hoi');
end;
exports
Test name publicname;
{$ifdef supportidx}
exports
Test index publicindex;
{$endif}
begin
end.
{$else supported}
begin
Writeln('No library for that target');
end.
{$endif supported}