* dllprt0 stub for linux shared libs

* pass -init and -fini for linux shared libs
  * libprefix splitted into staticlibprefix and sharedlibprefix
This commit is contained in:
peter 2001-06-03 15:15:31 +00:00
parent 34a674c6a1
commit 5fed44fe5d
18 changed files with 203 additions and 113 deletions

View File

@ -626,11 +626,11 @@ uses
{ lib and exe could be loaded with a file specified with -o }
if AllowOutput and (OutputFile<>'') and (compile_level=1) then
n:=OutputFile;
staticlibfilename:=stringdup(p+target_info.libprefix+n+target_info.staticlibext);
staticlibfilename:=stringdup(p+target_info.staticlibprefix+n+target_info.staticlibext);
if target_info.target=target_i386_WIN32 then
sharedlibfilename:=stringdup(p+n+target_info.sharedlibext)
else
sharedlibfilename:=stringdup(p+target_info.libprefix+n+target_info.sharedlibext);
sharedlibfilename:=stringdup(p+target_info.sharedlibprefix+n+target_info.sharedlibext);
{ output dir of exe can be specified separatly }
if AllowOutput and (OutputExeDir<>'') then
p:=OutputExeDir
@ -683,7 +683,12 @@ uses
end.
{
$Log$
Revision 1.9 2001-04-18 22:01:53 peter
Revision 1.10 2001-06-03 15:15:31 peter
* dllprt0 stub for linux shared libs
* pass -init and -fini for linux shared libs
* libprefix splitted into staticlibprefix and sharedlibprefix
Revision 1.9 2001/04/18 22:01:53 peter
* registration of targets and assemblers
Revision 1.8 2001/04/13 01:22:07 peter

View File

@ -132,7 +132,6 @@ interface
destructor destroy;override;
procedure reset;virtual;
procedure numberunits;
procedure setfilename(const fn:string;allowoutput:boolean);
end;
tused_unit = class(tlinkedlistitem)
@ -553,56 +552,6 @@ uses
end;
procedure tmodule.setfilename(const fn:string;allowoutput:boolean);
var
p : dirstr;
n : NameStr;
e : ExtStr;
begin
stringdispose(objfilename);
stringdispose(asmfilename);
stringdispose(ppufilename);
stringdispose(staticlibfilename);
stringdispose(sharedlibfilename);
stringdispose(exefilename);
stringdispose(outputpath);
stringdispose(path);
{ Create names }
fsplit(fn,p,n,e);
n:=FixFileName(n);
{ set path }
path:=stringdup(FixPath(p,false));
{ obj,asm,ppu names }
p:=path^;
if AllowOutput then
begin
if (OutputUnitDir<>'') then
p:=OutputUnitDir
else
if (OutputExeDir<>'') then
p:=OutputExeDir;
end;
outputpath:=stringdup(p);
objfilename:=stringdup(p+n+target_info.objext);
asmfilename:=stringdup(p+n+target_info.asmext);
ppufilename:=stringdup(p+n+target_info.unitext);
{ lib and exe could be loaded with a file specified with -o }
if AllowOutput and (OutputFile<>'') and (compile_level=1) then
n:=OutputFile;
staticlibfilename:=stringdup(p+target_info.libprefix+n+target_info.staticlibext);
if target_info.target=target_i386_WIN32 then
sharedlibfilename:=stringdup(p+n+target_info.sharedlibext)
else
sharedlibfilename:=stringdup(p+target_info.libprefix+n+target_info.sharedlibext);
{ output dir of exe can be specified separatly }
if AllowOutput and (OutputExeDir<>'') then
p:=OutputExeDir
else
p:=path^;
exefilename:=stringdup(p+n+target_info.exeext);
end;
procedure tmodule.numberunits;
var
counter : longint;
@ -636,7 +585,12 @@ uses
end.
{
$Log$
Revision 1.15 2001-05-09 14:11:10 jonas
Revision 1.16 2001-06-03 15:15:31 peter
* dllprt0 stub for linux shared libs
* pass -init and -fini for linux shared libs
* libprefix splitted into staticlibprefix and sharedlibprefix
Revision 1.15 2001/05/09 14:11:10 jonas
* range check error fixes from Peter
Revision 1.14 2001/05/06 14:49:16 peter

View File

@ -323,8 +323,8 @@ begin
if s='' then
exit;
{ remove prefix 'lib' }
if Copy(s,1,length(target_info.libprefix))=target_info.libprefix then
Delete(s,1,length(target_info.libprefix));
if Copy(s,1,length(target_info.sharedlibprefix))=target_info.sharedlibprefix then
Delete(s,1,length(target_info.sharedlibprefix));
{ remove extension if any }
if Copy(s,length(s)-length(target_info.sharedlibext)+1,length(target_info.sharedlibext))=target_info.sharedlibext then
Delete(s,length(s)-length(target_info.sharedlibext)+1,length(target_info.sharedlibext)+1);
@ -482,7 +482,12 @@ initialization
end.
{
$Log$
Revision 1.16 2001-04-18 22:01:54 peter
Revision 1.17 2001-06-03 15:15:31 peter
* dllprt0 stub for linux shared libs
* pass -init and -fini for linux shared libs
* libprefix splitted into staticlibprefix and sharedlibprefix
Revision 1.16 2001/04/18 22:01:54 peter
* registration of targets and assemblers
Revision 1.15 2001/04/13 01:22:08 peter

View File

@ -1189,14 +1189,26 @@ implementation
{The program intialization needs an alias, so it can be called
from the bootstrap code.}
codegen_newprocedure;
gen_main_procsym('main',potype_proginit,st);
aktprocsym.definition.aliasnames.insert('program_init');
aktprocsym.definition.aliasnames.insert('PASCALMAIN');
aktprocsym.definition.aliasnames.insert(target_info.cprefix+'main');
if islibrary then
begin
gen_main_procsym(current_module.modulename^+'_main',potype_proginit,st);
aktprocsym.definition.aliasnames.insert(target_info.cprefix+current_module.modulename^+'_main');
aktprocsym.definition.aliasnames.insert('PASCALMAIN');
{ this code is called from C so we need to save some
registers }
include(aktprocsym.definition.procoptions,po_savestdregs);
end
else
begin
gen_main_procsym('main',potype_proginit,st);
aktprocsym.definition.aliasnames.insert('program_init');
aktprocsym.definition.aliasnames.insert('PASCALMAIN');
aktprocsym.definition.aliasnames.insert(target_info.cprefix+'main');
{$ifdef m68k}
if target_info.target=target_m68k_PalmOS then
aktprocsym.definition.aliasnames.insert('PilotMain');
if target_info.target=target_m68k_PalmOS then
aktprocsym.definition.aliasnames.insert('PilotMain');
{$endif m68k}
end;
compile_proc_body(true,false);
{ avoid self recursive destructor call !! PM }
@ -1316,7 +1328,12 @@ implementation
end.
{
$Log$
Revision 1.33 2001-05-19 23:05:19 peter
Revision 1.34 2001-06-03 15:15:31 peter
* dllprt0 stub for linux shared libs
* pass -init and -fini for linux shared libs
* libprefix splitted into staticlibprefix and sharedlibprefix
Revision 1.33 2001/05/19 23:05:19 peter
* support uses <unit> in <file> construction
Revision 1.32 2001/05/18 22:26:36 peter

View File

@ -154,7 +154,8 @@ interface
objext,
resext,
resobjext : string[4];
libprefix : string[4];
staticlibprefix : string[4];
sharedlibprefix : string[4];
Cprefix : string[2];
newline : string[2];
assem : tasm;
@ -573,7 +574,12 @@ finalization
end.
{
$Log$
Revision 1.17 2001-06-02 19:21:45 peter
Revision 1.18 2001-06-03 15:15:31 peter
* dllprt0 stub for linux shared libs
* pass -init and -fini for linux shared libs
* libprefix splitted into staticlibprefix and sharedlibprefix
Revision 1.17 2001/06/02 19:21:45 peter
* extradefines field added to target_info, so that targets don't
need to put code in options.pas for it

View File

@ -64,7 +64,8 @@ implementation
objext : '.o';
resext : '.res';
resobjext : '.or';
libprefix : '';
staticlibprefix : '';
sharedlibprefix : '';
Cprefix : '_';
newline : #10;
assem : as_m68k_as;
@ -92,7 +93,12 @@ initialization
end.
{
$Log$
Revision 1.2 2001-06-02 19:22:44 peter
Revision 1.3 2001-06-03 15:15:31 peter
* dllprt0 stub for linux shared libs
* pass -init and -fini for linux shared libs
* libprefix splitted into staticlibprefix and sharedlibprefix
Revision 1.2 2001/06/02 19:22:44 peter
* extradefines field added
Revision 1.1 2001/04/18 22:02:04 peter

View File

@ -64,7 +64,8 @@ implementation
objext : '.o';
resext : '.res';
resobjext : '.or';
libprefix : '';
staticlibprefix : '';
sharedlibprefix : '';
Cprefix : '_';
newline : #10;
assem : as_m68k_as;
@ -92,7 +93,12 @@ initialization
end.
{
$Log$
Revision 1.2 2001-06-02 19:22:44 peter
Revision 1.3 2001-06-03 15:15:31 peter
* dllprt0 stub for linux shared libs
* pass -init and -fini for linux shared libs
* libprefix splitted into staticlibprefix and sharedlibprefix
Revision 1.2 2001/06/02 19:22:44 peter
* extradefines field added
Revision 1.1 2001/04/18 22:02:04 peter

View File

@ -462,7 +462,8 @@ end;
objext : '.o';
resext : '.res';
resobjext : '.or';
libprefix : 'libp';
staticlibprefix : 'libp';
sharedlibprefix : 'lib';
Cprefix : '';
newline : #10;
assem : as_i386_as;
@ -495,7 +496,12 @@ initialization
end.
{
$Log$
Revision 1.1 2001-06-02 19:29:37 peter
Revision 1.2 2001-06-03 15:15:31 peter
* dllprt0 stub for linux shared libs
* pass -init and -fini for linux shared libs
* libprefix splitted into staticlibprefix and sharedlibprefix
Revision 1.1 2001/06/02 19:29:37 peter
* beos target
}

View File

@ -473,7 +473,8 @@ end;
objext : '.o';
resext : '.res';
resobjext : '.or';
libprefix : 'libp';
staticlibprefix : 'libp';
sharedlibprefix : 'lib';
Cprefix : '';
newline : #10;
assem : as_i386_elf32;
@ -504,7 +505,12 @@ initialization
end.
{
$Log$
Revision 1.5 2001-06-02 19:22:44 peter
Revision 1.6 2001-06-03 15:15:31 peter
* dllprt0 stub for linux shared libs
* pass -init and -fini for linux shared libs
* libprefix splitted into staticlibprefix and sharedlibprefix
Revision 1.5 2001/06/02 19:22:44 peter
* extradefines field added
Revision 1.4 2001/04/21 15:34:01 peter

View File

@ -215,7 +215,8 @@ end;
objext : '.o1';
resext : '.res';
resobjext : '.o1r';
libprefix : '';
staticlibprefix : '';
sharedlibprefix : '';
Cprefix : '_';
newline : #13#10;
assem : as_i386_as;
@ -244,7 +245,12 @@ initialization
end.
{
$Log$
Revision 1.4 2001-06-02 19:22:44 peter
Revision 1.5 2001-06-03 15:15:31 peter
* dllprt0 stub for linux shared libs
* pass -init and -fini for linux shared libs
* libprefix splitted into staticlibprefix and sharedlibprefix
Revision 1.4 2001/06/02 19:22:44 peter
* extradefines field added
Revision 1.3 2001/04/18 22:02:04 peter

View File

@ -443,7 +443,8 @@ end;
objext : '.o';
resext : '.res';
resobjext : '.or';
libprefix : '';
staticlibprefix : '';
sharedlibprefix : '';
Cprefix : '_';
newline : #13#10;
assem : as_i386_coff;
@ -472,7 +473,12 @@ initialization
end.
{
$Log$
Revision 1.4 2001-06-02 19:22:44 peter
Revision 1.5 2001-06-03 15:15:31 peter
* dllprt0 stub for linux shared libs
* pass -init and -fini for linux shared libs
* libprefix splitted into staticlibprefix and sharedlibprefix
Revision 1.4 2001/06/02 19:22:44 peter
* extradefines field added
Revision 1.3 2001/04/18 22:02:04 peter

View File

@ -164,13 +164,18 @@ begin
begin
if not hp2.is_var then
begin
{ the manglednames can already be the same when the procedure
is declared with cdecl }
if hp2.sym.mangledname<>hp2.name^ then
begin
{$ifdef i386}
{ place jump in codesegment }
codesegment.concat(Tai_align.Create_op(4,$90));
codeSegment.concat(Tai_symbol.Createname_global(hp2.name^,0));
codeSegment.concat(Taicpu.Op_sym(A_JMP,S_NO,newasmsymbol(hp2.sym.mangledname)));
codeSegment.concat(Tai_symbol_end.Createname(hp2.name^));
{ place jump in codesegment }
codesegment.concat(Tai_align.Create_op(4,$90));
codeSegment.concat(Tai_symbol.Createname_global(hp2.name^,0));
codeSegment.concat(Taicpu.Op_sym(A_JMP,S_NO,newasmsymbol(hp2.sym.mangledname)));
codeSegment.concat(Tai_symbol_end.Createname(hp2.name^));
{$endif i386}
end;
end
else
Message1(parser_e_no_export_of_variables_for_target,'linux');
@ -200,7 +205,7 @@ begin
with Info do
begin
ExeCmd[1]:='ld $OPT $DYNLINK $STATIC $STRIP -L. -o $EXE $RES';
DllCmd[1]:='ld $OPT -shared -L. -o $EXE $RES';
DllCmd[1]:='ld $OPT $INIT $FINI $SONAME -shared -L. -o $EXE $RES';
DllCmd[2]:='strip --strip-unneeded $EXE';
{ first try glibc2 }
DynamicLinker:='/lib/ld-linux.so.2';
@ -215,11 +220,7 @@ begin
end
else
DynamicLinker:='/lib/ld-linux.so.1';
{$ifdef BSD}
DynamicLinker:='';
{$endif}
end;
end;
@ -239,13 +240,22 @@ begin
{ set special options for some targets }
linkdynamic:=not(SharedLibFiles.empty);
linklibc:=(SharedLibFiles.Find('c')<>nil);
prtobj:='prt0';
cprtobj:='cprt0';
gprtobj:='gprt0';
if glibc21 then
if isdll then
begin
cprtobj:='cprt21';
gprtobj:='gprt21';
prtobj:='dllprt0';
cprtobj:='dllprt0';
gprtobj:='dllprt0';
end
else
begin
prtobj:='prt0';
cprtobj:='cprt0';
gprtobj:='gprt0';
if glibc21 then
begin
cprtobj:='cprt21';
gprtobj:='gprt21';
end;
end;
if cs_profile in aktmoduleswitches then
begin
@ -410,6 +420,9 @@ end;
Function TLinkerLinux.MakeSharedLibrary:boolean;
var
InitStr,
FiniStr,
SoNameStr : string[80];
binstr,
cmdstr : string;
success : boolean;
@ -421,11 +434,19 @@ begin
{ Write used files and libraries }
WriteResponseFile(true);
{ Create some replacements }
InitStr:='-init FPC_LIB_START';
FiniStr:='-fini FPC_LIB_EXIT';
SoNameStr:='-soname '+SplitFileName(current_module.sharedlibfilename^);
{ Call linker }
SplitBinCmd(Info.DllCmd[1],binstr,cmdstr);
Replace(cmdstr,'$EXE',current_module.sharedlibfilename^);
Replace(cmdstr,'$OPT',Info.ExtraOptions);
Replace(cmdstr,'$RES',outputexedir+Info.ResName);
Replace(cmdstr,'$INIT',InitStr);
Replace(cmdstr,'$FINI',FiniStr);
Replace(cmdstr,'$SONAME',SoNameStr);
success:=DoExec(FindUtil(binstr),cmdstr,true,false);
{ Strip the library ? }
@ -473,7 +494,8 @@ end;
objext : '.o';
resext : '.res';
resobjext : '.or';
libprefix : 'libp';
staticlibprefix : 'libp';
sharedlibprefix : 'lib';
Cprefix : '';
newline : #10;
assem : as_i386_elf32;
@ -521,7 +543,8 @@ end;
objext : '.o';
resext : '.res';
resobjext : '.or';
libprefix : 'libp';
staticlibprefix : 'libp';
sharedlibprefix : 'lib';
Cprefix : '';
newline : #10;
assem : as_m68k_as;
@ -569,7 +592,8 @@ end;
objext : '.o';
resext : '.res';
resobjext : '.or';
libprefix : 'libp';
staticlibprefix : 'libp';
sharedlibprefix : 'lib';
Cprefix : '';
newline : #10;
assem : as_powerpc_as;
@ -615,7 +639,8 @@ end;
objext : '.o';
resext : '.res';
resobjext : '.or';
libprefix : 'libp';
staticlibprefix : 'libp';
sharedlibprefix : 'lib';
Cprefix : '';
newline : #10;
assem : as_alpha_as;
@ -667,7 +692,12 @@ initialization
end.
{
$Log$
Revision 1.6 2001-06-02 19:22:44 peter
Revision 1.7 2001-06-03 15:15:31 peter
* dllprt0 stub for linux shared libs
* pass -init and -fini for linux shared libs
* libprefix splitted into staticlibprefix and sharedlibprefix
Revision 1.6 2001/06/02 19:22:44 peter
* extradefines field added
Revision 1.5 2001/04/21 15:34:01 peter

View File

@ -65,7 +65,8 @@ implementation
objext : '.o';
resext : '.res';
resobjext : '.or';
libprefix : '';
staticlibprefix : '';
sharedlibprefix : '';
Cprefix : '_';
newline : #13;
assem : as_m68k_mpw;
@ -114,7 +115,8 @@ implementation
objext : '.o';
resext : '.res';
resobjext : '.or';
libprefix : '';
staticlibprefix : '';
sharedlibprefix : '';
Cprefix : '';
newline : #13;
assem : as_powerpc_mpw;
@ -148,7 +150,12 @@ initialization
end.
{
$Log$
Revision 1.2 2001-06-02 19:22:44 peter
Revision 1.3 2001-06-03 15:15:32 peter
* dllprt0 stub for linux shared libs
* pass -init and -fini for linux shared libs
* libprefix splitted into staticlibprefix and sharedlibprefix
Revision 1.2 2001/06/02 19:22:44 peter
* extradefines field added
Revision 1.1 2001/04/18 22:02:04 peter

View File

@ -479,7 +479,8 @@ end;
objext : '.on';
resext : '.res';
resobjext : '.or';
libprefix : '';
staticlibprefix : '';
sharedlibprefix : '';
Cprefix : '';
newline : #13#10;
assem : as_i386_elf32;
@ -510,7 +511,12 @@ initialization
end.
{
$Log$
Revision 1.5 2001-06-02 19:22:44 peter
Revision 1.6 2001-06-03 15:15:32 peter
* dllprt0 stub for linux shared libs
* pass -init and -fini for linux shared libs
* libprefix splitted into staticlibprefix and sharedlibprefix
Revision 1.5 2001/06/02 19:22:44 peter
* extradefines field added
Revision 1.4 2001/05/30 21:35:49 peter

View File

@ -537,7 +537,8 @@ end;
objext : '.oo2';
resext : '.res';
resobjext : '.oor';
libprefix : '';
staticlibprefix : '';
sharedlibprefix : '';
Cprefix : '_';
newline : #13#10;
assem : as_i386_as_aout;
@ -568,7 +569,12 @@ initialization
end.
{
$Log$
Revision 1.5 2001-06-02 19:22:44 peter
Revision 1.6 2001-06-03 15:15:32 peter
* dllprt0 stub for linux shared libs
* pass -init and -fini for linux shared libs
* libprefix splitted into staticlibprefix and sharedlibprefix
Revision 1.5 2001/06/02 19:22:44 peter
* extradefines field added
Revision 1.4 2001/04/18 22:02:04 peter

View File

@ -65,7 +65,8 @@ implementation
objext : '.o';
resext : '.res';
resobjext : '.or';
libprefix : 'libp';
staticlibprefix : 'libp';
sharedlibprefix : 'lib';
Cprefix : '_';
newline : #10;
assem : as_m68k_as;
@ -95,7 +96,12 @@ initialization
end.
{
$Log$
Revision 1.2 2001-06-02 19:22:44 peter
Revision 1.3 2001-06-03 15:15:32 peter
* dllprt0 stub for linux shared libs
* pass -init and -fini for linux shared libs
* libprefix splitted into staticlibprefix and sharedlibprefix
Revision 1.2 2001/06/02 19:22:44 peter
* extradefines field added
Revision 1.1 2001/04/18 22:02:04 peter

View File

@ -502,7 +502,8 @@ end;
objext : '.o';
resext : '.res';
resobjext : '.or';
libprefix : 'lib';
staticlibprefix : 'libp';
sharedlibprefix : 'lib';
Cprefix : '';
newline : #10;
assem : as_i386_as;
@ -533,7 +534,12 @@ initialization
end.
{
$Log$
Revision 1.5 2001-06-02 19:22:44 peter
Revision 1.6 2001-06-03 15:15:32 peter
* dllprt0 stub for linux shared libs
* pass -init and -fini for linux shared libs
* libprefix splitted into staticlibprefix and sharedlibprefix
Revision 1.5 2001/06/02 19:22:44 peter
* extradefines field added
Revision 1.4 2001/04/21 15:34:01 peter

View File

@ -1417,7 +1417,8 @@ function tDLLScannerWin32.scan(const binname:string):longbool;
objext : '.ow';
resext : '.rc';
resobjext : '.owr';
libprefix : 'libp';
staticlibprefix : 'libp';
sharedlibprefix : '';
Cprefix : '_';
newline : #13#10;
assem : as_i386_pecoff;
@ -1451,7 +1452,12 @@ initialization
end.
{
$Log$
Revision 1.8 2001-06-02 19:22:44 peter
Revision 1.9 2001-06-03 15:15:32 peter
* dllprt0 stub for linux shared libs
* pass -init and -fini for linux shared libs
* libprefix splitted into staticlibprefix and sharedlibprefix
Revision 1.8 2001/06/02 19:22:44 peter
* extradefines field added
Revision 1.7 2001/04/21 13:33:16 peter