+ added a 'producers' custom section to WebAssembly object modules, containing the FPC version

This commit is contained in:
Nikolay Nikolov 2022-05-28 03:31:53 +03:00
parent 1ce1a0fe1f
commit 1dd80d596d
2 changed files with 19 additions and 3 deletions

View File

@ -169,7 +169,7 @@ interface
implementation
uses
verbose;
verbose,version;
procedure WriteUleb5(d: tdynamicarray; v: uint64);
var
@ -1655,6 +1655,18 @@ implementation
Writer.write(WasmModuleMagic,SizeOf(WasmModuleMagic));
Writer.write(WasmVersion,SizeOf(WasmVersion));
{ Write the producers section:
https://github.com/WebAssembly/tool-conventions/blob/main/ProducersSection.md }
WriteUleb(FWasmCustomSections[wcstProducers],2);
WriteName(FWasmCustomSections[wcstProducers],'language');
WriteUleb(FWasmCustomSections[wcstProducers],1);
WriteName(FWasmCustomSections[wcstProducers],'Pascal');
WriteName(FWasmCustomSections[wcstProducers],'');
WriteName(FWasmCustomSections[wcstProducers],'processed-by');
WriteUleb(FWasmCustomSections[wcstProducers],1);
WriteName(FWasmCustomSections[wcstProducers],'Free Pascal Compiler (FPC)');
WriteName(FWasmCustomSections[wcstProducers],full_version_string+' ['+date_string+'] for '+target_cpu_string+' - '+target_info.shortname);
code_section_nr:=-1;
data_section_nr:=-1;
section_nr:=0;
@ -1708,6 +1720,8 @@ implementation
WriteWasmCustomSection(wcstRelocData);
Inc(section_nr);
end;
WriteWasmCustomSection(wcstProducers);
Inc(section_nr);
result:=true;
end;

View File

@ -49,13 +49,15 @@ type
TWasmCustomSectionType = (
wcstLinking,
wcstRelocCode,
wcstRelocData);
wcstRelocData,
wcstProducers);
const
WasmCustomSectionName: array [TWasmCustomSectionType] of string =
('linking',
'reloc.CODE',
'reloc.DATA');
'reloc.DATA',
'producers');
type
TWasmRelocationType = (