* fixed stab reloc writing

This commit is contained in:
peter 2000-12-18 21:56:35 +00:00
parent 57df6a2232
commit 503ae036c4

View File

@ -43,7 +43,7 @@ interface
type type
pcoffsection = ^tcoffsection; pcoffsection = ^tcoffsection;
tcoffsection = object(toutputsection) tcoffsection = object(toutputsection)
flags : longint; flags : cardinal;
relocpos : longint; relocpos : longint;
constructor initsec(sec:TSection;AAlign,AFlags:longint); constructor initsec(sec:TSection;AAlign,AFlags:longint);
end; end;
@ -235,7 +235,7 @@ implementation
sec_data : sec_data :
begin begin
if win32 then if win32 then
Flags:=longint($c0300040) Flags:=$c0300040
else else
Flags:=$40; Flags:=$40;
Aalign:=4; Aalign:=4;
@ -243,7 +243,7 @@ implementation
sec_bss : sec_bss :
begin begin
if win32 then if win32 then
Flags:=longint($c0300080) Flags:=$c0300080
else else
Flags:=$80; Flags:=$80;
Aalign:=4; Aalign:=4;
@ -260,7 +260,7 @@ implementation
sec_edata : sec_edata :
begin begin
if win32 then if win32 then
Flags:=longint($c0300040); Flags:=$c0300040;
end; end;
end; end;
sects[sec]:=new(PcoffSection,InitSec(Sec,AAlign,Flags)); sects[sec]:=new(PcoffSection,InitSec(Sec,AAlign,Flags));
@ -385,12 +385,8 @@ implementation
var var
stab : coffstab; stab : coffstab;
s : tsection; s : tsection;
curraddr : longint;
begin begin
{ This is wrong because
sec_none is used only for external bss
if section=sec_none then
s:=currsec
else }
s:=section; s:=section;
{ local var can be at offset -1 !! PM } { local var can be at offset -1 !! PM }
if reloc then if reloc then
@ -419,13 +415,15 @@ implementation
sects[sec_stab]^.write(stab,sizeof(stab)); sects[sec_stab]^.write(stab,sizeof(stab));
{ when the offset is not 0 then write a relocation, take also the { when the offset is not 0 then write a relocation, take also the
hdrstab into account with the offset } hdrstab into account with the offset }
{ current address }
curraddr:=sects[sec_stab]^.mempos+sects[sec_stab]^.datasize;
if reloc then if reloc then
if DLLSource and RelocSection then if DLLSource and RelocSection then
{ avoid relocation in the .stab section { avoid relocation in the .stab section
because it ends up in the .reloc section instead } because it ends up in the .reloc section instead }
sects[sec_stab]^.addsectionreloc(sects[sec_stab]^.datasize-4,s,relative_rva) sects[sec_stab]^.addsectionreloc(curraddr-4,s,relative_rva)
else else
sects[sec_stab]^.addsectionreloc(sects[sec_stab]^.datasize-4,s,relative_false); sects[sec_stab]^.addsectionreloc(curraddr-4,s,relative_false);
end; end;
@ -433,6 +431,7 @@ implementation
nidx,nother,line:longint;reloc:boolean); nidx,nother,line:longint;reloc:boolean);
var var
stab : coffstab; stab : coffstab;
curraddr : longint;
begin begin
{ do not use the size stored in offset field { do not use the size stored in offset field
this is DJGPP specific ! PM } this is DJGPP specific ! PM }
@ -465,14 +464,16 @@ implementation
sects[sec_stab]^.write(stab,sizeof(stab)); sects[sec_stab]^.write(stab,sizeof(stab));
{ when the offset is not 0 then write a relocation, take also the { when the offset is not 0 then write a relocation, take also the
hdrstab into account with the offset } hdrstab into account with the offset }
{ current address }
curraddr:=sects[sec_stab]^.mempos+sects[sec_stab]^.datasize;
if reloc then if reloc then
begin begin
if DLLSource and RelocSection then if DLLSource and RelocSection then
{ avoid relocation in the .stab section { avoid relocation in the .stab section
because it ends up in the .reloc section instead } because it ends up in the .reloc section instead }
sects[sec_stab]^.addsymreloc(sects[sec_stab]^.datasize-4,ps,relative_rva) sects[sec_stab]^.addsymreloc(curraddr-4,ps,relative_rva)
else else
sects[sec_stab]^.addsymreloc(sects[sec_stab]^.datasize-4,ps,relative_false); sects[sec_stab]^.addsymreloc(curraddr-4,ps,relative_false);
end; end;
end; end;
@ -747,7 +748,10 @@ implementation
end. end.
{ {
$Log$ $Log$
Revision 1.2 2000-12-07 17:19:42 jonas Revision 1.3 2000-12-18 21:56:35 peter
* fixed stab reloc writing
Revision 1.2 2000/12/07 17:19:42 jonas
* new constant handling: from now on, hex constants >$7fffffff are * new constant handling: from now on, hex constants >$7fffffff are
parsed as unsigned constants (otherwise, $80000000 got sign extended parsed as unsigned constants (otherwise, $80000000 got sign extended
and became $ffffffff80000000), all constants in the longint range and became $ffffffff80000000), all constants in the longint range