diff options
author | Sriraman Tallam <tmsriram@google.com> | 2011-02-02 21:55:29 +0000 |
---|---|---|
committer | Sriraman Tallam <tmsriram@google.com> | 2011-02-02 21:55:29 +0000 |
commit | 4e271fffeca9db3e0eea8d57b98aa7130f941225 (patch) | |
tree | 6fc646675e808e481b0f3e5bf85495fc68d6fe3a | |
parent | e0634ccfe8718b76b5e77c983a3cebfa7707747a (diff) | |
download | gdb-4e271fffeca9db3e0eea8d57b98aa7130f941225.zip gdb-4e271fffeca9db3e0eea8d57b98aa7130f941225.tar.gz gdb-4e271fffeca9db3e0eea8d57b98aa7130f941225.tar.bz2 |
2011-02-02 Sriraman Tallam <tmsriram@google.com>
* icf.h (is_section_foldable_candidate): Change type of parameter
to std::string.
* icf.cc (Icf::find_identical_sections): Change type of local variable
section_name to be std::string.
(is_function_ctor_or_dtor): Change type of parameter to std::string.
-rw-r--r-- | gold/ChangeLog | 8 | ||||
-rw-r--r-- | gold/icf.cc | 21 | ||||
-rw-r--r-- | gold/icf.h | 7 |
3 files changed, 22 insertions, 14 deletions
diff --git a/gold/ChangeLog b/gold/ChangeLog index 8974f8c..e09ed79 100644 --- a/gold/ChangeLog +++ b/gold/ChangeLog @@ -1,3 +1,11 @@ +2011-02-02 Sriraman Tallam <tmsriram@google.com> + + * icf.h (is_section_foldable_candidate): Change type of parameter + to std::string. + * icf.cc (Icf::find_identical_sections): Change type of local variable + section_name to be std::string. + (is_function_ctor_or_dtor): Change type of parameter to std::string. + 2011-01-25 Ian Lance Taylor <iant@google.com> * script.cc (script_add_extern): Rewrite to use diff --git a/gold/icf.cc b/gold/icf.cc index 13e8374..09dcba6 100644 --- a/gold/icf.cc +++ b/gold/icf.cc @@ -652,16 +652,17 @@ match_sections(unsigned int iteration_num, } // During safe icf (--icf=safe), only fold functions that are ctors or dtors. -// This function returns true if the mangled function name is a ctor or a -// dtor. +// This function returns true if the section name is that of a ctor or a dtor. static bool -is_function_ctor_or_dtor(const char* mangled_func_name) +is_function_ctor_or_dtor(const std::string& section_name) { - if ((is_prefix_of("_ZN", mangled_func_name) - || is_prefix_of("_ZZ", mangled_func_name)) - && (is_gnu_v3_mangled_ctor(mangled_func_name) - || is_gnu_v3_mangled_dtor(mangled_func_name))) + const char* mangled_func_name = strrchr(section_name.c_str(), '.'); + gold_assert(mangled_func_name != NULL); + if ((is_prefix_of("._ZN", mangled_func_name) + || is_prefix_of("._ZZ", mangled_func_name)) + && (is_gnu_v3_mangled_ctor(mangled_func_name + 1) + || is_gnu_v3_mangled_dtor(mangled_func_name + 1))) { return true; } @@ -696,7 +697,7 @@ Icf::find_identical_sections(const Input_objects* input_objects, for (unsigned int i = 0;i < (*p)->shnum(); ++i) { - const char* section_name = (*p)->section_name(i).c_str(); + const std::string section_name = (*p)->section_name(i); if (!is_section_foldable_candidate(section_name)) continue; if (!(*p)->is_section_included(i)) @@ -704,13 +705,11 @@ Icf::find_identical_sections(const Input_objects* input_objects, if (parameters->options().gc_sections() && symtab->gc()->is_section_garbage(*p, i)) continue; - const char* mangled_func_name = strrchr(section_name, '.'); - gold_assert(mangled_func_name != NULL); // With --icf=safe, check if the mangled function name is a ctor // or a dtor. The mangled function name can be obtained from the // section name by stripping the section prefix. if (parameters->options().icf_safe_folding() - && !is_function_ctor_or_dtor(mangled_func_name + 1) + && !is_function_ctor_or_dtor(section_name) && (!target.can_check_for_function_pointers() || section_has_function_pointers(*p, i))) { @@ -168,10 +168,11 @@ class Icf // earlier gcc versions, like 4.0.3, put constructors and destructors in // .gnu.linkonce.t sections and hence should be included too. inline bool -is_section_foldable_candidate(const char* section_name) +is_section_foldable_candidate(const std::string& section_name) { - return (is_prefix_of(".text", section_name) - || is_prefix_of(".gnu.linkonce.t", section_name)); + const char* section_name_cstr = section_name.c_str(); + return (is_prefix_of(".text", section_name_cstr) + || is_prefix_of(".gnu.linkonce.t", section_name_cstr)); } } // End of namespace gold. |