* updated for new linking, but still doesn't work because ld-linux.so.2

requires some more crt*.o files
This commit is contained in:
peter 1999-07-28 16:53:58 +00:00
parent 00c8bda3b2
commit 48cfee3a4b

View File

@ -33,7 +33,7 @@ uses
getopts; getopts;
const const
Version = 'Version 0.99.12'; Version = 'Version 0.99.13';
Title = 'PPU-Mover'; Title = 'PPU-Mover';
Copyright = 'Copyright (c) 1998-99 by the Free Pascal Development Team'; Copyright = 'Copyright (c) 1998-99 by the Free Pascal Development Team';
@ -50,6 +50,12 @@ const
BatchExt ='.bat'; BatchExt ='.bat';
{$endif Linux} {$endif Linux}
{ link options }
link_none = $0;
link_allways = $1;
link_static = $2;
link_smart = $4;
link_shared = $8;
Type Type
PLinkOEnt = ^TLinkOEnt; PLinkOEnt = ^TLinkOEnt;
@ -82,7 +88,6 @@ Procedure Error(const s:string;stop:boolean);
begin begin
{$ifdef FPC} {$ifdef FPC}
writeln(stderr,s); writeln(stderr,s);
flush(stderr);
{$else} {$else}
writeln(s); writeln(s);
{$endif} {$endif}
@ -226,10 +231,10 @@ Var
outppu : pppufile; outppu : pppufile;
b, b,
untilb : byte; untilb : byte;
l : longint; l,m : longint;
i : word; i : word;
f : file; f : file;
isstaticlinked : boolean; s : string;
begin begin
DoPPU:=false; DoPPU:=false;
If Not Quiet then If Not Quiet then
@ -248,7 +253,7 @@ begin
Error('Error: Not a PPU File : '+PPUFn,false); Error('Error: Not a PPU File : '+PPUFn,false);
Exit; Exit;
end; end;
if inppu^.GetPPUVersion<15 then if inppu^.GetPPUVersion<CurrentPPUVersion then
begin begin
dispose(inppu,done); dispose(inppu,done);
Error('Error: Wrong PPU Version : '+PPUFn,false); Error('Error: Wrong PPU Version : '+PPUFn,false);
@ -261,6 +266,13 @@ begin
Error('Error: PPU is already in a library : '+PPUFn,false); Error('Error: PPU is already in a library : '+PPUFn,false);
Exit; Exit;
end; end;
{ We need a static linked unit }
if (inppu^.header.flags and uf_static_linked)=0 then
begin
dispose(inppu,done);
Error('Error: PPU is not static linked : '+PPUFn,false);
Exit;
end;
{ Create the new ppu } { Create the new ppu }
if PPUFn=PPLFn then if PPUFn=PPLFn then
outppu:=new(pppufile,init('ppumove.$$$')) outppu:=new(pppufile,init('ppumove.$$$'))
@ -272,15 +284,10 @@ begin
outppu^.header.flags:=outppu^.header.flags or uf_in_library; outppu^.header.flags:=outppu^.header.flags or uf_in_library;
if MakeStatic then if MakeStatic then
outppu^.header.flags:=outppu^.header.flags or uf_static_linked outppu^.header.flags:=outppu^.header.flags or uf_static_linked
else
outppu^.header.flags:=outppu^.header.flags or uf_shared_linked;
{ Is the until smartlinked ? }
IsStaticLinked:=(inppu^.header.flags and uf_static_linked)<>0;
{ read until the object files are found }
if IsStaticLinked then
untilb:=iblinkunitstaticlibs
else else
untilb:=iblinkunitofiles; outppu^.header.flags:=outppu^.header.flags or uf_shared_linked;
{ read until the object files are found }
untilb:=iblinkunitofiles;
repeat repeat
b:=inppu^.readentry; b:=inppu^.readentry;
if b in [ibendinterface,ibend] then if b in [ibendinterface,ibend] then
@ -302,28 +309,50 @@ begin
{ we have now reached the section for the files which need to be added, { we have now reached the section for the files which need to be added,
now add them to the list } now add them to the list }
case b of case b of
iblinkunitofiles : begin iblinkunitofiles :
while not inppu^.endofentry do begin
AddToLinkFiles(inppu^.getstring); { add all o files, and save the entry when not creating a static
end; library to keep staticlinking possible }
iblinkunitstaticlibs : begin while not inppu^.endofentry do
AddToLinkFiles(ExtractLib(inppu^.getstring)); begin
if not inppu^.endofentry then s:=inppu^.getstring;
begin m:=inppu^.getlongint;
repeat if not MakeStatic then
inppu^.getdatabuf(buffer^,bufsize,l); begin
outppu^.putdata(buffer^,l); outppu^.putstring(s);
until l<bufsize; outppu^.putlongint(m);
outppu^.writeentry(b); end;
end; AddToLinkFiles(s);
end; end;
if not MakeStatic then
outppu^.writeentry(b);
end;
{ iblinkunitstaticlibs :
begin
AddToLinkFiles(ExtractLib(inppu^.getstring));
if not inppu^.endofentry then
begin
repeat
inppu^.getdatabuf(buffer^,bufsize,l);
outppu^.putdata(buffer^,l);
until l<bufsize;
outppu^.writeentry(b);
end;
end; }
end; end;
{ just add a new entry with the new lib } { just add a new entry with the new lib }
outppu^.putstring(outputfile);
if MakeStatic then if MakeStatic then
outppu^.writeentry(iblinkunitstaticlibs) begin
outppu^.putstring(outputfile);
outppu^.putlongint(link_static);
outppu^.writeentry(iblinkunitstaticlibs)
end
else else
outppu^.writeentry(iblinkunitsharedlibs); begin
outppu^.putstring(outputfile);
outppu^.putlongint(link_shared);
outppu^.writeentry(iblinkunitsharedlibs);
end;
{ read all entries until the end and write them also to the new ppu } { read all entries until the end and write them also to the new ppu }
repeat repeat
b:=inppu^.readentry; b:=inppu^.readentry;
@ -380,6 +409,7 @@ begin
exit; exit;
findnext(dir); findnext(dir);
end; end;
findclose(dir);
DoFile:=true; DoFile:=true;
{$endif} {$endif}
end; end;
@ -423,13 +453,6 @@ begin
Err:=Shell(ldbin+' -shared -o '+OutputFile+' '+names)<>0; Err:=Shell(ldbin+' -shared -o '+OutputFile+' '+names)<>0;
If Err then If Err then
Error('Fatal: Library building stage failed.',true); Error('Fatal: Library building stage failed.',true);
{ Remove the .o files }
if PPLExt=PPUExt then
begin
while pos('*',names)>0 do
Delete(names,pos('*',names),1);
Shell('rm -rf '+names);
end;
{ Rename to the destpath } { Rename to the destpath }
if DestPath<>'' then if DestPath<>'' then
begin begin
@ -470,7 +493,7 @@ begin
repeat repeat
c:=Getopt (ShortOpts); c:=Getopt (ShortOpts);
Case C of Case C of
EndOfOptions : break; EndOfOptions : break;
's' : MakeStatic:=True; 's' : MakeStatic:=True;
'o' : OutputFile:=OptArg; 'o' : OutputFile:=OptArg;
'd' : DestPath:=OptArg; 'd' : DestPath:=OptArg;
@ -494,7 +517,7 @@ begin
GetMem (Buffer,Bufsize); GetMem (Buffer,Bufsize);
If Buffer=Nil then If Buffer=Nil then
Error('Error: could not allocate memory for buffer.',true); Error('Error: could not allocate memory for buffer.',true);
{ fix filename } { fix filename }
{$ifdef linux} {$ifdef linux}
if Copy(OutputFile,1,3)<>'lib' then if Copy(OutputFile,1,3)<>'lib' then
OutputFile:='lib'+OutputFile; OutputFile:='lib'+OutputFile;
@ -502,8 +525,6 @@ begin
end; end;
var var
i : longint; i : longint;
begin begin
@ -559,7 +580,11 @@ begin
end. end.
{ {
$Log$ $Log$
Revision 1.3 1999-07-06 11:32:54 peter Revision 1.4 1999-07-28 16:53:58 peter
* updated for new linking, but still doesn't work because ld-linux.so.2
requires some more crt*.o files
Revision 1.3 1999/07/06 11:32:54 peter
* updated for new ppu.pas * updated for new ppu.pas
Revision 1.2 1999/06/08 22:16:07 peter Revision 1.2 1999/06/08 22:16:07 peter