Backport upstream fix to disable inlining of merge sections in ICF for
ARM back end.

Change-Id: If59807eea3b016308bdcd70153c0a84d9dc265ac
http://sourceware.org/ml/binutils/2010-09/msg00492.html
diff --git a/binutils-2.19/README.android b/binutils-2.19/README.android
index 93ea299..5c04089 100644
--- a/binutils-2.19/README.android
+++ b/binutils-2.19/README.android
@@ -1,3 +1,17 @@
+2010-09-28  Sriraman Tallam  <[email protected]>
+
+	Backport upstream fix to disable inlining of merge section in ICF for
+	ARM back end.
+
+	http://sourceware.org/ml/binutils/2010-09/msg00492.html
+
+	Changed files:
+
+	gold/target.h
+	gold/i386.cc
+	gold/x86_64.cc
+	gold/icf.cc
+
 2010-09-17  Doug Kwan  <[email protected]>
 
 	Backport upstream fix for mis-handling of GOT-using relocations
diff --git a/binutils-2.19/gold/i386.cc b/binutils-2.19/gold/i386.cc
index bb1de1c..3796b94 100644
--- a/binutils-2.19/gold/i386.cc
+++ b/binutils-2.19/gold/i386.cc
@@ -69,6 +69,10 @@
   can_check_for_function_pointers() const
   { return true; }
 
+  virtual bool
+  can_icf_inline_merge_sections () const
+  { return true; }
+
   // Process the relocations to determine unreferenced sections for 
   // garbage collection.
   void
diff --git a/binutils-2.19/gold/icf.cc b/binutils-2.19/gold/icf.cc
index 31312bb..09cb1d4 100644
--- a/binutils-2.19/gold/icf.cc
+++ b/binutils-2.19/gold/icf.cc
@@ -366,7 +366,8 @@
               uint64_t secn_flags = (it_v->first)->section_flags(it_v->second);
               // This reloc points to a merge section.  Hash the
               // contents of this section.
-              if ((secn_flags & elfcpp::SHF_MERGE) != 0)
+              if ((secn_flags & elfcpp::SHF_MERGE) != 0
+		  && parameters->target().can_icf_inline_merge_sections ())
                 {
                   uint64_t entsize =
                     (it_v->first)->section_entsize(it_v->second);
diff --git a/binutils-2.19/gold/target.h b/binutils-2.19/gold/target.h
index 563a365..48b11b2 100644
--- a/binutils-2.19/gold/target.h
+++ b/binutils-2.19/gold/target.h
@@ -71,6 +71,13 @@
   can_check_for_function_pointers() const
   { return false; }
 
+  // This function is used in ICF (icf.cc).  This is set to true by
+  // the target if a relocation to a merged section can be processed
+  // to retrieve the contents of the merged section.
+  virtual bool
+  can_icf_inline_merge_sections () const
+  { return false; }
+
   // Whether a section called SECTION_NAME may have function pointers to
   // sections not eligible for safe ICF folding.
   virtual bool
diff --git a/binutils-2.19/gold/x86_64.cc b/binutils-2.19/gold/x86_64.cc
index 61299c2..dcd6c46 100644
--- a/binutils-2.19/gold/x86_64.cc
+++ b/binutils-2.19/gold/x86_64.cc
@@ -81,6 +81,10 @@
   can_check_for_function_pointers() const
   { return !parameters->options().pie(); }
 
+  virtual bool
+  can_icf_inline_merge_sections () const
+  { return true; }
+
   // Hook for a new output section.
   void
   do_new_output_section(Output_section*) const;