diff options
author | Ian Lance Taylor <ian@airs.com> | 2008-03-28 22:42:34 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@airs.com> | 2008-03-28 22:42:34 +0000 |
commit | 2fd322316ec7699c44d24b1c465c80ada336754d (patch) | |
tree | 9f4f290c5d9e5efe79544cfaf10a3c62f63b83d3 /gold/output.h | |
parent | 2460c166aeb65cd1664234dfebbd779c77ee2956 (diff) | |
download | gdb-2fd322316ec7699c44d24b1c465c80ada336754d.zip gdb-2fd322316ec7699c44d24b1c465c80ada336754d.tar.gz gdb-2fd322316ec7699c44d24b1c465c80ada336754d.tar.bz2 |
* layout.cc (Layout::layout): If we see an input section with a
name that needs sorting, set the must_sort flag for the output
section.
(Layout::make_output_section): If the name of the output section
indicates that it might require sorting, set the may_sort flag.
* output.h (Output_section::may_sort_attached_input_sections): New
function.
(Output_section::set_may_sort_attached_input_sections): New
function.
(Output_section::must_sort_attached_input_sections): New
function.
(Output_section::set_must_sort_attached_input_sections): New
function.
(class Output_section): Declare Input_section_sort_entry. Define
Input_section_sort_compare. Declare
sort_attached_input_sections. Add new fields:
may_sort_attached_input_sections_,
must_sort_attached_input_sections_,
attached_input_sections_are_sorted_.
* output.cc (Output_section::Output_section): Initialize new
fields.
(Output_section::add_input_section): Add an entry to
input_sections_ if may_sort or must_sort are true.
(Output_section::set_final_data_size): Call
sort_attached_input_sections if necessary.
(Output_section::Input_section_sort_entry): Define new class.
(Output_section::Input_section_sort_compare::operator()): New
function.
(Output_section::sort_attached_input_sections): New function.
* configure.ac: Check whether the compiler supports constructor
priorities. Define a CONSTRUCTOR_PRIORITY automake conditional.
* testsuite/initpri1.c: New file.
* testsuite/Makefile.am (check_PROGRAMS): Add initpri1 if
CONSTRUCTOR_PRIORITY.
(initpri1_SOURCES, initpri1_DEPENDENCIES): New variables.
(initpri1_LDFLAGS): New variable.
* configure, Makefile.in, testsuite/Makefile.in: Rebuild.
Diffstat (limited to 'gold/output.h')
-rw-r--r-- | gold/output.h | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/gold/output.h b/gold/output.h index 2b864f3..5a95748 100644 --- a/gold/output.h +++ b/gold/output.h @@ -1869,6 +1869,32 @@ class Output_section : public Output_data this->dynsym_index_ = index; } + // Return whether the input sections sections attachd to this output + // section may require sorting. This is used to handle constructor + // priorities compatibly with GNU ld. + bool + may_sort_attached_input_sections() const + { return this->may_sort_attached_input_sections_; } + + // Record that the input sections attached to this output section + // may require sorting. + void + set_may_sort_attached_input_sections() + { this->may_sort_attached_input_sections_ = true; } + + // Return whether the input sections attached to this output section + // require sorting. This is used to handle constructor priorities + // compatibly with GNU ld. + bool + must_sort_attached_input_sections() const + { return this->must_sort_attached_input_sections_; } + + // Record that the input sections attached to this output section + // require sorting. + void + set_must_sort_attached_input_sections() + { this->must_sort_attached_input_sections_ = true; } + // Return whether this section should be written after all the input // sections are complete. bool @@ -2310,6 +2336,17 @@ class Output_section : public Output_data typedef std::vector<Input_section> Input_section_list; + // This class is used to sort the input sections. + class Input_section_sort_entry; + + // This is the sort comparison function. + struct Input_section_sort_compare + { + bool + operator()(const Input_section_sort_entry&, + const Input_section_sort_entry&) const; + }; + // Fill data. This is used to fill in data between input sections. // It is also used for data statements (BYTE, WORD, etc.) in linker // scripts. When we have to keep track of the input sections, we @@ -2360,6 +2397,10 @@ class Output_section : public Output_data add_output_merge_section(Output_section_data* posd, bool is_string, uint64_t entsize); + // Sort the attached input sections. + void + sort_attached_input_sections(); + // Most of these fields are only valid after layout. // The name of the section. This will point into a Stringpool. @@ -2443,6 +2484,15 @@ class Output_section : public Output_data // section, false if it means the symbol index of the corresponding // section symbol. bool info_uses_section_index_ : 1; + // True if the input sections attached to this output section may + // need sorting. + bool may_sort_attached_input_sections_ : 1; + // True if the input sections attached to this output section must + // be sorted. + bool must_sort_attached_input_sections_ : 1; + // True if the input sections attached to this output section have + // already been sorted. + bool attached_input_sections_are_sorted_ : 1; // For SHT_TLS sections, the offset of this section relative to the base // of the TLS segment. uint64_t tls_offset_; |