1*fae548d3Szrj // mapfile.h -- map file generation for gold -*- C++ -*- 2*fae548d3Szrj 3*fae548d3Szrj // Copyright (C) 2008-2020 Free Software Foundation, Inc. 4*fae548d3Szrj // Written by Ian Lance Taylor <iant@google.com>. 5*fae548d3Szrj 6*fae548d3Szrj // This file is part of gold. 7*fae548d3Szrj 8*fae548d3Szrj // This program is free software; you can redistribute it and/or modify 9*fae548d3Szrj // it under the terms of the GNU General Public License as published by 10*fae548d3Szrj // the Free Software Foundation; either version 3 of the License, or 11*fae548d3Szrj // (at your option) any later version. 12*fae548d3Szrj 13*fae548d3Szrj // This program is distributed in the hope that it will be useful, 14*fae548d3Szrj // but WITHOUT ANY WARRANTY; without even the implied warranty of 15*fae548d3Szrj // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16*fae548d3Szrj // GNU General Public License for more details. 17*fae548d3Szrj 18*fae548d3Szrj // You should have received a copy of the GNU General Public License 19*fae548d3Szrj // along with this program; if not, write to the Free Software 20*fae548d3Szrj // Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, 21*fae548d3Szrj // MA 02110-1301, USA. 22*fae548d3Szrj 23*fae548d3Szrj #ifndef GOLD_MAP_H 24*fae548d3Szrj #define GOLD_MAP_H 25*fae548d3Szrj 26*fae548d3Szrj #include <cstdio> 27*fae548d3Szrj #include <string> 28*fae548d3Szrj 29*fae548d3Szrj namespace gold 30*fae548d3Szrj { 31*fae548d3Szrj 32*fae548d3Szrj class Archive; 33*fae548d3Szrj class Symbol; 34*fae548d3Szrj class Relobj; 35*fae548d3Szrj template<int size, bool big_endian> 36*fae548d3Szrj class Sized_relobj_file; 37*fae548d3Szrj class Output_section; 38*fae548d3Szrj class Output_data; 39*fae548d3Szrj 40*fae548d3Szrj // This class manages map file output. 41*fae548d3Szrj 42*fae548d3Szrj class Mapfile 43*fae548d3Szrj { 44*fae548d3Szrj public: 45*fae548d3Szrj Mapfile(); 46*fae548d3Szrj 47*fae548d3Szrj ~Mapfile(); 48*fae548d3Szrj 49*fae548d3Szrj // Open the map file. Return whether the open succeed. 50*fae548d3Szrj bool 51*fae548d3Szrj open(const char* map_filename); 52*fae548d3Szrj 53*fae548d3Szrj // Close the map file. 54*fae548d3Szrj void 55*fae548d3Szrj close(); 56*fae548d3Szrj 57*fae548d3Szrj // Return the underlying file. 58*fae548d3Szrj FILE* file()59*fae548d3Szrj file() 60*fae548d3Szrj { return this->map_file_; } 61*fae548d3Szrj 62*fae548d3Szrj // Report that we are including a member from an archive. This is 63*fae548d3Szrj // called by the archive reading code. 64*fae548d3Szrj void 65*fae548d3Szrj report_include_archive_member(const std::string& member_name, 66*fae548d3Szrj const Symbol* sym, const char* why); 67*fae548d3Szrj 68*fae548d3Szrj // Report allocating a common symbol. 69*fae548d3Szrj void 70*fae548d3Szrj report_allocate_common(const Symbol*, uint64_t symsize); 71*fae548d3Szrj 72*fae548d3Szrj // Print discarded input sections. 73*fae548d3Szrj void 74*fae548d3Szrj print_discarded_sections(const Input_objects*); 75*fae548d3Szrj 76*fae548d3Szrj // Print an output section. 77*fae548d3Szrj void 78*fae548d3Szrj print_output_section(const Output_section*); 79*fae548d3Szrj 80*fae548d3Szrj // Print an input section. 81*fae548d3Szrj void 82*fae548d3Szrj print_input_section(Relobj*, unsigned int shndx); 83*fae548d3Szrj 84*fae548d3Szrj // Print an Output_data. 85*fae548d3Szrj void 86*fae548d3Szrj print_output_data(const Output_data*, const char* name); 87*fae548d3Szrj 88*fae548d3Szrj private: 89*fae548d3Szrj // The space we allow for a section name. 90*fae548d3Szrj static const size_t section_name_map_length; 91*fae548d3Szrj 92*fae548d3Szrj // Advance to a column. 93*fae548d3Szrj void 94*fae548d3Szrj advance_to_column(size_t from, size_t to); 95*fae548d3Szrj 96*fae548d3Szrj // Print the memory map header. 97*fae548d3Szrj void 98*fae548d3Szrj print_memory_map_header(); 99*fae548d3Szrj 100*fae548d3Szrj // Print symbols for an input section. 101*fae548d3Szrj template<int size, bool big_endian> 102*fae548d3Szrj void 103*fae548d3Szrj print_input_section_symbols(const Sized_relobj_file<size, big_endian>*, 104*fae548d3Szrj unsigned int shndx); 105*fae548d3Szrj 106*fae548d3Szrj // Map file to write to. 107*fae548d3Szrj FILE* map_file_; 108*fae548d3Szrj // Whether we have printed the archive member header. 109*fae548d3Szrj bool printed_archive_header_; 110*fae548d3Szrj // Whether we have printed the allocated common header. 111*fae548d3Szrj bool printed_common_header_; 112*fae548d3Szrj // Whether we have printed the memory map header. 113*fae548d3Szrj bool printed_memory_map_header_; 114*fae548d3Szrj }; 115*fae548d3Szrj 116*fae548d3Szrj } // End namespace gold. 117*fae548d3Szrj 118*fae548d3Szrj #endif // !defined(GOLD_MAP_H) 119