+ Fixed incompatibilities/differences with Delphi

git-svn-id: trunk@958 -
This commit is contained in:
michael 2005-08-28 12:30:30 +00:00
parent 1fa1fc663a
commit 726dfa7a37

View File

@ -63,7 +63,8 @@ Index Pointer to
{$ifdef fpc} {$ifdef fpc}
{$mode objfpc} {$mode objfpc}
{$endif} {$endif}
{$H+} {$h+}
unit elfres; unit elfres;
interface interface
@ -226,7 +227,7 @@ procedure TElfResCreator.DoAlign(const a: integer);
var i: integer; var i: integer;
begin begin
i:=(4 - (FSectionStream.position MOD a)) MOD a; i:=(4 - (FSectionStream.position MOD a)) MOD a;
if (i>0) then FSectionStream.Write(zeros,i); if (i>0) then FSectionStream.Write(zeros[1],i);
end; end;
procedure TElfResCreator.Convert(const Source, Destination: String); procedure TElfResCreator.Convert(const Source, Destination: String);
@ -286,7 +287,7 @@ var l:longint;
ws:WideString; ws:WideString;
wc:WideChar; wc:WideChar;
name:string; name:string;
i: integer; i,nl: integer;
headersize:integer; headersize:integer;
headerstart:integer; headerstart:integer;
begin begin
@ -333,11 +334,11 @@ begin
// create a hash of the name // create a hash of the name
resinfo.reshash:=HashELF(name); resinfo.reshash:=HashELF(name);
// save the name plus a trailing #0 to the SymStream, also save // save the name plus a trailing #0 to the SymStream, also save
// the position of this name in the SymStream // the position of this name in the SymStream
resinfo.name:=SymStream.Position; resinfo.name:=SymStream.Position;
name:=name+#0; name:=name+#0;
nl:=length(name);
SymStream.Write(name[1],length(name)); SymStream.Write(name[1],length(name));
// We don't care about the rest of the header // We don't care about the rest of the header
@ -353,7 +354,7 @@ begin
// Align the data stream on a dword boundary // Align the data stream on a dword boundary
i:=(4 - (DataStream.Position MOD 4)) MOD 4; i:=(4 - (DataStream.Position MOD 4)) MOD 4;
if (i>0) then DataStream.Write(zeros,i); if (i>0) then DataStream.Write(zeros[1],i);
end; end;
procedure TElf32ResCreator.LoadBinaryDFMEntry(const rs:TStream; const DataStream:TMemoryStream; const SymStream:TMemoryStream; var resinfo:TELF32ResourceInfo); procedure TElf32ResCreator.LoadBinaryDFMEntry(const rs:TStream; const DataStream:TMemoryStream; const SymStream:TMemoryStream; var resinfo:TELF32ResourceInfo);
@ -494,7 +495,7 @@ begin
// shstrtab - this is not aligned // shstrtab - this is not aligned
shstrtab_ofs:=FSectionStream.Position+sizeof(TElf32Header); shstrtab_ofs:=FSectionStream.Position+sizeof(TElf32Header);
FSectionStream.Write(shstrtab,length(shstrtab)); FSectionStream.Write(shstrtab[1],length(shstrtab));
// Write 12 section headers. The headers itself don't need to be aligned, // Write 12 section headers. The headers itself don't need to be aligned,
// as their size can be divided by 4. As shstrtab is uneven and not aligned, // as their size can be divided by 4. As shstrtab is uneven and not aligned,
@ -651,11 +652,11 @@ begin
FSectionStream.Write(SectionHeader,sizeOf(SectionHeader)); FSectionStream.Write(SectionHeader,sizeOf(SectionHeader));
// now write the symbol table // now write the symbol table
FSectionStream.Write(symtab,length(symtab)); FSectionStream.Write(symtab[1],length(symtab));
// We don't need to align it, as it's $90 in size // We don't need to align it, as it's $90 in size
// now write the string table, it's just a single byte // now write the string table, it's just a single byte
FSectionStream.Write(strtab,1); FSectionStream.Write(strtab[1],1);
// Ok, we are done, now let's really write something to disk... // Ok, we are done, now let's really write something to disk...
@ -678,7 +679,8 @@ begin
Dest.Write(ElfHeader,sizeof(TElf32header)); Dest.Write(ElfHeader,sizeof(TElf32header));
// And now let's dump our whole memorystream into it. // And now let's dump our whole memorystream into it.
Dest.CopyFrom(FSectionStream,0); FSectionStream.Position:=0;
Dest.CopyFrom(FSectionStream,FsectionStream.Size);
end; end;