ogwasm.pas 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. {
  2. Copyright (c) 2021 by Nikolay Nikolov
  3. Contains the WebAssembly binary module format reader and writer
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. ****************************************************************************
  16. }
  17. unit ogwasm;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. { common }
  22. globtype,
  23. { target }
  24. systems,
  25. { assembler }
  26. aasmbase,assemble,
  27. { output }
  28. ogbase,
  29. owbase;
  30. type
  31. { TWasmObjData }
  32. TWasmObjData = class(TObjData)
  33. public
  34. function sectionname(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder):string;override;
  35. procedure writeReloc(Data:TRelocDataInt;len:aword;p:TObjSymbol;Reloctype:TObjRelocationType);override;
  36. end;
  37. { TWasmObjOutput }
  38. TWasmObjOutput = class(tObjOutput)
  39. protected
  40. function writeData(Data:TObjData):boolean;override;
  41. public
  42. constructor create(AWriter:TObjectWriter);override;
  43. end;
  44. { TWasmAssembler }
  45. TWasmAssembler = class(tinternalassembler)
  46. constructor create(info: pasminfo; smart:boolean);override;
  47. end;
  48. implementation
  49. {****************************************************************************
  50. TWasmObjData
  51. ****************************************************************************}
  52. function TWasmObjData.sectionname(atype: TAsmSectiontype;
  53. const aname: string; aorder: TAsmSectionOrder): string;
  54. begin
  55. result:='todosectionname';
  56. end;
  57. procedure TWasmObjData.writeReloc(Data: TRelocDataInt; len: aword;
  58. p: TObjSymbol; Reloctype: TObjRelocationType);
  59. begin
  60. end;
  61. {****************************************************************************
  62. TWasmObjOutput
  63. ****************************************************************************}
  64. function TWasmObjOutput.writeData(Data:TObjData):boolean;
  65. begin
  66. result:=false;
  67. end;
  68. constructor TWasmObjOutput.create(AWriter: TObjectWriter);
  69. begin
  70. inherited;
  71. cobjdata:=TWasmObjData;
  72. end;
  73. {****************************************************************************
  74. TWasmAssembler
  75. ****************************************************************************}
  76. constructor TWasmAssembler.Create(info: pasminfo; smart:boolean);
  77. begin
  78. inherited;
  79. CObjOutput:=TWasmObjOutput;
  80. end;
  81. {*****************************************************************************
  82. Initialize
  83. *****************************************************************************}
  84. {$ifdef wasm32}
  85. const
  86. as_wasm32_wasm_info : tasminfo =
  87. (
  88. id : as_wasm32_wasm;
  89. idtxt : 'OMF';
  90. asmbin : '';
  91. asmcmd : '';
  92. supported_targets : [system_wasm32_embedded,system_wasm32_wasi];
  93. flags : [af_outputbinary,af_smartlink_sections];
  94. labelprefix : '..@';
  95. labelmaxlen : -1;
  96. comment : '; ';
  97. dollarsign: '$';
  98. );
  99. {$endif wasm32}
  100. initialization
  101. {$ifdef wasm32}
  102. RegisterAssembler(as_wasm32_wasm_info,TWasmAssembler);
  103. {$endif wasm32}
  104. end.