ogmap.pas 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. {
  2. $Id$
  3. Copyright (c) 2001-2002 by Peter Vreman
  4. Contains the class for generating a map file
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. unit ogmap;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. { common }
  23. cclasses,systems,
  24. { object writer }
  25. aasmbase,ogbase
  26. ;
  27. type
  28. texemap = class
  29. private
  30. t : text;
  31. public
  32. constructor Create(const s:string);
  33. destructor Destroy;override;
  34. procedure Add(const s:string);
  35. procedure AddCommonSymbolsHeader;
  36. procedure AddCommonSymbol(p:tasmsymbol);
  37. procedure AddMemoryMapHeader;
  38. procedure AddMemoryMapSection(p:texesection);
  39. procedure AddMemoryMapObjectData(p:TAsmObjectData;sec:TSection);
  40. procedure AddMemoryMapSymbol(p:tasmsymbol);
  41. end;
  42. var
  43. exemap : texemap;
  44. implementation
  45. uses
  46. cutils,globals,verbose;
  47. {****************************************************************************
  48. TExeMap
  49. ****************************************************************************}
  50. constructor TExeMap.Create(const s:string);
  51. begin
  52. Assign(t,FixFileName(s));
  53. Rewrite(t);
  54. end;
  55. destructor TExeMap.Destroy;
  56. begin
  57. Close(t);
  58. end;
  59. procedure TExeMap.Add(const s:string);
  60. begin
  61. writeln(t,s);
  62. end;
  63. procedure TExeMap.AddCommonSymbolsHeader;
  64. begin
  65. writeln(t,'');
  66. writeln(t,'Allocating common symbols');
  67. writeln(t,'Common symbol size file');
  68. writeln(t,'');
  69. end;
  70. procedure TExeMap.AddCommonSymbol(p:tasmsymbol);
  71. var
  72. s : string;
  73. begin
  74. { Common symbol size file }
  75. s:=p.name;
  76. if length(s)>20 then
  77. begin
  78. writeln(t,p.name);
  79. s:='';
  80. end;
  81. writeln(t,PadSpace(s,20)+'0x'+PadSpace(hexstr(p.size,1),16)+TAsmObjectData(p.objectdata).name);
  82. end;
  83. procedure TExeMap.AddMemoryMapHeader;
  84. begin
  85. writeln(t,'');
  86. writeln(t,'Memory map');
  87. writeln(t,'');
  88. end;
  89. procedure TExeMap.AddMemoryMapSection(p:texesection);
  90. begin
  91. { .text 0x000018a8 0xd958 }
  92. writeln(t,PadSpace(p.name,18)+PadSpace('0x'+HexStr(p.mempos,8),15)+'0x'+HexStr(p.memsize,1));
  93. end;
  94. procedure TExeMap.AddMemoryMapObjectData(p:TAsmObjectData;sec:TSection);
  95. begin
  96. { .text 0x000018a8 0xd958 object.o }
  97. writeln(t,' '+PadSpace(p.sects[sec].name,17)+PadSpace('0x'+HexStr(p.sects[sec].mempos,8),16)+
  98. '0x'+HexStr(p.sects[sec].memsize,1)+' '+p.name);
  99. end;
  100. procedure TExeMap.AddMemoryMapSymbol(p:tasmsymbol);
  101. begin
  102. { 0x00001e30 setup_screens }
  103. writeln(t,Space(18)+PadSpace('0x'+HexStr(p.address,8),26)+p.name);
  104. end;
  105. end.
  106. {
  107. $Log$
  108. Revision 1.2 2003-04-22 14:33:38 peter
  109. * removed some notes/hints
  110. Revision 1.1 2002/07/01 18:46:24 peter
  111. * internal linker
  112. * reorganized aasm layer
  113. }