39
43
verbose,systems,globtype,globals,
41
45
fmodule,aasmbase,aasmtai,aasmcpu,cpubase,symsym,symdef,
226
231
codeSegment.concat(Taicpu.Op_sym(A_JMP,S_NO,objectlibrary.newasmsymbol(tprocsym(hp2.sym).first_procdef.mangledname,AB_EXTERNAL,AT_FUNCTION)));
227
232
codeSegment.concat(Tai_symbol_end.Createname(hp2.name^));
235
codesegment.concat(Tai_align.create(16));
236
codesegment.concat(Tai_symbol.Createname_global(hp2.name^,AT_FUNCTION,0));
237
codeSegment.concat(Taicpu.Op_sym(A_B,objectlibrary.newasmsymbol(tprocsym(hp2.sym).first_procdef.mangledname,AB_EXTERNAL,AT_FUNCTION)));
238
codeSegment.concat(Tai_symbol_end.Createname(hp2.name^));
232
Message1(parser_e_no_export_of_variables_for_target,'freebsd');
243
Message1(parser_e_no_export_of_variables_for_target,'*bsd/darwin');
233
244
hp2:=texported_item(hp2.next);
263
274
if LdSupportsNoResponseFile then
265
ExeCmd[1]:='ld $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP -L. -o $EXE `cat $RES`';
276
if (target_info.system <> system_powerpc_darwin) then
278
ExeCmd[1]:='ld $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP -L. -o $EXE `cat $RES`';
279
DllCmd[1]:='ld $OPT -shared -L. -o $EXE `cat $RES`'
283
ExeCmd[1]:='ld $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP -multiply_defined suppress -L. -o $EXE `cat $RES`';
284
DllCmd[1]:='libtool $OPT -dynamic -init _PASCALMAIN -multiply_defined suppress -L. -o $EXE `cat $RES`'
268
ExeCmd[1]:='ld $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP -L. -o $EXE $RES';
269
DllCmd[1]:='ld $OPT $INIT $FINI $SONAME -shared -L. -o $EXE $RES';
270
DllCmd[2]:='strip --strip-unneeded $EXE';
272
{$ifdef GLIBC2} {Keep linux code in place. FBSD might go to a different
274
DynamicLinker:='/lib/ld-linux.so.2';
275
if FileExists(DynamicLinker) then
278
{ Check for 2.0 files, else use the glibc 2.1 stub }
279
if FileExists('/lib/ld-2.0.*') then
289
ExeCmd[1]:='ld $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP -L. -o $EXE $RES';
290
DllCmd[1]:='ld $OPT $INIT $FINI $SONAME -shared -L. -o $EXE $RES';
292
if (target_info.system <> system_powerpc_darwin) then
293
DllCmd[2]:='strip --strip-unneeded $EXE'
285
DynamicLinker:='/lib/ld-linux.so.1';
295
DllCmd[2]:='strip -x $EXE';
287
296
DynamicLinker:='';
300
procedure TLinkerBSD.LoadPredefinedLibraryOrder;
301
// put your linkorder/linkalias overrides here.
302
// Note: assumes only called when reordering/aliasing is used.
304
if not(target_info.system in [system_powerpc_darwin,system_i386_darwin]) then
306
if (target_info.system =system_i386_freebsd) and
307
not (cs_link_no_default_lib_order in aktglobalswitches) Then
309
LinkLibraryOrder.add('gcc','',15);
310
LinkLibraryOrder.add('c','',50); // c and c_p mutual. excl?
311
LinkLibraryOrder.add('c_p','',55);
312
LinkLibraryOrder.add('pthread','',75); // pthread and c_r should be mutually exclusive
313
LinkLibraryOrder.add('c_r','',76);
314
LinkLibraryOrder.add('kvm','',80); // must be before ncurses
315
if (cs_link_pthread in aktglobalswitches) Then // convert libpthread to libc_r.
316
LinkLibraryAliases.add('pthread','c_r');
321
LinkLibraryOrder.add('gcc','',15);
322
LinkLibraryOrder.add('c','',50);
293
326
Function TLinkerBSD.WriteResponseFile(isdll:boolean) : Boolean;
304
337
linklibc : boolean;
305
338
Fl1,Fl2 : Boolean;
308
343
WriteResponseFile:=False;
345
IsDarwin:=target_info.system in [system_powerpc_darwin,system_i386_darwin];
309
346
{ set special options for some targets }
310
if target_info.system <> system_powerpc_darwin then
312
linkdynamic:=not(SharedLibFiles.empty);
313
linklibc:=(SharedLibFiles.Find('c')<>nil);
314
linkpthread:=(SharedLibFiles.Find('pthread')<>nil);
315
if (target_info.system =system_i386_freebsd) and linkpthread Then
317
if not (cs_link_pthread in aktglobalswitches) Then
319
{delete pthreads from list, in this case it is in libc_r}
320
SharedLibFiles.Remove(SharedLibFiles.Find('pthread').str);
325
350
cprtobj:='cprt0';
326
351
gprtobj:='gprt0';
352
linkdynamic:=not(SharedLibFiles.empty);
353
linklibc:=(SharedLibFiles.Find('c')<>nil);
354
// this one is a bit complex.
355
// Only reorder for now if -XL or -XO params are given
357
reorder:= linklibc and
361
(cs_link_pthread in aktglobalswitches));
327
362
if cs_profile in aktmoduleswitches then
374
// after this point addition of shared libs not allowed.
342
{ for darwin: always link dynamically against libc�}
378
{ for darwin: always link dynamically against libc }
343
379
linklibc := true;
344
if not(cs_profile in aktmoduleswitches) then
345
prtobj:='/usr/lib/crt1.o'
380
reorder:=reorderentries;
382
if not(cs_profile in aktmoduleswitches) then
384
if librarysearchpath.FindFile('crt1.o',s) then
387
prtobj:='/usr/lib/crt1.o';
390
prtobj:='/usr/lib/gcrt1.o'
347
prtobj:='/usr/lib/gcrt1.o';
396
ExpandAndApplyOrder(SharedLibFiles);
351
398
{ Open link.res file }
352
399
LinkRes:=TLinkRes.Create(outputexedir+Info.ResName);
403
case target_info.system of
404
system_powerpc_darwin:
405
LinkRes.Add('-arch ppc');
407
LinkRes.Add('-arch i386');
354
410
{ Write path to search libraries }
355
411
HPath:=TStringListItem(current_module.locallibrarysearchpath.First);
356
412
while assigned(HPath) do
515
575
DynLinkStr:='-dynamic-linker='+Info.DynamicLinker;
518
DynLinKStr:=DynLinkStr+' --shared';
579
if (target_info.system <> system_powerpc_darwin) then
580
DynLinKStr:=DynLinkStr+' --shared'
582
DynLinKStr:=DynLinkStr+' -dynamic'; // one dash!
519
584
{ Write used files and libraries }
520
585
WriteResponseFile(false);
562
627
SplitBinCmd(Info.DllCmd[1],binstr,cmdstr);
563
629
Replace(cmdstr,'$EXE',maybequoted(current_module.sharedlibfilename^));
631
{$ifdef USE_SYSUTILS}
632
Replace(cmdstr,'$EXE',maybequoted(ExpandFileName(current_module.sharedlibfilename^)));
634
Replace(cmdstr,'$EXE',maybequoted(FExpand(current_module.sharedlibfilename^)));
635
{$endif USE_SYSUTILS}
564
637
Replace(cmdstr,'$OPT',Info.ExtraOptions);
565
638
Replace(cmdstr,'$RES',maybequoted(outputexedir+Info.ResName));
566
639
Replace(cmdstr,'$INIT',InitStr);
567
640
Replace(cmdstr,'$FINI',FiniStr);
568
641
Replace(cmdstr,'$SONAME',SoNameStr);
570
success:=DoExec(FindUtil(utilsprefix+binstr),cmdstr,true,false);
643
success:=DoExec(FindUtil(utilsprefix+binstr),cmdstr,true,LdSupportsNoResponseFile);
572
645
{ Strip the library ? }
573
646
if success and (cs_link_strip in aktglobalswitches) then