diff options
author | Joshua Oreman <oremanj@hudson-trading.com> | 2019-05-11 07:27:10 +0800 |
---|---|---|
committer | Cary Coutant <ccoutant@gmail.com> | 2019-05-11 07:27:10 +0800 |
commit | e173ea00c2941af42ea4e2267446d6039a70da6e (patch) | |
tree | c4e71d797a234be5ce51cc9e18c3d922384e7a7e /gold/icf.h | |
parent | 1367480341749b1498a6c5e7a7b79c7a4ab4ed34 (diff) | |
download | gdb-e173ea00c2941af42ea4e2267446d6039a70da6e.zip gdb-e173ea00c2941af42ea4e2267446d6039a70da6e.tar.gz gdb-e173ea00c2941af42ea4e2267446d6039a70da6e.tar.bz2 |
Fix problem with ICF where diffs in EH frame info is ignored.
PR gold/21066
* gc.h (gc_process_relocs): Track relocations in .eh_frame sections
when ICF is enabled, even though the .eh_frame sections themselves
are not foldable.
* icf.cc (get_section_contents): Change arguments to permit operation
on just part of a section. Include extra identity regions in the
referring section's contents recursively.
(match_sections): Lock object here instead of in get_section_contents
so that get_section_contents can operate recursively.
(Icf::add_ehframe_links): New method.
(Icf::find_identical_sections): Pass .eh_frame sections to
add_ehframe_links(). Increase default iteration count from 2 to 3
because handling exception info typically requires one extra iteration.
* icf.h (Icf::extra_identity_list_): New data member with accessor.
(is_section_foldable_candidate): Include .gcc_except_table sections.
* options.h: Update documentation for new default ICF iteration count.
* testsuite/Makefile.am (icf_test_pr21066): New test case.
* testsuite/Makefile.in: Regenerate.
* testsuite/icf_test_pr21066.cc: New source file.
* testsuite/icf_test_pr21066.sh: New test script.
Diffstat (limited to 'gold/icf.h')
-rw-r--r-- | gold/icf.h | 30 |
1 files changed, 30 insertions, 0 deletions
@@ -64,6 +64,19 @@ class Icf typedef Unordered_map<Section_id, Reloc_info, Section_id_hash> Reloc_info_list; + // A region of some other section that should be considered part of + // a section for ICF purposes. This is used to avoid folding sections + // that have identical text and relocations but different .eh_frame + // information. + typedef struct + { + Section_id section; + section_offset_type offset; + section_size_type length; + } Extra_identity_info; + + typedef std::multimap<Section_id, Extra_identity_info> Extra_identity_list; + Icf() : id_section_(), section_id_(), kept_section_id_(), fptr_section_id_(), @@ -137,6 +150,12 @@ class Icf reloc_info_list() { return this->reloc_info_list_; } + // Returns a map from section to region of a different section that should + // be considered part of the key section for ICF purposes. + Extra_identity_list& + extra_identity_list() + { return this->extra_identity_list_; } + // Returns a mapping of each section to a unique integer. Uniq_secn_id_map& section_to_int_map() @@ -144,6 +163,10 @@ class Icf private: + bool + add_ehframe_links(Relobj* object, unsigned int ehframe_shndx, + Reloc_info& ehframe_relocs); + // Maps integers to sections. std::vector<Section_id> id_section_; // Does the reverse. @@ -160,17 +183,24 @@ class Icf bool icf_ready_; // This list is populated by gc_process_relocs in gc.h. Reloc_info_list reloc_info_list_; + // Regions of other sections that should be considered part of + // each section for ICF purposes. + Extra_identity_list extra_identity_list_; }; // This function returns true if this section corresponds to a function that // should be considered by icf as a possible candidate for folding. Some // earlier gcc versions, like 4.0.3, put constructors and destructors in // .gnu.linkonce.t sections and hence should be included too. +// The mechanism used to safely fold functions referenced by .eh_frame +// requires folding .gcc_except_table sections as well; see "Notes regarding +// C++ exception handling" at the top of icf.cc for an explanation why. inline bool is_section_foldable_candidate(const std::string& section_name) { const char* section_name_cstr = section_name.c_str(); return (is_prefix_of(".text", section_name_cstr) + || is_prefix_of(".gcc_except_table", section_name_cstr) || is_prefix_of(".gnu.linkonce.t", section_name_cstr)); } |