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