* fix symbol substraction in stabs

git-svn-id: trunk@7008 -
This commit is contained in:
peter 2007-03-27 17:43:28 +00:00
parent be76496895
commit 69a4e616ba

View File

@ -671,7 +671,7 @@ Implementation
result:=(code=0); result:=(code=0);
end; end;
function consumeoffset(var p:pchar;out relocsym:tobjsymbol;out value,symvalue:longint):boolean; function consumeoffset(var p:pchar;out relocsym:tobjsymbol;out value:longint):boolean;
var var
hs : string; hs : string;
len, len,
@ -682,17 +682,14 @@ Implementation
gotmin, gotmin,
have_first_symbol, have_first_symbol,
have_second_symbol, have_second_symbol,
have_sym_address,
dosub : boolean; dosub : boolean;
begin begin
result:=false; result:=false;
value:=0; value:=0;
symvalue:=0;
relocsym:=nil; relocsym:=nil;
gotmin:=false; gotmin:=false;
have_first_symbol:=false; have_first_symbol:=false;
have_second_symbol:=false; have_second_symbol:=false;
have_sym_address:=false;
repeat repeat
dosub:=false; dosub:=false;
exprvalue:=0; exprvalue:=0;
@ -741,17 +738,17 @@ Implementation
begin begin
if have_second_symbol then if have_second_symbol then
internalerror(2007032201); internalerror(2007032201);
have_second_symbol:=true; have_second_symbol:=true;
if not have_sym_address then if not have_first_symbol then
internalerror(2007032202); internalerror(2007032202);
{ second symbol should substracted to first } { second symbol should substracted to first }
if not dosub then if not dosub then
internalerror(2007032203); internalerror(2007032203);
if (relocsym.objsection<>sym.objsection) then if (relocsym.objsection<>sym.objsection) then
internalerror(2005091810); internalerror(2005091810);
exprvalue:=relocsym.address-sym.address;
relocsym:=nil; relocsym:=nil;
symvalue:=symvalue-sym.address; dosub:=false;
end end
else else
begin begin
@ -759,10 +756,9 @@ Implementation
if assigned(sym.objsection) then if assigned(sym.objsection) then
begin begin
{ first symbol should be + } { first symbol should be + }
if not have_sym_address and dosub then if not have_first_symbol and dosub then
internalerror(2007032204); internalerror(2007032204);
have_sym_address:=true; have_first_symbol:=true;
symvalue:=sym.address;
end; end;
end; end;
end; end;
@ -787,26 +783,22 @@ Implementation
result:=true; result:=true;
end; end;
const
N_Function = $24; { function or const }
var var
stabstrlen, stabstrlen,
ofs, ofs,
symaddr,
nline, nline,
nidx, nidx,
nother, nother,
i : longint; i : longint;
stab : TObjStabEntry; stab : TObjStabEntry;
relocsym : TObjSymbol; relocsym : TObjSymbol;
pstr,pstart, pstr,
pcurr, pcurr,
pendquote : pchar; pendquote : pchar;
oldsec : TObjSection; oldsec : TObjSection;
reltype : TObjRelocationType; reltype : TObjRelocationType;
begin begin
pcurr:=nil; pcurr:=nil;
pstart:=p;
pstr:=nil; pstr:=nil;
pendquote:=nil; pendquote:=nil;
relocsym:=nil; relocsym:=nil;
@ -851,10 +843,7 @@ Implementation
if not consumenumber(pcurr,nline) then if not consumenumber(pcurr,nline) then
internalerror(200509186); internalerror(200509186);
if consumecomma(pcurr) then if consumecomma(pcurr) then
consumeoffset(pcurr,relocsym,ofs,symaddr); consumeoffset(pcurr,relocsym,ofs);
if assigned(relocsym) and
(relocsym.bind<>AB_LOCAL) then
symaddr:=0;
{ Generate stab entry } { Generate stab entry }
if assigned(pstr) and (pstr[0]<>#0) then if assigned(pstr) and (pstr[0]<>#0) then
@ -889,7 +878,7 @@ Implementation
stab.ntype:=byte(nidx); stab.ntype:=byte(nidx);
stab.ndesc:=word(nline); stab.ndesc:=word(nline);
stab.nother:=byte(nother); stab.nother:=byte(nother);
stab.nvalue:=ofs+symaddr; stab.nvalue:=ofs;
{ Write the stab first without the value field. Then { Write the stab first without the value field. Then
write a the value field with relocation } write a the value field with relocation }