cpuelf.pas 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. {
  2. Copyright (c) 2022 by the Free Pascal Development team
  3. Includes ELF-related code specific to m68k
  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 cpuelf;
  18. {$i fpcdefs.inc}
  19. interface
  20. implementation
  21. uses
  22. verbose,elfbase,
  23. systems,ogbase,ogelf,assemble;
  24. const
  25. {* Relocation types. *}
  26. R_68K_NONE = 0;
  27. R_68K_32 = 1;
  28. R_68K_16 = 2;
  29. R_68K_8 = 3;
  30. R_68K_PC32 = 4;
  31. R_68K_PC16 = 5;
  32. R_68K_PC8 = 6;
  33. R_68K_GOT32 = 7;
  34. R_68K_GOT16 = 8;
  35. R_68K_GOT8 = 9;
  36. R_68K_GOT32O = 10;
  37. R_68K_GOT16O = 11;
  38. R_68K_GOT8O = 12;
  39. R_68K_PLT32 = 13;
  40. R_68K_PLT16 = 14;
  41. R_68K_PLT8 = 15;
  42. R_68K_PLT32O = 16;
  43. R_68K_PLT16O = 17;
  44. R_68K_PLT8O = 18;
  45. R_68K_COPY = 19;
  46. R_68K_GLOB_DAT = 20;
  47. R_68K_JMP_SLOT = 21;
  48. R_68K_RELATIVE = 22;
  49. R_68K_GNU_VTINHERIT = 23;
  50. R_68K_GNU_VTENTRY = 24;
  51. R_68K_TLS_GD32 = 25;
  52. R_68K_TLS_GD16 = 26;
  53. R_68K_TLS_GD8 = 27;
  54. R_68K_TLS_LDM32 = 28;
  55. R_68K_TLS_LDM16 = 29;
  56. R_68K_TLS_LDM8 = 30;
  57. R_68K_TLS_LDO32 = 31;
  58. R_68K_TLS_LDO16 = 32;
  59. R_68K_TLS_LDO8 = 33;
  60. R_68K_TLS_IE32 = 34;
  61. R_68K_TLS_IE16 = 35;
  62. R_68K_TLS_IE8 = 36;
  63. R_68K_TLS_LE32 = 37;
  64. R_68K_TLS_LE16 = 38;
  65. R_68K_TLS_LE8 = 39;
  66. R_68K_TLS_DTPMOD32 = 40;
  67. R_68K_TLS_DTPREL32 = 41;
  68. R_68K_TLS_TPREL32 = 42;
  69. {****************************************************************************
  70. ELF Target methods
  71. ****************************************************************************}
  72. function elf_m68k_encodereloc(objrel:TObjRelocation):byte;
  73. begin
  74. case objrel.typ of
  75. RELOC_NONE :
  76. result:=R_68K_NONE;
  77. RELOC_ABSOLUTE :
  78. result:=R_68K_32;
  79. { TODO }
  80. else
  81. result:=0;
  82. InternalError(2022122901);
  83. end;
  84. end;
  85. function elf_m68k_relocname(reltyp:byte):string;
  86. begin
  87. result:='TODO';
  88. end;
  89. procedure elf_m68k_loadreloc(objrel:TObjRelocation);
  90. begin
  91. end;
  92. {*****************************************************************************
  93. Initialize
  94. *****************************************************************************}
  95. const
  96. elf_target_m68k: TElfTarget =
  97. (
  98. max_page_size: $8000; // fixme
  99. exe_image_base: $8000; // fixme
  100. machine_code: EM_M68K;
  101. relocs_use_addend: false;
  102. dyn_reloc_codes: (
  103. R_68K_RELATIVE,
  104. R_68K_GLOB_DAT,
  105. R_68K_JMP_SLOT,
  106. R_68K_COPY,
  107. 0 // IRELATIVE is absent(?)
  108. );
  109. relocname: @elf_m68k_relocName;
  110. encodereloc: @elf_m68k_encodeReloc;
  111. loadreloc: @elf_m68k_loadReloc;
  112. loadsection: nil;
  113. encodeflags: nil;
  114. );
  115. as_m68k_elf32_info : tasminfo =
  116. (
  117. id : as_m68k_elf32;
  118. idtxt : 'ELF';
  119. asmbin : '';
  120. asmcmd : '';
  121. supported_targets : [system_m68k_amiga,system_m68k_embedded];
  122. flags : [af_outputbinary,af_smartlink_sections];
  123. labelprefix : '.L';
  124. labelmaxlen : -1;
  125. comment : '';
  126. dollarsign: '$';
  127. );
  128. initialization
  129. RegisterAssembler(as_m68k_elf32_info,TElfAssembler);
  130. ElfTarget:=elf_target_m68k;
  131. end.