mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 19:09:23 +02:00
Add MaybeSwap for coffsectionrec records (needed for cross-endian compilation)
This commit is contained in:
parent
615e9bdafd
commit
9648463eb5
@ -1841,6 +1841,7 @@ const pemagic : array[0..3] of byte = (
|
|||||||
else
|
else
|
||||||
secrec.nrelocs:=65535;
|
secrec.nrelocs:=65535;
|
||||||
inc(symidx);
|
inc(symidx);
|
||||||
|
MaybeSwap(secrec);
|
||||||
FCoffSyms.write(secrec,sizeof(secrec));
|
FCoffSyms.write(secrec,sizeof(secrec));
|
||||||
{ aux recs have the same size as symbols, so we need to add two
|
{ aux recs have the same size as symbols, so we need to add two
|
||||||
Byte of padding in case of a Big Obj Coff }
|
Byte of padding in case of a Big Obj Coff }
|
||||||
@ -2396,7 +2397,8 @@ const pemagic : array[0..3] of byte = (
|
|||||||
strname : string;
|
strname : string;
|
||||||
auxrec : array[0..sizeof(coffsymbol)-1] of byte;
|
auxrec : array[0..sizeof(coffsymbol)-1] of byte;
|
||||||
boauxrec : array[0..sizeof(coffbigobjsymbol)-1] of byte;
|
boauxrec : array[0..sizeof(coffbigobjsymbol)-1] of byte;
|
||||||
secrec : pcoffsectionrec;
|
psecrec : pcoffsectionrec;
|
||||||
|
secrec : coffsectionrec;
|
||||||
objsec : TObjSection;
|
objsec : TObjSection;
|
||||||
secidx : longint;
|
secidx : longint;
|
||||||
symvalue : longword;
|
symvalue : longword;
|
||||||
@ -2546,15 +2548,19 @@ const pemagic : array[0..3] of byte = (
|
|||||||
if bigobj then
|
if bigobj then
|
||||||
begin
|
begin
|
||||||
FCoffSyms.Read(boauxrec,sizeof(boauxrec));
|
FCoffSyms.Read(boauxrec,sizeof(boauxrec));
|
||||||
secrec:=pcoffsectionrec(@boauxrec[0]);
|
psecrec:=pcoffsectionrec(@boauxrec[0]);
|
||||||
|
secrec:=psecrec^;
|
||||||
|
MaybeSwap(secrec);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
FCoffSyms.Read(auxrec,sizeof(auxrec));
|
FCoffSyms.Read(auxrec,sizeof(auxrec));
|
||||||
secrec:=pcoffsectionrec(@auxrec);
|
psecrec:=pcoffsectionrec(@auxrec);
|
||||||
|
secrec:=psecrec^;
|
||||||
|
MaybeSwap(secrec);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
case secrec^.select of
|
case secrec.select of
|
||||||
IMAGE_COMDAT_SELECT_NODUPLICATES:
|
IMAGE_COMDAT_SELECT_NODUPLICATES:
|
||||||
comdatsel:=oscs_none;
|
comdatsel:=oscs_none;
|
||||||
IMAGE_COMDAT_SELECT_ANY:
|
IMAGE_COMDAT_SELECT_ANY:
|
||||||
@ -2569,14 +2575,14 @@ const pemagic : array[0..3] of byte = (
|
|||||||
comdatsel:=oscs_largest;
|
comdatsel:=oscs_largest;
|
||||||
else begin
|
else begin
|
||||||
comdatsel:=oscs_none;
|
comdatsel:=oscs_none;
|
||||||
Message2(link_e_comdat_select_unsupported,inttostr(secrec^.select),objsym.objsection.name);
|
Message2(link_e_comdat_select_unsupported,inttostr(secrec.select),objsym.objsection.name);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if comdatsel in [oscs_associative,oscs_exact_match] then
|
if comdatsel in [oscs_associative,oscs_exact_match] then
|
||||||
{ only temporary }
|
{ only temporary }
|
||||||
Comment(V_Error,'Associative or exact match COMDAT sections are not yet supported (symbol: '+objsym.objsection.Name+')')
|
Comment(V_Error,'Associative or exact match COMDAT sections are not yet supported (symbol: '+objsym.objsection.Name+')')
|
||||||
else if (comdatsel=oscs_associative) and (secrec^.assoc=0) then
|
else if (comdatsel=oscs_associative) and (secrec.assoc=0) then
|
||||||
Message1(link_e_comdat_associative_section_expected,objsym.objsection.name)
|
Message1(link_e_comdat_associative_section_expected,objsym.objsection.name)
|
||||||
else if (objsym.objsection.ComdatSelection<>oscs_none) and (comdatsel<>oscs_none) and (objsym.objsection.ComdatSelection<>comdatsel) then
|
else if (objsym.objsection.ComdatSelection<>oscs_none) and (comdatsel<>oscs_none) and (objsym.objsection.ComdatSelection<>comdatsel) then
|
||||||
Message2(link_e_comdat_not_matching,objsym.objsection.Name,objsym.Name)
|
Message2(link_e_comdat_not_matching,objsym.objsection.Name,objsym.Name)
|
||||||
@ -2584,9 +2590,9 @@ const pemagic : array[0..3] of byte = (
|
|||||||
begin
|
begin
|
||||||
objsym.objsection.ComdatSelection:=comdatsel;
|
objsym.objsection.ComdatSelection:=comdatsel;
|
||||||
|
|
||||||
if (secrec^.assoc<>0) and not assigned(objsym.objsection.AssociativeSection) then
|
if (secrec.assoc<>0) and not assigned(objsym.objsection.AssociativeSection) then
|
||||||
begin
|
begin
|
||||||
objsym.objsection.AssociativeSection:=GetSection(secrec^.assoc);
|
objsym.objsection.AssociativeSection:=GetSection(secrec.assoc);
|
||||||
if not assigned(objsym.objsection.AssociativeSection) then
|
if not assigned(objsym.objsection.AssociativeSection) then
|
||||||
Message1(link_e_comdat_associative_section_not_found,objsym.objsection.Name);
|
Message1(link_e_comdat_associative_section_not_found,objsym.objsection.Name);
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user