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