aboutsummaryrefslogtreecommitdiff
path: root/gold/icf.cc
diff options
context:
space:
mode:
authorSriraman Tallam <tmsriram@google.com>2009-08-12 19:03:16 +0000
committerSriraman Tallam <tmsriram@google.com>2009-08-12 19:03:16 +0000
commit48c187ced8fcf0c09c26ab1782e63752bf206b4e (patch)
tree139f6a887edb3544c108164fee359016f5a5a48f /gold/icf.cc
parent645afe0c5b028b013231f5890f66376e4dfc811d (diff)
downloadgdb-48c187ced8fcf0c09c26ab1782e63752bf206b4e.zip
gdb-48c187ced8fcf0c09c26ab1782e63752bf206b4e.tar.gz
gdb-48c187ced8fcf0c09c26ab1782e63752bf206b4e.tar.bz2
Sriraman Tallam <tmsriram@google.com>
* icf.cc (Icf::find_identical_sections): Unfold symbols that have been maked as --keep-unique. (Icf::unfold_section): New function. * icf.h (Icf::unfold_section): New function. * options.h (General_options::keep_unique): New option. * testsuite/Makefile.am: Add commands to build icf_keep_unique_test. * testsuite/Makefile.in: Regenerate. * testsuite/icf_keep_unique_test.sh: New file. * testsuite/icf_keep_unique_test.cc: New file.
Diffstat (limited to 'gold/icf.cc')
-rw-r--r--gold/icf.cc38
1 files changed, 38 insertions, 0 deletions
diff --git a/gold/icf.cc b/gold/icf.cc
index 55d8ea4..6f95922 100644
--- a/gold/icf.cc
+++ b/gold/icf.cc
@@ -598,9 +598,47 @@ Icf::find_identical_sections(const Input_objects* input_objects,
program_name, num_iterations);
}
+ // Unfold --keep-unique symbols.
+ for (options::String_set::const_iterator p =
+ parameters->options().keep_unique_begin();
+ p != parameters->options().keep_unique_end();
+ ++p)
+ {
+ const char* name = p->c_str();
+ Symbol* sym = symtab->lookup(name);
+ if (sym != NULL
+ && sym->source() == Symbol::FROM_OBJECT
+ && !sym->object()->is_dynamic())
+ {
+ Object* obj = sym->object();
+ bool is_ordinary;
+ unsigned int shndx = sym->shndx(&is_ordinary);
+ if (is_ordinary)
+ {
+ this->unfold_section(obj, shndx);
+ }
+ }
+
+ }
+
this->icf_ready();
}
+// Unfolds the section denoted by OBJ and SHNDX if folded.
+
+void
+Icf::unfold_section(Object* obj, unsigned int shndx)
+{
+ Section_id secn(obj, shndx);
+ Uniq_secn_id_map::iterator it = this->section_id_.find(secn);
+ if (it == this->section_id_.end())
+ return;
+ unsigned int section_num = it->second;
+ unsigned int kept_section_id = this->kept_section_id_[section_num];
+ if (kept_section_id != section_num)
+ this->kept_section_id_[section_num] = section_num;
+}
+
// This function determines if the section corresponding to the
// given object and index is folded based on if the kept section
// is different from this section.