[GOLD] PowerPC64 identical code folding

Alan Modra amodra@gmail.com
Thu Mar 14 07:25:00 GMT 2013


On Thu, Mar 14, 2013 at 05:22:15PM +1030, Alan Modra wrote:
> On Tue, Mar 12, 2013 at 10:50:29AM +1030, Alan Modra wrote:
> > 	* gc.h (gc_process_relocs): Look through function descriptors
> > 	to determine shndx, symvalue and addend used by ICF.  Tidy
> > 	variable duplication.
> 
> On testing this with more than the gold testsuite, I discovered that
> --icf on PowerPC64 is quite broken.  We can't call function_location()
> for a symbol defined in some object for which do_read_relocs() hasn't
> been called;  The .opd info for that object isn't yet set up.
> 
> It looks like I'll need to translate shndx, symvalue and addend in
> icf.cc.

Like this.  OK to apply?

	* gc.h (gc_process_relocs): Don't look through function descriptors.
	* icf.cc (get_section_contents): Do so here instead.

Index: gold/gc.h
===================================================================
RCS file: /cvs/src/src/gold/gc.h,v
retrieving revision 1.18
diff -u -p -r1.18 gc.h
--- gold/gc.h	12 Mar 2013 00:42:14 -0000	1.18
+++ gold/gc.h	14 Mar 2013 07:12:04 -0000
@@ -253,21 +253,7 @@ gc_process_relocs(
             {
 	      Address symvalue = dst_off - addend;
 	      if (is_ordinary) 
-		{
-		  Symbol_location loc;
-		  loc.object = dst_obj;
-		  loc.shndx = dst_indx;
-		  loc.offset = convert_types<off_t, Address>(dst_off);
-		  // Look through function descriptors.
-		  parameters->target().function_location(&loc);
-		  if (loc.shndx != dst_indx)
-		    {
-		      // Modify symvalue/addend to the code entry.
-		      symvalue = loc.offset;
-		      addend = 0;
-		    }
-		  (*secvec).push_back(Section_id(loc.object, loc.shndx));
-		}
+		(*secvec).push_back(Section_id(dst_obj, dst_indx));
 	      else
                 (*secvec).push_back(Section_id(NULL, 0));
               (*symvec).push_back(NULL);
@@ -343,21 +329,7 @@ gc_process_relocs(
             {
 	      Address symvalue = dst_off - addend;
               if (is_ordinary && gsym->source() == Symbol::FROM_OBJECT)
-		{
-		  Symbol_location loc;
-		  loc.object = dst_obj;
-		  loc.shndx = dst_indx;
-		  loc.offset = convert_types<off_t, Address>(dst_off);
-		  // Look through function descriptors.
-		  parameters->target().function_location(&loc);
-		  if (loc.shndx != dst_indx)
-		    {
-		      // Modify symvalue/addend to the code entry.
-		      symvalue = loc.offset;
-		      addend = 0;
-		    }
-		  (*secvec).push_back(Section_id(loc.object, loc.shndx));
-		}
+		(*secvec).push_back(Section_id(dst_obj, dst_indx));
 	      else
                 (*secvec).push_back(Section_id(NULL, 0));
               (*symvec).push_back(gsym);
Index: gold/icf.cc
===================================================================
RCS file: /cvs/src/src/gold/icf.cc,v
retrieving revision 1.20
diff -u -p -r1.20 icf.cc
--- gold/icf.cc	28 Jun 2011 21:15:42 -0000	1.20
+++ gold/icf.cc	14 Mar 2013 07:12:04 -0000
@@ -288,6 +288,25 @@ get_section_contents(bool first_iteratio
 
       for (; it_v != v.end(); ++it_v, ++it_s, ++it_a, ++it_o, ++it_addend_size)
         {
+	  if (first_iteration
+	      && it_v->first != NULL)
+	    {
+	      Symbol_location loc;
+	      loc.object = it_v->first;
+	      loc.shndx = it_v->second;
+	      loc.offset = convert_types<off_t, long long>(it_a->first
+							   + it_a->second);
+	      // Look through function descriptors
+	      parameters->target().function_location(&loc);
+	      if (loc.shndx != it_v->second)
+		{
+		  it_v->second = loc.shndx;
+		  // Modify symvalue/addend to the code entry.
+		  it_a->first = loc.offset;
+		  it_a->second = 0;
+		}
+	    }
+
           // ADDEND_STR stores the symbol value and addend and offset,
           // each at most 16 hex digits long.  it_a points to a pair
           // where first is the symbol value and second is the

-- 
Alan Modra
Australia Development Lab, IBM



More information about the Binutils mailing list