mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-18 23:29:32 +02:00
* wasm32 obj writer: determine the section number for the datacount, code, data and debug sections ahead of time (before writing the sections)
This commit is contained in:
parent
b5a71086e8
commit
edf5fce7e3
@ -1895,6 +1895,26 @@ implementation
|
|||||||
WriteWasmSection(wsiExport);
|
WriteWasmSection(wsiExport);
|
||||||
Inc(section_nr);
|
Inc(section_nr);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ determine the section numbers for the datacount, code, data and debug sections ahead of time }
|
||||||
|
if segment_count>0 then
|
||||||
|
Inc(section_nr); { the DataCount section }
|
||||||
|
code_section_nr:=section_nr; { the Code section }
|
||||||
|
Inc(section_nr);
|
||||||
|
if segment_count>0 then
|
||||||
|
begin
|
||||||
|
data_section_nr:=section_nr; { the Data section }
|
||||||
|
Inc(section_nr);
|
||||||
|
end;
|
||||||
|
{ the debug sections }
|
||||||
|
MaybeAddDebugSectionToSymbolTable('.debug_abbrev',wcstDebugAbbrev,debug_abbrev_section_nr);
|
||||||
|
MaybeAddDebugSectionToSymbolTable('.debug_info',wcstDebugInfo,debug_info_section_nr);
|
||||||
|
MaybeAddDebugSectionToSymbolTable('.debug_str',wcstDebugStr,debug_str_section_nr);
|
||||||
|
MaybeAddDebugSectionToSymbolTable('.debug_line',wcstDebugLine,debug_line_section_nr);
|
||||||
|
MaybeAddDebugSectionToSymbolTable('.debug_frame',wcstDebugFrame,debug_frame_section_nr);
|
||||||
|
MaybeAddDebugSectionToSymbolTable('.debug_aranges',wcstDebugAranges,debug_aranges_section_nr);
|
||||||
|
MaybeAddDebugSectionToSymbolTable('.debug_ranges',wcstDebugRanges,debug_ranges_section_nr);
|
||||||
|
|
||||||
if segment_count>0 then
|
if segment_count>0 then
|
||||||
begin
|
begin
|
||||||
WriteUleb(FWasmSections[wsiData],segment_count);
|
WriteUleb(FWasmSections[wsiData],segment_count);
|
||||||
@ -1931,11 +1951,7 @@ implementation
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
if segment_count>0 then
|
|
||||||
begin
|
|
||||||
WriteWasmSection(wsiDataCount);
|
|
||||||
Inc(section_nr);
|
|
||||||
end;
|
|
||||||
WriteUleb(FWasmSections[wsiCode],functions_count);
|
WriteUleb(FWasmSections[wsiCode],functions_count);
|
||||||
for i:=0 to Data.ObjSymbolList.Count-1 do
|
for i:=0 to Data.ObjSymbolList.Count-1 do
|
||||||
begin
|
begin
|
||||||
@ -1943,23 +1959,12 @@ implementation
|
|||||||
if (objsym.typ=AT_FUNCTION) and not objsym.IsAlias then
|
if (objsym.typ=AT_FUNCTION) and not objsym.IsAlias then
|
||||||
WriteFunctionCode(FWasmSections[wsiCode],objsym);
|
WriteFunctionCode(FWasmSections[wsiCode],objsym);
|
||||||
end;
|
end;
|
||||||
WriteWasmSection(wsiCode);
|
|
||||||
code_section_nr:=section_nr;
|
|
||||||
Inc(section_nr);
|
|
||||||
if segment_count>0 then
|
|
||||||
begin
|
|
||||||
WriteWasmSection(wsiData);
|
|
||||||
data_section_nr:=section_nr;
|
|
||||||
Inc(section_nr);
|
|
||||||
end;
|
|
||||||
|
|
||||||
MaybeAddDebugSectionToSymbolTable('.debug_abbrev',wcstDebugAbbrev,debug_abbrev_section_nr);
|
if segment_count>0 then
|
||||||
MaybeAddDebugSectionToSymbolTable('.debug_info',wcstDebugInfo,debug_info_section_nr);
|
WriteWasmSection(wsiDataCount);
|
||||||
MaybeAddDebugSectionToSymbolTable('.debug_str',wcstDebugStr,debug_str_section_nr);
|
WriteWasmSection(wsiCode);
|
||||||
MaybeAddDebugSectionToSymbolTable('.debug_line',wcstDebugLine,debug_line_section_nr);
|
if segment_count>0 then
|
||||||
MaybeAddDebugSectionToSymbolTable('.debug_frame',wcstDebugFrame,debug_frame_section_nr);
|
WriteWasmSection(wsiData);
|
||||||
MaybeAddDebugSectionToSymbolTable('.debug_aranges',wcstDebugAranges,debug_aranges_section_nr);
|
|
||||||
MaybeAddDebugSectionToSymbolTable('.debug_ranges',wcstDebugRanges,debug_ranges_section_nr);
|
|
||||||
|
|
||||||
MaybeWriteDebugSection('.debug_abbrev',wcstDebugAbbrev);
|
MaybeWriteDebugSection('.debug_abbrev',wcstDebugAbbrev);
|
||||||
MaybeWriteDebugSection('.debug_info',wcstDebugInfo);
|
MaybeWriteDebugSection('.debug_info',wcstDebugInfo);
|
||||||
|
Loading…
Reference in New Issue
Block a user