gas/
[binutils.git] / gold / compressed_output.h
blob11b2762288f58b09b69b6de81ba7686a3657f250
1 // compressed_output.h -- compressed output sections for gold -*- C++ -*-
3 // Copyright 2007, 2008 Free Software Foundation, Inc.
4 // Written by Ian Lance Taylor <iant@google.com>.
6 // This file is part of gold.
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.
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.
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.
23 // We support compressing .debug_* sections on output. (And,
24 // potentially one day, other sections.) This is a form of
25 // relaxation. This file adds support for merging and emitting the
26 // compressed sections.
28 #ifndef GOLD_COMPRESSED_OUTPUT_H
29 #define GOLD_COMPRESSED_OUTPUT_H
31 #include <string>
33 #include "output.h"
35 namespace gold
38 class General_options;
40 // This is used for a section whose data should be compressed. It is
41 // a regular Output_section which computes its contents into a buffer
42 // and then postprocesses it.
44 class Output_compressed_section : public Output_section
46 public:
47 Output_compressed_section(const General_options* options,
48 const char* name, elfcpp::Elf_Word flags,
49 elfcpp::Elf_Xword type)
50 : Output_section(name, flags, type),
51 options_(options)
52 { this->set_requires_postprocessing(); }
54 protected:
55 // Set the final data size.
56 void
57 set_final_data_size();
59 // Write out the compressed contents.
60 void
61 do_write(Output_file*);
63 private:
64 // The options--this includes the compression type.
65 const General_options* options_;
66 // The compressed data.
67 unsigned char* data_;
68 // The new section name if we do compress.
69 std::string new_section_name_;
72 } // End namespace gold.
74 #endif // !defined(GOLD_COMPRESSED_OUTPUT_H)