mapfile.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. // mapfile.h -- map file generation for gold -*- C++ -*-
  2. // Copyright (C) 2008-2015 Free Software Foundation, Inc.
  3. // Written by Ian Lance Taylor <iant@google.com>.
  4. // This file is part of gold.
  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 3 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., 51 Franklin Street - Fifth Floor, Boston,
  16. // MA 02110-1301, USA.
  17. #ifndef GOLD_MAP_H
  18. #define GOLD_MAP_H
  19. #include <cstdio>
  20. #include <string>
  21. namespace gold
  22. {
  23. class Archive;
  24. class Symbol;
  25. class Relobj;
  26. template<int size, bool big_endian>
  27. class Sized_relobj_file;
  28. class Output_section;
  29. class Output_data;
  30. // This class manages map file output.
  31. class Mapfile
  32. {
  33. public:
  34. Mapfile();
  35. ~Mapfile();
  36. // Open the map file. Return whether the open succeed.
  37. bool
  38. open(const char* map_filename);
  39. // Close the map file.
  40. void
  41. close();
  42. // Return the underlying file.
  43. FILE*
  44. file()
  45. { return this->map_file_; }
  46. // Report that we are including a member from an archive. This is
  47. // called by the archive reading code.
  48. void
  49. report_include_archive_member(const std::string& member_name,
  50. const Symbol* sym, const char* why);
  51. // Report allocating a common symbol.
  52. void
  53. report_allocate_common(const Symbol*, uint64_t symsize);
  54. // Print discarded input sections.
  55. void
  56. print_discarded_sections(const Input_objects*);
  57. // Print an output section.
  58. void
  59. print_output_section(const Output_section*);
  60. // Print an input section.
  61. void
  62. print_input_section(Relobj*, unsigned int shndx);
  63. // Print an Output_data.
  64. void
  65. print_output_data(const Output_data*, const char* name);
  66. private:
  67. // The space we allow for a section name.
  68. static const size_t section_name_map_length;
  69. // Advance to a column.
  70. void
  71. advance_to_column(size_t from, size_t to);
  72. // Print the memory map header.
  73. void
  74. print_memory_map_header();
  75. // Print symbols for an input section.
  76. template<int size, bool big_endian>
  77. void
  78. print_input_section_symbols(const Sized_relobj_file<size, big_endian>*,
  79. unsigned int shndx);
  80. // Map file to write to.
  81. FILE* map_file_;
  82. // Whether we have printed the archive member header.
  83. bool printed_archive_header_;
  84. // Whether we have printed the allocated common header.
  85. bool printed_common_header_;
  86. // Whether we have printed the memory map header.
  87. bool printed_memory_map_header_;
  88. };
  89. } // End namespace gold.
  90. #endif // !defined(GOLD_MAP_H)