ogmap.pas 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. {
  2. Copyright (c) 2001-2002 by Peter Vreman
  3. Contains the class for generating a map file
  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 ogmap;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. { common }
  22. cclasses,systems,
  23. { object writer }
  24. aasmbase,ogbase
  25. ;
  26. type
  27. texemap = class
  28. private
  29. t : text;
  30. public
  31. constructor Create(const s:string);
  32. destructor Destroy;override;
  33. procedure Add(const s:string);
  34. procedure AddCommonSymbolsHeader;
  35. procedure AddCommonSymbol(p:tasmsymbol);
  36. procedure AddMemoryMapHeader;
  37. procedure AddMemoryMapExeSection(p:texesection);
  38. procedure AddMemoryMapObjectSection(p:TAsmSection);
  39. procedure AddMemoryMapSymbol(p:tasmsymbol);
  40. end;
  41. var
  42. exemap : texemap;
  43. implementation
  44. uses
  45. cutils,globals,verbose;
  46. {****************************************************************************
  47. TExeMap
  48. ****************************************************************************}
  49. constructor TExeMap.Create(const s:string);
  50. begin
  51. Assign(t,FixFileName(s));
  52. Rewrite(t);
  53. end;
  54. destructor TExeMap.Destroy;
  55. begin
  56. Close(t);
  57. end;
  58. procedure TExeMap.Add(const s:string);
  59. begin
  60. writeln(t,s);
  61. end;
  62. procedure TExeMap.AddCommonSymbolsHeader;
  63. begin
  64. writeln(t,'');
  65. writeln(t,'Allocating common symbols');
  66. writeln(t,'Common symbol size file');
  67. writeln(t,'');
  68. end;
  69. procedure TExeMap.AddCommonSymbol(p:tasmsymbol);
  70. var
  71. s : string;
  72. begin
  73. { Common symbol size file }
  74. s:=p.name;
  75. if length(s)>20 then
  76. begin
  77. writeln(t,p.name);
  78. s:='';
  79. end;
  80. writeln(t,PadSpace(s,20)+'0x'+PadSpace(hexstr(p.size,1),16)+p.owner.name);
  81. end;
  82. procedure TExeMap.AddMemoryMapHeader;
  83. begin
  84. writeln(t,'');
  85. writeln(t,'Memory map');
  86. writeln(t,'');
  87. end;
  88. procedure TExeMap.AddMemoryMapExeSection(p:texesection);
  89. begin
  90. { .text 0x000018a8 0xd958 }
  91. writeln(t,PadSpace(p.name,18)+PadSpace('0x'+HexStr(p.mempos,8),15)+'0x'+HexStr(p.memsize,1));
  92. end;
  93. procedure TExeMap.AddMemoryMapObjectSection(p:TAsmSection);
  94. begin
  95. { .text 0x000018a8 0xd958 object.o }
  96. writeln(t,' '+PadSpace(p.name,17)+PadSpace('0x'+HexStr(p.mempos,8),16)+
  97. '0x'+HexStr(p.memsize,1)+' '+p.owner.name);
  98. end;
  99. procedure TExeMap.AddMemoryMapSymbol(p:tasmsymbol);
  100. begin
  101. { 0x00001e30 setup_screens }
  102. writeln(t,Space(18)+PadSpace('0x'+HexStr(p.address,8),26)+p.name);
  103. end;
  104. end.