1a405f
diff -rup ../binutils-2.27/gold/aarch64.cc gold/aarch64.cc
1a405f
--- ../binutils-2.27/gold/aarch64.cc	2016-09-26 11:22:18.728811436 +0100
1a405f
+++ gold/aarch64.cc	2016-11-03 15:05:31.000000000 +0000
1a405f
@@ -6026,6 +6026,23 @@ Target_aarch64<size, big_endian>::Scan::
1a405f
       }
1a405f
       break;
1a405f
 
1a405f
+    case elfcpp::R_AARCH64_MOVW_UABS_G0:        // 263
1a405f
+    case elfcpp::R_AARCH64_MOVW_UABS_G0_NC:     // 264
1a405f
+    case elfcpp::R_AARCH64_MOVW_UABS_G1:        // 265
1a405f
+    case elfcpp::R_AARCH64_MOVW_UABS_G1_NC:     // 266
1a405f
+    case elfcpp::R_AARCH64_MOVW_UABS_G2:        // 267
1a405f
+    case elfcpp::R_AARCH64_MOVW_UABS_G2_NC:     // 268
1a405f
+    case elfcpp::R_AARCH64_MOVW_UABS_G3:        // 269
1a405f
+    case elfcpp::R_AARCH64_MOVW_SABS_G0:        // 270
1a405f
+    case elfcpp::R_AARCH64_MOVW_SABS_G1:        // 271
1a405f
+    case elfcpp::R_AARCH64_MOVW_SABS_G2:        // 272
1a405f
+      if (parameters->options().output_is_position_independent())
1a405f
+	{
1a405f
+	  gold_error(_("%s: unsupported reloc %u in pos independent link."),
1a405f
+		     object->name().c_str(), r_type);
1a405f
+	}
1a405f
+      break;
1a405f
+
1a405f
     case elfcpp::R_AARCH64_LD_PREL_LO19:        // 273
1a405f
     case elfcpp::R_AARCH64_ADR_PREL_LO21:       // 274
1a405f
     case elfcpp::R_AARCH64_ADR_PREL_PG_HI21:    // 275
1a405f
@@ -6311,6 +6328,23 @@ Target_aarch64<size, big_endian>::Scan::
1a405f
 	}
1a405f
       break;
1a405f
 
1a405f
+    case elfcpp::R_AARCH64_MOVW_UABS_G0:        // 263
1a405f
+    case elfcpp::R_AARCH64_MOVW_UABS_G0_NC:     // 264
1a405f
+    case elfcpp::R_AARCH64_MOVW_UABS_G1:        // 265
1a405f
+    case elfcpp::R_AARCH64_MOVW_UABS_G1_NC:     // 266
1a405f
+    case elfcpp::R_AARCH64_MOVW_UABS_G2:        // 267
1a405f
+    case elfcpp::R_AARCH64_MOVW_UABS_G2_NC:     // 268
1a405f
+    case elfcpp::R_AARCH64_MOVW_UABS_G3:        // 269
1a405f
+    case elfcpp::R_AARCH64_MOVW_SABS_G0:        // 270
1a405f
+    case elfcpp::R_AARCH64_MOVW_SABS_G1:        // 271
1a405f
+    case elfcpp::R_AARCH64_MOVW_SABS_G2:        // 272
1a405f
+      if (parameters->options().output_is_position_independent())
1a405f
+	{
1a405f
+	  gold_error(_("%s: unsupported reloc %u in pos independent link."),
1a405f
+		     object->name().c_str(), r_type);
1a405f
+	}
1a405f
+      break;
1a405f
+
1a405f
     case elfcpp::R_AARCH64_LD_PREL_LO19:        // 273
1a405f
     case elfcpp::R_AARCH64_ADR_PREL_LO21:       // 274
1a405f
     case elfcpp::R_AARCH64_ADR_PREL_PG_HI21:    // 275
1a405f
@@ -6993,6 +7027,23 @@ Target_aarch64<size, big_endian>::Reloca
1a405f
 	view, object, psymval, addend, address, reloc_property);
1a405f
       break;
1a405f
 
1a405f
+    case elfcpp::R_AARCH64_MOVW_UABS_G0:
1a405f
+    case elfcpp::R_AARCH64_MOVW_UABS_G0_NC:
1a405f
+    case elfcpp::R_AARCH64_MOVW_UABS_G1:
1a405f
+    case elfcpp::R_AARCH64_MOVW_UABS_G1_NC:
1a405f
+    case elfcpp::R_AARCH64_MOVW_UABS_G2:
1a405f
+    case elfcpp::R_AARCH64_MOVW_UABS_G2_NC:
1a405f
+    case elfcpp::R_AARCH64_MOVW_UABS_G3:
1a405f
+      reloc_status = Reloc::template rela_general<32>(
1a405f
+	view, object, psymval, addend, reloc_property);
1a405f
+      break;
1a405f
+    case elfcpp::R_AARCH64_MOVW_SABS_G0:
1a405f
+    case elfcpp::R_AARCH64_MOVW_SABS_G1:
1a405f
+    case elfcpp::R_AARCH64_MOVW_SABS_G2:
1a405f
+      reloc_status = Reloc::movnz(view, psymval->value(object, addend),
1a405f
+				  reloc_property);
1a405f
+      break;
1a405f
+
1a405f
     case elfcpp::R_AARCH64_LD_PREL_LO19:
1a405f
       reloc_status = Reloc::template pcrela_general<32>(
1a405f
 	  view, object, psymval, addend, address, reloc_property);
1a405f
@@ -8075,7 +8126,7 @@ Target_aarch64<size, big_endian>::is_err
1a405f
     typename elfcpp::Swap<32,big_endian>::Valtype insn2)
1a405f
 {
1a405f
   uint32_t rt;
1a405f
-  uint32_t rt2;
1a405f
+  uint32_t rt2 = 0;
1a405f
   uint32_t rn;
1a405f
   uint32_t rm;
1a405f
   uint32_t ra;
1a405f
diff -rup ../binutils-2.27/gold/aarch64-reloc.def gold/aarch64-reloc.def
1a405f
--- ../binutils-2.27/gold/aarch64-reloc.def	2016-08-03 08:36:53.000000000 +0100
1a405f
+++ gold/aarch64-reloc.def	2016-11-03 14:38:22.000000000 +0000
1a405f
@@ -43,6 +43,20 @@ ARD(PREL32                       , STATI
1a405f
 ARD(PREL16                       , STATIC ,  DATA       ,   Y,  -1,   15,16               ,    0,0  , Symbol::RELATIVE_REF ,                         DATA  )
1a405f
 // Above is from Table 4-6, Data relocations, 257-262.
1a405f
 
1a405f
+ARD(MOVW_UABS_G0                 , STATIC ,  AARCH64    ,   Y,   0,    0,16               ,    0,15 , Symbol::ABSOLUTE_REF ,                         MOVW  )
1a405f
+ARD(MOVW_UABS_G0_NC              , STATIC ,  AARCH64    ,   Y,   0,    0,0                ,    0,15 , Symbol::ABSOLUTE_REF ,                         MOVW  )
1a405f
+ARD(MOVW_UABS_G1                 , STATIC ,  AARCH64    ,   Y,   0,    0,32               ,   16,31 , Symbol::ABSOLUTE_REF ,                         MOVW  )
1a405f
+ARD(MOVW_UABS_G1_NC              , STATIC ,  AARCH64    ,   Y,   0,    0,0                ,   16,31 , Symbol::ABSOLUTE_REF ,                         MOVW  )
1a405f
+ARD(MOVW_UABS_G2                 , STATIC ,  AARCH64    ,   Y,   0,    0,48               ,   32,47 , Symbol::ABSOLUTE_REF ,                         MOVW  )
1a405f
+ARD(MOVW_UABS_G2_NC              , STATIC ,  AARCH64    ,   Y,   0,    0,0                ,   32,47 , Symbol::ABSOLUTE_REF ,                         MOVW  )
1a405f
+ARD(MOVW_UABS_G3                 , STATIC ,  AARCH64    ,   Y,   0,    0,0                ,   48,63 , Symbol::ABSOLUTE_REF ,                         MOVW  )
1a405f
+// Above is from Table 4-7, Group relocations to create a 16-, 32-, 48-, or 64-bit unsigned data value or address inline.
1a405f
+
1a405f
+ARD(MOVW_SABS_G0                 , STATIC ,  AARCH64    ,   Y,   0,   16,16               ,    0,15 , Symbol::ABSOLUTE_REF ,                         MOVW  )
1a405f
+ARD(MOVW_SABS_G1                 , STATIC ,  AARCH64    ,   Y,   0,   32,32               ,   16,31 , Symbol::ABSOLUTE_REF ,                         MOVW  )
1a405f
+ARD(MOVW_SABS_G2                 , STATIC ,  AARCH64    ,   Y,   0,   48,48               ,   32,47 , Symbol::ABSOLUTE_REF ,                         MOVW  )
1a405f
+// Above is from Table 4-8, Group relocations to create a 16, 32, 48, or 64 bit signed data or offset value inline.
1a405f
+
1a405f
 ARD(LD_PREL_LO19		 , STATIC ,  AARCH64    ,   Y,  -1,   20,20		  ,    2,20 , Symbol::RELATIVE_REF , 			     LDST  )
1a405f
 ARD(ADR_PREL_LO21		 , STATIC ,  AARCH64    ,   Y,  -1,   20,20		  ,    0,20 , Symbol::RELATIVE_REF , 			     ADR   )
1a405f
 ARD(ADR_PREL_PG_HI21             , STATIC ,  AARCH64    ,   Y,  -1,   32,32               ,   12,32 , Symbol::RELATIVE_REF ,                         ADRP  )
1a405f
diff -rup ../binutils-2.27/gold/aarch64-reloc-property.cc gold/aarch64-reloc-property.cc
1a405f
--- ../binutils-2.27/gold/aarch64-reloc-property.cc	2016-08-03 08:36:53.000000000 +0100
1a405f
+++ gold/aarch64-reloc-property.cc	2016-11-03 15:05:32.000000000 +0000
1a405f
@@ -59,17 +59,51 @@ template<>
1a405f
 bool
1a405f
 rvalue_checkup<0, 0>(int64_t) { return true; }
1a405f
 
1a405f
+namespace
1a405f
+{
1a405f
+
1a405f
 template<int L, int U>
1a405f
-uint64_t
1a405f
-rvalue_bit_select(uint64_t x)
1a405f
+class Rvalue_bit_select_impl
1a405f
 {
1a405f
-  if (U == 63) return x >> L;
1a405f
-  return (x & (((uint64_t)1 << (U+1)) - 1)) >> L;
1a405f
-}
1a405f
+public:
1a405f
+  static uint64_t
1a405f
+  calc(uint64_t x)
1a405f
+  {
1a405f
+    return (x & ((1ULL << (U+1)) - 1)) >> L;
1a405f
+  }
1a405f
+};
1a405f
+
1a405f
+template<int L>
1a405f
+class Rvalue_bit_select_impl<L, 63>
1a405f
+{
1a405f
+public:
1a405f
+  static uint64_t
1a405f
+  calc(uint64_t x)
1a405f
+  {
1a405f
+    return x >> L;
1a405f
+  }
1a405f
+};
1a405f
 
1a405f
+// By our convention, L=U=0 means that the whole value should be retrieved.
1a405f
 template<>
1a405f
+class Rvalue_bit_select_impl<0, 0>
1a405f
+{
1a405f
+public:
1a405f
+  static uint64_t
1a405f
+  calc(uint64_t x)
1a405f
+  {
1a405f
+    return x;
1a405f
+  }
1a405f
+};
1a405f
+
1a405f
+} // End anonymous namespace.
1a405f
+
1a405f
+template<int L, int U>
1a405f
 uint64_t
1a405f
-rvalue_bit_select<0, 0>(uint64_t x) { return x; }
1a405f
+rvalue_bit_select(uint64_t x)
1a405f
+{
1a405f
+  return Rvalue_bit_select_impl<L, U>::calc(x);
1a405f
+}
1a405f
 
1a405f
 AArch64_reloc_property::AArch64_reloc_property(
1a405f
     unsigned int code,
1a405f
diff -rup ../binutils-2.27/gold/arm.cc gold/arm.cc
1a405f
--- ../binutils-2.27/gold/arm.cc	2016-09-26 11:22:18.629810833 +0100
1a405f
+++ gold/arm.cc	2016-11-03 15:05:33.000000000 +0000
1a405f
@@ -2128,8 +2128,36 @@ class Target_arm : public Sized_target<3
1a405f
       stub_tables_(), stub_factory_(Stub_factory::get_instance()),
1a405f
       should_force_pic_veneer_(false),
1a405f
       arm_input_section_map_(), attributes_section_data_(NULL),
1a405f
-      fix_cortex_a8_(false), cortex_a8_relocs_info_()
1a405f
-  { }
1a405f
+      fix_cortex_a8_(false), cortex_a8_relocs_info_(),
1a405f
+      target1_reloc_(elfcpp::R_ARM_ABS32),
1a405f
+      // This can be any reloc type but usually is R_ARM_GOT_PREL.
1a405f
+      target2_reloc_(elfcpp::R_ARM_GOT_PREL)
1a405f
+  {
1a405f
+    if (parameters->options().user_set_target1_rel())
1a405f
+      {
1a405f
+	// FIXME: This is not strictly compatible with ld, which allows both
1a405f
+	// --target1-abs and --target-rel to be given.
1a405f
+	if (parameters->options().user_set_target1_abs())
1a405f
+	  gold_error(_("Cannot use both --target1-abs and --target1-rel."));
1a405f
+	else
1a405f
+	  this->target1_reloc_ = elfcpp::R_ARM_REL32;
1a405f
+      }
1a405f
+    // We don't need to handle --target1-abs because target1_reloc_ is set
1a405f
+    // to elfcpp::R_ARM_ABS32 in the member initializer list.
1a405f
+
1a405f
+    if (parameters->options().user_set_target2())
1a405f
+      {
1a405f
+	const char* target2 = parameters->options().target2();
1a405f
+	if (strcmp(target2, "rel") == 0)
1a405f
+	  this->target2_reloc_ = elfcpp::R_ARM_REL32;
1a405f
+	else if (strcmp(target2, "abs") == 0)
1a405f
+	  this->target2_reloc_ = elfcpp::R_ARM_ABS32;
1a405f
+	else if (strcmp(target2, "got-rel") == 0)
1a405f
+	  this->target2_reloc_ = elfcpp::R_ARM_GOT_PREL;
1a405f
+	else
1a405f
+	  gold_unreachable();
1a405f
+      }
1a405f
+  }
1a405f
 
1a405f
   // Whether we force PCI branch veneers.
1a405f
   bool
1a405f
@@ -2391,8 +2419,8 @@ class Target_arm : public Sized_target<3
1a405f
   rel_irelative_section(Layout*);
1a405f
 
1a405f
   // Map platform-specific reloc types
1a405f
-  static unsigned int
1a405f
-  get_real_reloc_type(unsigned int r_type);
1a405f
+  unsigned int
1a405f
+  get_real_reloc_type(unsigned int r_type) const;
1a405f
 
1a405f
   //
1a405f
   // Methods to support stub-generations.
1a405f
@@ -3002,6 +3030,11 @@ class Target_arm : public Sized_target<3
1a405f
   bool fix_cortex_a8_;
1a405f
   // Map addresses to relocs for Cortex-A8 erratum.
1a405f
   Cortex_a8_relocs_info cortex_a8_relocs_info_;
1a405f
+  // What R_ARM_TARGET1 maps to. It can be R_ARM_REL32 or R_ARM_ABS32.
1a405f
+  unsigned int target1_reloc_;
1a405f
+  // What R_ARM_TARGET2 maps to. It should be one of R_ARM_REL32, R_ARM_ABS32
1a405f
+  // and R_ARM_GOT_PREL.
1a405f
+  unsigned int target2_reloc_;
1a405f
 };
1a405f
 
1a405f
 template<bool big_endian>
1a405f
@@ -6639,6 +6672,80 @@ Arm_relobj<big_endian>::do_relocate_sect
1a405f
 	      section_address,
1a405f
 	      section_size);
1a405f
 	}
1a405f
+	// BE8 swapping
1a405f
+	if (parameters->options().be8())
1a405f
+	  {
1a405f
+	    section_size_type  span_start, span_end;
1a405f
+	    elfcpp::Shdr<32, big_endian>
1a405f
+	      shdr(pshdrs + i * elfcpp::Elf_sizes<32>::shdr_size);
1a405f
+	    Mapping_symbol_position section_start(i, 0);
1a405f
+	    typename Mapping_symbols_info::const_iterator p =
1a405f
+	      this->mapping_symbols_info_.lower_bound(section_start);
1a405f
+	    unsigned char* view = (*pviews)[i].view;
1a405f
+	    Arm_address view_address = (*pviews)[i].address;
1a405f
+	    section_size_type view_size = (*pviews)[i].view_size;
1a405f
+	    while (p != this->mapping_symbols_info_.end()
1a405f
+		   && p->first.first == i)
1a405f
+	      {
1a405f
+		typename Mapping_symbols_info::const_iterator next =
1a405f
+		  this->mapping_symbols_info_.upper_bound(p->first);
1a405f
+
1a405f
+		// Only swap arm or thumb code.
1a405f
+		if ((p->second == 'a') || (p->second == 't'))
1a405f
+		  {
1a405f
+		    Output_section* os = this->output_section(i);
1a405f
+		    gold_assert(os != NULL);
1a405f
+		    Arm_address section_address =
1a405f
+		      this->simple_input_section_output_address(i, os);
1a405f
+		    span_start = convert_to_section_size_type(p->first.second);
1a405f
+		    if (next != this->mapping_symbols_info_.end()
1a405f
+		        && next->first.first == i)
1a405f
+		      span_end =
1a405f
+			convert_to_section_size_type(next->first.second);
1a405f
+		    else
1a405f
+		      span_end =
1a405f
+			convert_to_section_size_type(shdr.get_sh_size());
1a405f
+		    unsigned char* section_view =
1a405f
+		      view + (section_address - view_address);
1a405f
+		    uint64_t section_size = this->section_size(i);
1a405f
+
1a405f
+		    gold_assert(section_address >= view_address
1a405f
+				&& ((section_address + section_size)
1a405f
+				    <= (view_address + view_size)));
1a405f
+
1a405f
+		    // Set Output view for swapping
1a405f
+		    unsigned char *oview = section_view + span_start;
1a405f
+		    unsigned int index = 0;
1a405f
+		    if (p->second == 'a')
1a405f
+		      {
1a405f
+			while (index + 3 < (span_end - span_start))
1a405f
+			  {
1a405f
+			    typedef typename elfcpp::Swap<32, big_endian>
1a405f
+						     ::Valtype Valtype;
1a405f
+			    Valtype* wv =
1a405f
+			      reinterpret_cast<Valtype*>(oview+index);
1a405f
+			    uint32_t val = elfcpp::Swap<32, false>::readval(wv);
1a405f
+			    elfcpp::Swap<32, true>::writeval(wv, val);
1a405f
+			    index += 4;
1a405f
+			  }
1a405f
+		      }
1a405f
+		    else if (p->second == 't')
1a405f
+		      {
1a405f
+		        while (index + 1 < (span_end - span_start))
1a405f
+			  {
1a405f
+			    typedef typename elfcpp::Swap<16, big_endian>
1a405f
+						     ::Valtype Valtype;
1a405f
+			    Valtype* wv =
1a405f
+			      reinterpret_cast<Valtype*>(oview+index);
1a405f
+			    uint16_t val = elfcpp::Swap<16, false>::readval(wv);
1a405f
+			    elfcpp::Swap<16, true>::writeval(wv, val);
1a405f
+			    index += 2;
1a405f
+			   }
1a405f
+		      }
1a405f
+	          }
1a405f
+	        p = next;
1a405f
+	      }
1a405f
+	  }
1a405f
     }
1a405f
 }
1a405f
 
1a405f
@@ -7785,7 +7892,18 @@ Output_data_plt_arm_standard<big_endian>
1a405f
   const size_t num_first_plt_words = (sizeof(first_plt_entry)
1a405f
 				      / sizeof(first_plt_entry[0]));
1a405f
   for (size_t i = 0; i < num_first_plt_words - 1; i++)
1a405f
-    elfcpp::Swap<32, big_endian>::writeval(pov + i * 4, first_plt_entry[i]);
1a405f
+    {
1a405f
+      if (parameters->options().be8())
1a405f
+	{
1a405f
+	  elfcpp::Swap<32, false>::writeval(pov + i * 4,
1a405f
+					    first_plt_entry[i]);
1a405f
+	}
1a405f
+      else
1a405f
+	{
1a405f
+	  elfcpp::Swap<32, big_endian>::writeval(pov + i * 4,
1a405f
+						 first_plt_entry[i]);
1a405f
+	}
1a405f
+    }
1a405f
   // Last word in first PLT entry is &GOT[0] - .
1a405f
   elfcpp::Swap<32, big_endian>::writeval(pov + 16,
1a405f
 					 got_address - (plt_address + 16));
1a405f
@@ -7846,11 +7964,21 @@ Output_data_plt_arm_short<big_endian>::d
1a405f
     gold_error(_("PLT offset too large, try linking with --long-plt"));
1a405f
 
1a405f
   uint32_t plt_insn0 = plt_entry[0] | ((offset >> 20) & 0xff);
1a405f
-  elfcpp::Swap<32, big_endian>::writeval(pov, plt_insn0);
1a405f
   uint32_t plt_insn1 = plt_entry[1] | ((offset >> 12) & 0xff);
1a405f
-  elfcpp::Swap<32, big_endian>::writeval(pov + 4, plt_insn1);
1a405f
   uint32_t plt_insn2 = plt_entry[2] | (offset & 0xfff);
1a405f
-  elfcpp::Swap<32, big_endian>::writeval(pov + 8, plt_insn2);
1a405f
+
1a405f
+  if (parameters->options().be8())
1a405f
+    {
1a405f
+      elfcpp::Swap<32, false>::writeval(pov, plt_insn0);
1a405f
+      elfcpp::Swap<32, false>::writeval(pov + 4, plt_insn1);
1a405f
+      elfcpp::Swap<32, false>::writeval(pov + 8, plt_insn2);
1a405f
+    }
1a405f
+  else
1a405f
+    {
1a405f
+      elfcpp::Swap<32, big_endian>::writeval(pov, plt_insn0);
1a405f
+      elfcpp::Swap<32, big_endian>::writeval(pov + 4, plt_insn1);
1a405f
+      elfcpp::Swap<32, big_endian>::writeval(pov + 8, plt_insn2);
1a405f
+    }
1a405f
 }
1a405f
 
1a405f
 // This class generates long (16-byte) entries, for arbitrary displacements.
1a405f
@@ -7906,13 +8034,24 @@ Output_data_plt_arm_long<big_endian>::do
1a405f
 		    - (plt_address + plt_offset + 8));
1a405f
 
1a405f
   uint32_t plt_insn0 = plt_entry[0] | (offset >> 28);
1a405f
-  elfcpp::Swap<32, big_endian>::writeval(pov, plt_insn0);
1a405f
   uint32_t plt_insn1 = plt_entry[1] | ((offset >> 20) & 0xff);
1a405f
-  elfcpp::Swap<32, big_endian>::writeval(pov + 4, plt_insn1);
1a405f
   uint32_t plt_insn2 = plt_entry[2] | ((offset >> 12) & 0xff);
1a405f
-  elfcpp::Swap<32, big_endian>::writeval(pov + 8, plt_insn2);
1a405f
   uint32_t plt_insn3 = plt_entry[3] | (offset & 0xfff);
1a405f
-  elfcpp::Swap<32, big_endian>::writeval(pov + 12, plt_insn3);
1a405f
+
1a405f
+  if (parameters->options().be8())
1a405f
+    {
1a405f
+      elfcpp::Swap<32, false>::writeval(pov, plt_insn0);
1a405f
+      elfcpp::Swap<32, false>::writeval(pov + 4, plt_insn1);
1a405f
+      elfcpp::Swap<32, false>::writeval(pov + 8, plt_insn2);
1a405f
+      elfcpp::Swap<32, false>::writeval(pov + 12, plt_insn3);
1a405f
+    }
1a405f
+  else
1a405f
+    {
1a405f
+      elfcpp::Swap<32, big_endian>::writeval(pov, plt_insn0);
1a405f
+      elfcpp::Swap<32, big_endian>::writeval(pov + 4, plt_insn1);
1a405f
+      elfcpp::Swap<32, big_endian>::writeval(pov + 8, plt_insn2);
1a405f
+      elfcpp::Swap<32, big_endian>::writeval(pov + 12, plt_insn3);
1a405f
+    }
1a405f
 }
1a405f
 
1a405f
 // Write out the PLT.  This uses the hand-coded instructions above,
1a405f
@@ -8414,7 +8553,7 @@ Target_arm<big_endian>::Scan::local(Symb
1a405f
   if (is_discarded)
1a405f
     return;
1a405f
 
1a405f
-  r_type = get_real_reloc_type(r_type);
1a405f
+  r_type = target->get_real_reloc_type(r_type);
1a405f
 
1a405f
   // A local STT_GNU_IFUNC symbol may require a PLT entry.
1a405f
   bool is_ifunc = lsym.get_st_type() == elfcpp::STT_GNU_IFUNC;
1a405f
@@ -8820,7 +8959,7 @@ Target_arm<big_endian>::Scan::global(Sym
1a405f
       && this->reloc_needs_plt_for_ifunc(object, r_type))
1a405f
     target->make_plt_entry(symtab, layout, gsym);
1a405f
 
1a405f
-  r_type = get_real_reloc_type(r_type);
1a405f
+  r_type = target->get_real_reloc_type(r_type);
1a405f
   switch (r_type)
1a405f
     {
1a405f
     case elfcpp::R_ARM_NONE:
1a405f
@@ -9446,7 +9585,7 @@ Target_arm<big_endian>::Relocate::reloca
1a405f
 
1a405f
   const elfcpp::Rel<32, big_endian> rel(preloc);
1a405f
   unsigned int r_type = elfcpp::elf_r_type<32>(rel.get_r_info());
1a405f
-  r_type = get_real_reloc_type(r_type);
1a405f
+  r_type = target->get_real_reloc_type(r_type);
1a405f
   const Arm_reloc_property* reloc_property =
1a405f
     arm_reloc_property_table->get_implemented_static_reloc_property(r_type);
1a405f
   if (reloc_property == NULL)
1a405f
@@ -10156,7 +10295,9 @@ Target_arm<big_endian>::Classify_reloc::
1a405f
     unsigned int r_type,
1a405f
     Relobj* object)
1a405f
 {
1a405f
-  r_type = get_real_reloc_type(r_type);
1a405f
+  Target_arm<big_endian>* arm_target =
1a405f
+      Target_arm<big_endian>::default_target();
1a405f
+  r_type = arm_target->get_real_reloc_type(r_type);
1a405f
   const Arm_reloc_property* arp =
1a405f
       arm_reloc_property_table->get_implemented_static_reloc_property(r_type);
1a405f
   if (arp != NULL)
1a405f
@@ -10580,17 +10721,15 @@ Target_arm<big_endian>::do_dynsym_value(
1a405f
 //
1a405f
 template<bool big_endian>
1a405f
 unsigned int
1a405f
-Target_arm<big_endian>::get_real_reloc_type(unsigned int r_type)
1a405f
+Target_arm<big_endian>::get_real_reloc_type(unsigned int r_type) const
1a405f
 {
1a405f
   switch (r_type)
1a405f
     {
1a405f
     case elfcpp::R_ARM_TARGET1:
1a405f
-      // This is either R_ARM_ABS32 or R_ARM_REL32;
1a405f
-      return elfcpp::R_ARM_ABS32;
1a405f
+      return this->target1_reloc_;
1a405f
 
1a405f
     case elfcpp::R_ARM_TARGET2:
1a405f
-      // This can be any reloc type but usually is R_ARM_GOT_PREL
1a405f
-      return elfcpp::R_ARM_GOT_PREL;
1a405f
+      return this->target2_reloc_;
1a405f
 
1a405f
     default:
1a405f
       return r_type;
1a405f
@@ -10683,7 +10822,14 @@ Target_arm<big_endian>::do_adjust_elf_he
1a405f
     e_ident[elfcpp::EI_OSABI] = 0;
1a405f
   e_ident[elfcpp::EI_ABIVERSION] = 0;
1a405f
 
1a405f
-  // FIXME: Do EF_ARM_BE8 adjustment.
1a405f
+  // Do EF_ARM_BE8 adjustment.
1a405f
+  if (parameters->options().be8() && !big_endian)
1a405f
+    gold_error("BE8 images only valid in big-endian mode.");
1a405f
+  if (parameters->options().be8())
1a405f
+    {
1a405f
+      flags |= elfcpp::EF_ARM_BE8;
1a405f
+      this->set_processor_specific_flags(flags);
1a405f
+    }
1a405f
 
1a405f
   // If we're working in EABI_VER5, set the hard/soft float ABI flags
1a405f
   // as appropriate.
1a405f
diff -rup ../binutils-2.27/gold/configure gold/configure
1a405f
--- ../binutils-2.27/gold/configure	2016-09-26 11:22:19.027813254 +0100
1a405f
+++ gold/configure	2016-11-03 14:38:22.000000000 +0000
1a405f
@@ -609,6 +609,7 @@ GOLD_LDFLAGS
1a405f
 WARN_CXXFLAGS
1a405f
 WARN_WRITE_STRINGS
1a405f
 NO_WERROR
1a405f
+WARN_CFLAGS_FOR_BUILD
1a405f
 WARN_CFLAGS
1a405f
 IFUNC_STATIC_FALSE
1a405f
 IFUNC_STATIC_TRUE
1a405f
@@ -6723,8 +6724,12 @@ fi
1a405f
 # Set the 'development' global.
1a405f
 . $srcdir/../bfd/development.sh
1a405f
 
1a405f
+# Set acp_cpp_for_build variable
1a405f
+ac_cpp_for_build="$CC_FOR_BUILD -E $CPPFLAGS_FOR_BUILD"
1a405f
+
1a405f
 # Default set of GCC warnings to enable.
1a405f
 GCC_WARN_CFLAGS="-W -Wall -Wstrict-prototypes -Wmissing-prototypes"
1a405f
+GCC_WARN_CFLAGS_FOR_BUILD="-W -Wall -Wstrict-prototypes -Wmissing-prototypes"
1a405f
 
1a405f
 # Add -Wshadow if the compiler is a sufficiently recent version of GCC.
1a405f
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1a405f
@@ -6769,6 +6774,36 @@ fi
1a405f
 rm -f conftest*
1a405f
 
1a405f
 
1a405f
+# Verify CC_FOR_BUILD to be compatible with waring flags
1a405f
+
1a405f
+# Add -Wshadow if the compiler is a sufficiently recent version of GCC.
1a405f
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1a405f
+/* end confdefs.h.  */
1a405f
+__GNUC__
1a405f
+_ACEOF
1a405f
+if (eval "$ac_cpp_for_build conftest.$ac_ext") 2>&5 |
1a405f
+  $EGREP "^[0-3]$" >/dev/null 2>&1; then :
1a405f
+
1a405f
+else
1a405f
+  GCC_WARN_CFLAGS_FOR_BUILD="$GCC_WARN_CFLAGS_FOR_BUILD -Wshadow"
1a405f
+fi
1a405f
+rm -f conftest*
1a405f
+
1a405f
+
1a405f
+# Add -Wstack-usage if the compiler is a sufficiently recent version of GCC.
1a405f
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1a405f
+/* end confdefs.h.  */
1a405f
+__GNUC__
1a405f
+_ACEOF
1a405f
+if (eval "$ac_cpp_for_build conftest.$ac_ext") 2>&5 |
1a405f
+  $EGREP "^[0-4]$" >/dev/null 2>&1; then :
1a405f
+
1a405f
+else
1a405f
+  GCC_WARN_CFLAGS_FOR_BUILD="$GCC_WARN_CFLAGS_FOR_BUILD -Wstack-usage=262144"
1a405f
+fi
1a405f
+rm -f conftest*
1a405f
+
1a405f
+
1a405f
 # Check whether --enable-werror was given.
1a405f
 if test "${enable_werror+set}" = set; then :
1a405f
   enableval=$enable_werror; case "${enableval}" in
1a405f
@@ -6784,6 +6819,7 @@ case "${host}" in
1a405f
   *-*-mingw32*)
1a405f
     if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" ; then
1a405f
       GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Wno-format"
1a405f
+      GCC_WARN_CFLAGS_FOR_BUILD="$GCC_WARN_CFLAGS_FOR_BUILD -Wno-format"
1a405f
     fi
1a405f
     ;;
1a405f
   *) ;;
1a405f
@@ -6797,25 +6833,32 @@ fi
1a405f
 NO_WERROR=
1a405f
 if test "${ERROR_ON_WARNING}" = yes ; then
1a405f
     GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Werror"
1a405f
+    GCC_WARN_CFLAGS_FOR_BUILD="$GCC_WARN_CFLAGS_FOR_BUILD -Werror"
1a405f
     NO_WERROR="-Wno-error"
1a405f
 fi
1a405f
 
1a405f
 if test "${GCC}" = yes ; then
1a405f
   WARN_CFLAGS="${GCC_WARN_CFLAGS}"
1a405f
+  WARN_CFLAGS_FOR_BUILD="${GCC_WARN_CFLAGS_FOR_BUILD}"
1a405f
 fi
1a405f
 
1a405f
 # Check whether --enable-build-warnings was given.
1a405f
 if test "${enable_build_warnings+set}" = set; then :
1a405f
   enableval=$enable_build_warnings; case "${enableval}" in
1a405f
-  yes)	WARN_CFLAGS="${GCC_WARN_CFLAGS}";;
1a405f
+  yes)	WARN_CFLAGS="${GCC_WARN_CFLAGS}"
1a405f
+        WARN_CFLAGS_FOR_BUILD="${GCC_WARN_CFLAGS_FOR_BUILD}";;
1a405f
   no)	if test "${GCC}" = yes ; then
1a405f
 	  WARN_CFLAGS="-w"
1a405f
+      WARN_CFLAGS_FOR_BUILD="-w"
1a405f
 	fi;;
1a405f
   ,*)   t=`echo "${enableval}" | sed -e "s/,/ /g"`
1a405f
-        WARN_CFLAGS="${GCC_WARN_CFLAGS} ${t}";;
1a405f
+        WARN_CFLAGS="${GCC_WARN_CFLAGS} ${t}"
1a405f
+        WARN_CFLAGS_FOR_BUILD="${GCC_WARN_CFLAGS_FOR_BUILD} ${t}";;
1a405f
   *,)   t=`echo "${enableval}" | sed -e "s/,/ /g"`
1a405f
-        WARN_CFLAGS="${t} ${GCC_WARN_CFLAGS}";;
1a405f
-  *)    WARN_CFLAGS=`echo "${enableval}" | sed -e "s/,/ /g"`;;
1a405f
+        WARN_CFLAGS="${t} ${GCC_WARN_CFLAGS}"
1a405f
+        WARN_CFLAGS_FOR_BUILD="${t} ${GCC_WARN_CFLAGS_FOR_BUILD}";;
1a405f
+  *)    WARN_CFLAGS=`echo "${enableval}" | sed -e "s/,/ /g"`
1a405f
+        WARN_CFLAGS_FOR_BUILD=`echo "${enableval}" | sed -e "s/,/ /g"`;;
1a405f
 esac
1a405f
 fi
1a405f
 
1a405f
diff -rup ../binutils-2.27/gold/debug.h gold/debug.h
1a405f
--- ../binutils-2.27/gold/debug.h	2016-08-03 08:36:53.000000000 +0100
1a405f
+++ gold/debug.h	2016-11-03 15:05:05.000000000 +0000
1a405f
@@ -39,10 +39,11 @@ const int DEBUG_FILES = 0x4;
1a405f
 const int DEBUG_RELAXATION = 0x8;
1a405f
 const int DEBUG_INCREMENTAL = 0x10;
1a405f
 const int DEBUG_LOCATION = 0x20;
1a405f
+const int DEBUG_TARGET = 0x40;
1a405f
 
1a405f
 const int DEBUG_ALL = (DEBUG_TASK | DEBUG_SCRIPT | DEBUG_FILES
1a405f
 		       | DEBUG_RELAXATION | DEBUG_INCREMENTAL
1a405f
-		       | DEBUG_LOCATION);
1a405f
+		       | DEBUG_LOCATION | DEBUG_TARGET);
1a405f
 
1a405f
 // Convert a debug string to the appropriate enum.
1a405f
 inline int
1a405f
@@ -57,6 +58,7 @@ debug_string_to_enum(const char* arg)
1a405f
     { "relaxation", DEBUG_RELAXATION },
1a405f
     { "incremental", DEBUG_INCREMENTAL },
1a405f
     { "location", DEBUG_LOCATION },
1a405f
+    { "target", DEBUG_TARGET },
1a405f
     { "all", DEBUG_ALL }
1a405f
   };
1a405f
 
1a405f
@@ -70,11 +72,11 @@ debug_string_to_enum(const char* arg)
1a405f
 // Print a debug message if TYPE is enabled.  This is a macro so that
1a405f
 // we only evaluate the arguments if necessary.
1a405f
 
1a405f
-#define gold_debug(TYPE, FORMAT, ...)				\
1a405f
+#define gold_debug(TYPE, ...)					\
1a405f
   do								\
1a405f
     {								\
1a405f
       if (is_debugging_enabled(TYPE))				\
1a405f
-	parameters->errors()->debug(FORMAT, __VA_ARGS__);	\
1a405f
+	parameters->errors()->debug(__VA_ARGS__);		\
1a405f
     }								\
1a405f
   while (0)
1a405f
 
1a405f
diff -rup ../binutils-2.27/gold/i386.cc gold/i386.cc
1a405f
--- ../binutils-2.27/gold/i386.cc	2016-08-03 08:36:53.000000000 +0100
1a405f
+++ gold/i386.cc	2016-11-03 15:05:40.000000000 +0000
1a405f
@@ -2794,8 +2794,11 @@ Target_i386::Relocate::relocate(const Re
1a405f
 	   && r_type != elfcpp::R_386_PC32)
1a405f
 	  || gsym == NULL
1a405f
 	  || strcmp(gsym->name(), "___tls_get_addr") != 0)
1a405f
-	gold_error_at_location(relinfo, relnum, rel.get_r_offset(),
1a405f
-			       _("missing expected TLS relocation"));
1a405f
+	{
1a405f
+	  gold_error_at_location(relinfo, relnum, rel.get_r_offset(),
1a405f
+				 _("missing expected TLS relocation"));
1a405f
+	  this->skip_call_tls_get_addr_ = false;
1a405f
+	}
1a405f
       else
1a405f
 	{
1a405f
 	  this->skip_call_tls_get_addr_ = false;
1a405f
diff -rup ../binutils-2.27/gold/icf.cc gold/icf.cc
1a405f
--- ../binutils-2.27/gold/icf.cc	2016-08-03 08:36:53.000000000 +0100
1a405f
+++ gold/icf.cc	2016-11-03 15:05:40.000000000 +0000
1a405f
@@ -590,6 +590,7 @@ match_sections(unsigned int iteration_nu
1a405f
                std::vector<unsigned int>* num_tracked_relocs,
1a405f
                std::vector<unsigned int>* kept_section_id,
1a405f
                const std::vector<Section_id>& id_section,
1a405f
+	       const std::vector<uint64_t>& section_addraligns,
1a405f
                std::vector<bool>* is_secn_or_group_unique,
1a405f
                std::vector<std::string>* section_contents)
1a405f
 {
1a405f
@@ -630,13 +631,7 @@ match_sections(unsigned int iteration_nu
1a405f
         {
1a405f
           if ((*kept_section_id)[i] != i)
1a405f
             {
1a405f
-              // This section is already folded into something.  See
1a405f
-              // if it should point to a different kept section.
1a405f
-              unsigned int kept_section = (*kept_section_id)[i];
1a405f
-              if (kept_section != (*kept_section_id)[kept_section])
1a405f
-                {
1a405f
-                  (*kept_section_id)[i] = (*kept_section_id)[kept_section];
1a405f
-                }
1a405f
+              // This section is already folded into something.
1a405f
               continue;
1a405f
             }
1a405f
           this_secn_contents = get_section_contents(false, secn, i, NULL,
1a405f
@@ -671,7 +666,25 @@ match_sections(unsigned int iteration_nu
1a405f
                          this_secn_contents.c_str(),
1a405f
                          this_secn_contents.length()) != 0)
1a405f
                   continue;
1a405f
-              (*kept_section_id)[i] = kept_section;
1a405f
+
1a405f
+	      // Check section alignment here.
1a405f
+	      // The section with the larger alignment requirement
1a405f
+	      // should be kept.  We assume alignment can only be 
1a405f
+	      // zero or postive integral powers of two.
1a405f
+	      uint64_t align_i = section_addraligns[i];
1a405f
+	      uint64_t align_kept = section_addraligns[kept_section];
1a405f
+	      if (align_i <= align_kept)
1a405f
+		{
1a405f
+		  (*kept_section_id)[i] = kept_section;
1a405f
+		}
1a405f
+	      else
1a405f
+		{
1a405f
+		  (*kept_section_id)[kept_section] = i;
1a405f
+		  it->second = i;
1a405f
+		  full_section_contents[kept_section].swap(
1a405f
+		      full_section_contents[i]);
1a405f
+		}
1a405f
+
1a405f
               converged = false;
1a405f
               break;
1a405f
             }
1a405f
@@ -688,6 +701,26 @@ match_sections(unsigned int iteration_nu
1a405f
         (*is_secn_or_group_unique)[i] = true;
1a405f
     }
1a405f
 
1a405f
+  // If a section was folded into another section that was later folded
1a405f
+  // again then the former has to be updated.
1a405f
+  for (unsigned int i = 0; i < id_section.size(); i++)
1a405f
+    {
1a405f
+      // Find the end of the folding chain
1a405f
+      unsigned int kept = i;
1a405f
+      while ((*kept_section_id)[kept] != kept)
1a405f
+        {
1a405f
+          kept = (*kept_section_id)[kept];
1a405f
+        }
1a405f
+      // Update every element of the chain
1a405f
+      unsigned int current = i;
1a405f
+      while ((*kept_section_id)[current] != kept)
1a405f
+        {
1a405f
+          unsigned int next = (*kept_section_id)[current];
1a405f
+          (*kept_section_id)[current] = kept;
1a405f
+          current = next;
1a405f
+        }
1a405f
+    }
1a405f
+
1a405f
   return converged;
1a405f
 }
1a405f
 
1a405f
@@ -719,6 +752,7 @@ Icf::find_identical_sections(const Input
1a405f
 {
1a405f
   unsigned int section_num = 0;
1a405f
   std::vector<unsigned int> num_tracked_relocs;
1a405f
+  std::vector<uint64_t> section_addraligns;
1a405f
   std::vector<bool> is_secn_or_group_unique;
1a405f
   std::vector<std::string> section_contents;
1a405f
   const Target& target = parameters->target();
1a405f
@@ -759,6 +793,7 @@ Icf::find_identical_sections(const Input
1a405f
           this->section_id_[Section_id(*p, i)] = section_num;
1a405f
           this->kept_section_id_.push_back(section_num);
1a405f
           num_tracked_relocs.push_back(0);
1a405f
+	  section_addraligns.push_back((*p)->section_addralign(i));
1a405f
           is_secn_or_group_unique.push_back(false);
1a405f
           section_contents.push_back("");
1a405f
           section_num++;
1a405f
@@ -779,8 +814,8 @@ Icf::find_identical_sections(const Input
1a405f
       num_iterations++;
1a405f
       converged = match_sections(num_iterations, symtab,
1a405f
                                  &num_tracked_relocs, &this->kept_section_id_,
1a405f
-                                 this->id_section_, &is_secn_or_group_unique,
1a405f
-                                 &section_contents);
1a405f
+                                 this->id_section_, section_addraligns,
1a405f
+                                 &is_secn_or_group_unique, &section_contents);
1a405f
     }
1a405f
 
1a405f
   if (parameters->options().print_icf_sections())
1a405f
diff -rup ../binutils-2.27/gold/layout.cc gold/layout.cc
1a405f
--- ../binutils-2.27/gold/layout.cc	2016-08-03 08:36:53.000000000 +0100
1a405f
+++ gold/layout.cc	2016-11-03 15:05:42.000000000 +0000
1a405f
@@ -2135,7 +2135,7 @@ void
1a405f
 Layout::create_notes()
1a405f
 {
1a405f
   this->create_gold_note();
1a405f
-  this->create_executable_stack_info();
1a405f
+  this->create_stack_segment();
1a405f
   this->create_build_id();
1a405f
 }
1a405f
 
1a405f
@@ -2785,7 +2785,7 @@ Layout::finalize(const Input_objects* in
1a405f
       if (load_seg != NULL)
1a405f
 	ehdr_start->set_output_segment(load_seg, Symbol::SEGMENT_START);
1a405f
       else
1a405f
-        ehdr_start->set_undefined();
1a405f
+	ehdr_start->set_undefined();
1a405f
     }
1a405f
 
1a405f
   // Set the file offsets of all the non-data sections we've seen so
1a405f
@@ -2985,25 +2985,29 @@ Layout::create_gold_note()
1a405f
 // executable.  Otherwise, if at least one input file a
1a405f
 // .note.GNU-stack section, and some input file has no .note.GNU-stack
1a405f
 // section, we use the target default for whether the stack should be
1a405f
-// executable.  Otherwise, we don't generate a stack note.  When
1a405f
-// generating a object file, we create a .note.GNU-stack section with
1a405f
-// the appropriate marking.  When generating an executable or shared
1a405f
-// library, we create a PT_GNU_STACK segment.
1a405f
+// executable.  If -z stack-size was used to set a p_memsz value for
1a405f
+// PT_GNU_STACK, we generate the segment regardless.  Otherwise, we
1a405f
+// don't generate a stack note.  When generating a object file, we
1a405f
+// create a .note.GNU-stack section with the appropriate marking.
1a405f
+// When generating an executable or shared library, we create a
1a405f
+// PT_GNU_STACK segment.
1a405f
 
1a405f
 void
1a405f
-Layout::create_executable_stack_info()
1a405f
+Layout::create_stack_segment()
1a405f
 {
1a405f
   bool is_stack_executable;
1a405f
   if (parameters->options().is_execstack_set())
1a405f
     {
1a405f
       is_stack_executable = parameters->options().is_stack_executable();
1a405f
       if (!is_stack_executable
1a405f
-          && this->input_requires_executable_stack_
1a405f
-          && parameters->options().warn_execstack())
1a405f
+	  && this->input_requires_executable_stack_
1a405f
+	  && parameters->options().warn_execstack())
1a405f
 	gold_warning(_("one or more inputs require executable stack, "
1a405f
-	               "but -z noexecstack was given"));
1a405f
+		       "but -z noexecstack was given"));
1a405f
     }
1a405f
-  else if (!this->input_with_gnu_stack_note_)
1a405f
+  else if (!this->input_with_gnu_stack_note_
1a405f
+	   && (!parameters->options().user_set_stack_size()
1a405f
+	       || parameters->options().relocatable()))
1a405f
     return;
1a405f
   else
1a405f
     {
1a405f
@@ -3032,7 +3036,12 @@ Layout::create_executable_stack_info()
1a405f
       int flags = elfcpp::PF_R | elfcpp::PF_W;
1a405f
       if (is_stack_executable)
1a405f
 	flags |= elfcpp::PF_X;
1a405f
-      this->make_output_segment(elfcpp::PT_GNU_STACK, flags);
1a405f
+      Output_segment* seg =
1a405f
+	this->make_output_segment(elfcpp::PT_GNU_STACK, flags);
1a405f
+      seg->set_size(parameters->options().stack_size());
1a405f
+      // BFD lets targets override this default alignment, but the only
1a405f
+      // targets that do so are ones that Gold does not support so far.
1a405f
+      seg->set_minimum_p_align(16);
1a405f
     }
1a405f
 }
1a405f
 
1a405f
@@ -3718,7 +3727,9 @@ Layout::set_segment_offsets(const Target
1a405f
        p != this->segment_list_.end();
1a405f
        ++p)
1a405f
     {
1a405f
-      if ((*p)->type() != elfcpp::PT_LOAD)
1a405f
+      // PT_GNU_STACK was set up correctly when it was created.
1a405f
+      if ((*p)->type() != elfcpp::PT_LOAD
1a405f
+	  && (*p)->type() != elfcpp::PT_GNU_STACK)
1a405f
 	(*p)->set_offset((*p)->type() == elfcpp::PT_GNU_RELRO
1a405f
 			 ? increase_relro
1a405f
 			 : 0);
1a405f
diff -rup ../binutils-2.27/gold/layout.h gold/layout.h
1a405f
--- ../binutils-2.27/gold/layout.h	2016-08-03 08:36:53.000000000 +0100
1a405f
+++ gold/layout.h	2016-11-03 15:05:12.000000000 +0000
1a405f
@@ -1037,9 +1037,9 @@ class Layout
1a405f
   void
1a405f
   create_gold_note();
1a405f
 
1a405f
-  // Record whether the stack must be executable.
1a405f
+  // Record whether the stack must be executable, and a user-supplied size.
1a405f
   void
1a405f
-  create_executable_stack_info();
1a405f
+  create_stack_segment();
1a405f
 
1a405f
   // Create a build ID note if needed.
1a405f
   void
1a405f
diff -rup ../binutils-2.27/gold/Makefile.in gold/Makefile.in
1a405f
--- ../binutils-2.27/gold/Makefile.in	2016-08-03 08:36:53.000000000 +0100
1a405f
+++ gold/Makefile.in	2016-11-03 14:38:22.000000000 +0000
1a405f
@@ -87,8 +87,8 @@ subdir = .
1a405f
 DIST_COMMON = NEWS README ChangeLog $(srcdir)/Makefile.in \
1a405f
 	$(srcdir)/Makefile.am $(top_srcdir)/configure \
1a405f
 	$(am__configure_deps) $(srcdir)/config.in \
1a405f
-	$(srcdir)/../mkinstalldirs $(top_srcdir)/po/Make-in \
1a405f
-	ftruncate.c pread.c mremap.c ffsll.c yyscript.h yyscript.c \
1a405f
+	$(srcdir)/../mkinstalldirs $(top_srcdir)/po/Make-in ffsll.c \
1a405f
+	mremap.c ftruncate.c pread.c yyscript.h yyscript.c \
1a405f
 	$(srcdir)/../depcomp $(srcdir)/../ylwrap
1a405f
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
1a405f
 am__aclocal_m4_deps = $(top_srcdir)/../config/depstand.m4 \
1a405f
@@ -409,6 +409,7 @@ TARGETOBJS = @TARGETOBJS@
1a405f
 USE_NLS = @USE_NLS@
1a405f
 VERSION = @VERSION@
1a405f
 WARN_CFLAGS = @WARN_CFLAGS@
1a405f
+WARN_CFLAGS_FOR_BUILD = @WARN_CFLAGS_FOR_BUILD@
1a405f
 WARN_CXXFLAGS = @WARN_CXXFLAGS@
1a405f
 WARN_WRITE_STRINGS = @WARN_WRITE_STRINGS@
1a405f
 XGETTEXT = @XGETTEXT@
1a405f
diff -rup ../binutils-2.27/gold/options.h gold/options.h
1a405f
--- ../binutils-2.27/gold/options.h	2016-08-03 08:36:53.000000000 +0100
1a405f
+++ gold/options.h	2016-11-03 15:05:13.000000000 +0000
1a405f
@@ -647,7 +647,7 @@ class General_options
1a405f
   DEFINE_bool(apply_dynamic_relocs, options::TWO_DASHES, '\0', true,
1a405f
 	      N_("Apply link-time values for dynamic relocations (default)"),
1a405f
 	      N_("(aarch64 only) Do not apply link-time values "
1a405f
-	         "for dynamic relocations"));
1a405f
+		 "for dynamic relocations"));
1a405f
 
1a405f
   DEFINE_bool(as_needed, options::TWO_DASHES, '\0', false,
1a405f
 	      N_("Only set DT_NEEDED for shared libraries if used"),
1a405f
@@ -674,6 +674,9 @@ class General_options
1a405f
   DEFINE_bool_alias(dn, Bdynamic, options::ONE_DASH, '\0',
1a405f
 		    N_("alias for -Bstatic"), NULL, true);
1a405f
 
1a405f
+  DEFINE_bool(be8,options::TWO_DASHES, '\0', false,
1a405f
+	      N_("Output BE8 format image"), NULL);
1a405f
+
1a405f
   DEFINE_bool(Bgroup, options::ONE_DASH, '\0', false,
1a405f
 	      N_("Use group name lookup rules for shared library"), NULL);
1a405f
 
1a405f
@@ -1152,6 +1155,17 @@ class General_options
1a405f
   DEFINE_string(sysroot, options::TWO_DASHES, '\0', "",
1a405f
 		N_("Set target system root directory"), N_("DIR"));
1a405f
 
1a405f
+  DEFINE_bool(target1_rel, options::TWO_DASHES, '\0', false,
1a405f
+	      N_("(ARM only) Force R_ARM_TARGET1 type to R_ARM_REL32"),
1a405f
+	      NULL);
1a405f
+  DEFINE_bool(target1_abs, options::TWO_DASHES, '\0', false,
1a405f
+	      N_("(ARM only) Force R_ARM_TARGET1 type to R_ARM_ABS32"),
1a405f
+	      NULL);
1a405f
+  DEFINE_enum(target2, options::TWO_DASHES, '\0', NULL,
1a405f
+	      N_("(ARM only) Set R_ARM_TARGET2 relocation type"),
1a405f
+	      N_("[rel, abs, got-rel"),
1a405f
+	      {"rel", "abs", "got-rel"});
1a405f
+
1a405f
   DEFINE_bool(trace, options::TWO_DASHES, 't', false,
1a405f
 	      N_("Print the name of each input file"), NULL);
1a405f
 
1a405f
@@ -1293,7 +1307,7 @@ class General_options
1a405f
 	      N_("Mark output as requiring executable stack"), NULL);
1a405f
   DEFINE_bool(global, options::DASH_Z, '\0', false,
1a405f
 	      N_("Make symbols in DSO available for subsequently loaded "
1a405f
-	         "objects"), NULL);
1a405f
+		 "objects"), NULL);
1a405f
   DEFINE_bool(initfirst, options::DASH_Z, '\0', false,
1a405f
 	      N_("Mark DSO to be initialized first at runtime"),
1a405f
 	      NULL);
1a405f
@@ -1339,6 +1353,8 @@ class General_options
1a405f
   DEFINE_bool(relro, options::DASH_Z, '\0', DEFAULT_LD_Z_RELRO,
1a405f
 	      N_("Where possible mark variables read-only after relocation"),
1a405f
 	      N_("Don't mark variables read-only after relocation"));
1a405f
+  DEFINE_uint64(stack_size, options::DASH_Z, '\0', 0,
1a405f
+		N_("Set PT_GNU_STACK segment p_memsz to SIZE"), N_("SIZE"));
1a405f
   DEFINE_bool(text, options::DASH_Z, '\0', false,
1a405f
 	      N_("Do not permit relocations in read-only segments"),
1a405f
 	      N_("Permit relocations in read-only segments (default)"));
1a405f
diff -rup ../binutils-2.27/gold/output.cc gold/output.cc
1a405f
--- ../binutils-2.27/gold/output.cc	2016-08-03 08:36:53.000000000 +0100
1a405f
+++ gold/output.cc	2016-11-03 15:05:44.000000000 +0000
1a405f
@@ -4398,7 +4398,7 @@ Output_segment::set_section_addresses(co
1a405f
   this->offset_ = orig_off;
1a405f
 
1a405f
   off_t off = 0;
1a405f
-  uint64_t ret;
1a405f
+  uint64_t ret = 0;
1a405f
   for (int i = 0; i < static_cast<int>(ORDER_MAX); ++i)
1a405f
     {
1a405f
       if (i == static_cast<int>(ORDER_RELRO_LAST))
1a405f
diff -rup ../binutils-2.27/gold/output.h gold/output.h
1a405f
--- ../binutils-2.27/gold/output.h	2016-08-03 08:36:53.000000000 +0100
1a405f
+++ gold/output.h	2016-11-03 15:05:14.000000000 +0000
1a405f
@@ -2499,7 +2499,7 @@ class Output_data_got : public Output_da
1a405f
   // entry.
1a405f
   bool
1a405f
   add_local(Relobj* object, unsigned int sym_index, unsigned int got_type,
1a405f
-            uint64_t addend);
1a405f
+	    uint64_t addend);
1a405f
 
1a405f
   // Like add_local, but use the PLT offset of the local symbol if it
1a405f
   // has one.
1a405f
@@ -2643,7 +2643,7 @@ class Output_data_got : public Output_da
1a405f
 
1a405f
     // Create a local symbol entry plus addend.
1a405f
     Got_entry(Relobj* object, unsigned int local_sym_index,
1a405f
-        bool use_plt_or_tls_offset, uint64_t addend)
1a405f
+	bool use_plt_or_tls_offset, uint64_t addend)
1a405f
       : local_sym_index_(local_sym_index),
1a405f
 	use_plt_or_tls_offset_(use_plt_or_tls_offset), addend_(addend)
1a405f
     {
1a405f
@@ -4796,6 +4796,13 @@ class Output_segment
1a405f
       this->min_p_align_ = align;
1a405f
   }
1a405f
 
1a405f
+  // Set the memory size of this segment.
1a405f
+  void
1a405f
+  set_size(uint64_t size)
1a405f
+  {
1a405f
+    this->memsz_ = size;
1a405f
+  }
1a405f
+
1a405f
   // Set the offset of this segment based on the section.  This should
1a405f
   // only be called for a non-PT_LOAD segment.
1a405f
   void
1a405f
diff -rup ../binutils-2.27/gold/powerpc.cc gold/powerpc.cc
1a405f
--- ../binutils-2.27/gold/powerpc.cc	2016-09-26 11:22:18.717811369 +0100
1a405f
+++ gold/powerpc.cc	2016-11-03 15:05:45.000000000 +0000
1a405f
@@ -2439,9 +2439,8 @@ class Stub_control
1a405f
   // the stubbed branches.
1a405f
   Stub_control(int32_t size, bool no_size_errors)
1a405f
     : state_(NO_GROUP), stub_group_size_(abs(size)),
1a405f
-      stub14_group_size_(abs(size) >> 10),
1a405f
       stubs_always_before_branch_(size < 0),
1a405f
-      suppress_size_errors_(no_size_errors),
1a405f
+      suppress_size_errors_(no_size_errors), group_size_(0),
1a405f
       group_end_addr_(0), owner_(NULL), output_section_(NULL)
1a405f
   {
1a405f
   }
1a405f
@@ -2479,24 +2478,28 @@ class Stub_control
1a405f
 
1a405f
   State state_;
1a405f
   uint32_t stub_group_size_;
1a405f
-  uint32_t stub14_group_size_;
1a405f
   bool stubs_always_before_branch_;
1a405f
   bool suppress_size_errors_;
1a405f
+  // Current max size of group.  Starts at stub_group_size_ but is
1a405f
+  // reduced to stub_group_size_/1024 on seeing a section with
1a405f
+  // external conditional branches.
1a405f
+  uint32_t group_size_;
1a405f
   uint64_t group_end_addr_;
1a405f
+  // owner_ and output_section_ specify the section to which stubs are
1a405f
+  // attached.  The stubs are placed at the end of this section.
1a405f
   const Output_section::Input_section* owner_;
1a405f
   Output_section* output_section_;
1a405f
 };
1a405f
 
1a405f
 // Return true iff input section can be handled by current stub
1a405f
-// group.
1a405f
+// group.  Sections are presented to this function in reverse order,
1a405f
+// so the first section is the tail of the group.
1a405f
 
1a405f
 bool
1a405f
 Stub_control::can_add_to_stub_group(Output_section* o,
1a405f
 				    const Output_section::Input_section* i,
1a405f
 				    bool has14)
1a405f
 {
1a405f
-  uint32_t group_size
1a405f
-    = has14 ? this->stub14_group_size_ : this->stub_group_size_;
1a405f
   bool whole_sec = o->order() == ORDER_INIT || o->order() == ORDER_FINI;
1a405f
   uint64_t this_size;
1a405f
   uint64_t start_addr = o->address();
1a405f
@@ -2510,46 +2513,90 @@ Stub_control::can_add_to_stub_group(Outp
1a405f
       start_addr += i->relobj()->output_section_offset(i->shndx());
1a405f
       this_size = i->data_size();
1a405f
     }
1a405f
-  uint64_t end_addr = start_addr + this_size;
1a405f
-  bool toobig = this_size > group_size;
1a405f
 
1a405f
-  if (toobig && !this->suppress_size_errors_)
1a405f
+  uint32_t group_size = this->stub_group_size_;
1a405f
+  if (has14)
1a405f
+    this->group_size_ = group_size = group_size >> 10;
1a405f
+
1a405f
+  if (this_size > group_size && !this->suppress_size_errors_)
1a405f
     gold_warning(_("%s:%s exceeds group size"),
1a405f
 		 i->relobj()->name().c_str(),
1a405f
 		 i->relobj()->section_name(i->shndx()).c_str());
1a405f
 
1a405f
-  if (this->state_ != HAS_STUB_SECTION
1a405f
-      && (!whole_sec || this->output_section_ != o)
1a405f
-      && (this->state_ == NO_GROUP
1a405f
-	  || this->group_end_addr_ - end_addr < group_size))
1a405f
-    {
1a405f
-      this->owner_ = i;
1a405f
-      this->output_section_ = o;
1a405f
-    }
1a405f
-
1a405f
-  if (this->state_ == NO_GROUP)
1a405f
-    {
1a405f
-      this->state_ = FINDING_STUB_SECTION;
1a405f
-      this->group_end_addr_ = end_addr;
1a405f
-    }
1a405f
-  else if (this->group_end_addr_ - start_addr < group_size)
1a405f
-    ;
1a405f
-  // Adding this section would make the group larger than GROUP_SIZE.
1a405f
-  else if (this->state_ == FINDING_STUB_SECTION
1a405f
-	   && !this->stubs_always_before_branch_
1a405f
-	   && !toobig)
1a405f
-    {
1a405f
-      // But wait, there's more!  Input sections up to GROUP_SIZE
1a405f
-      // bytes before the stub table can be handled by it too.
1a405f
-      this->state_ = HAS_STUB_SECTION;
1a405f
-      this->group_end_addr_ = end_addr;
1a405f
+  gold_debug(DEBUG_TARGET, "maybe add%s %s:%s size=%#llx total=%#llx",
1a405f
+	     has14 ? " 14bit" : "",
1a405f
+	     i->relobj()->name().c_str(),
1a405f
+	     i->relobj()->section_name(i->shndx()).c_str(),
1a405f
+	     (long long) this_size,
1a405f
+	     (long long) this->group_end_addr_ - start_addr);
1a405f
+
1a405f
+  uint64_t end_addr = start_addr + this_size;
1a405f
+  if (this->state_ == HAS_STUB_SECTION)
1a405f
+    {
1a405f
+      // Can we add this section, which is before the stubs, to the
1a405f
+      // group?
1a405f
+      if (this->group_end_addr_ - start_addr <= this->group_size_)
1a405f
+	return true;
1a405f
     }
1a405f
   else
1a405f
     {
1a405f
-      this->state_ = NO_GROUP;
1a405f
-      return false;
1a405f
+      // Stubs are added at the end of "owner_".
1a405f
+      // The current section can always be the stub owner, except when
1a405f
+      // whole_sec is true and the current section isn't the last of
1a405f
+      // the pasted sections.  (This restriction for the whole_sec
1a405f
+      // case is just to simplify the corner case mentioned in
1a405f
+      // group_sections.)
1a405f
+      // Note that "owner_" itself is not necessarily part of the
1a405f
+      // group of sections served by these stubs!
1a405f
+      if (!whole_sec || this->output_section_ != o)
1a405f
+	{
1a405f
+	  this->owner_ = i;
1a405f
+	  this->output_section_ = o;
1a405f
+	}
1a405f
+
1a405f
+      if (this->state_ == FINDING_STUB_SECTION)
1a405f
+	{
1a405f
+	  if (this->group_end_addr_ - start_addr <= this->group_size_)
1a405f
+	    return true;
1a405f
+	  // The group after the stubs has reached maximum size.
1a405f
+	  // Now see about adding sections before the stubs to the
1a405f
+	  // group.  If the current section has a 14-bit branch and
1a405f
+	  // the group after the stubs exceeds group_size_ (because
1a405f
+	  // they didn't have 14-bit branches), don't add sections
1a405f
+	  // before the stubs:  The size of stubs for such a large
1a405f
+	  // group may exceed the reach of a 14-bit branch.
1a405f
+	  if (!this->stubs_always_before_branch_
1a405f
+	      && this_size <= this->group_size_
1a405f
+	      && this->group_end_addr_ - end_addr <= this->group_size_)
1a405f
+	    {
1a405f
+	      gold_debug(DEBUG_TARGET, "adding before stubs");
1a405f
+	      this->state_ = HAS_STUB_SECTION;
1a405f
+	      this->group_end_addr_ = end_addr;
1a405f
+	      return true;
1a405f
+	    }
1a405f
+	}
1a405f
+      else if (this->state_ == NO_GROUP)
1a405f
+	{
1a405f
+	  // Only here on very first use of Stub_control
1a405f
+	  this->state_ = FINDING_STUB_SECTION;
1a405f
+	  this->group_size_ = group_size;
1a405f
+	  this->group_end_addr_ = end_addr;
1a405f
+	  return true;
1a405f
+	}
1a405f
+      else
1a405f
+	gold_unreachable();
1a405f
     }
1a405f
-  return true;
1a405f
+
1a405f
+  gold_debug(DEBUG_TARGET, "nope, didn't fit\n");
1a405f
+
1a405f
+  // The section fails to fit in the current group.  Set up a few
1a405f
+  // things for the next group.  owner_ and output_section_ will be
1a405f
+  // set later after we've retrieved those values for the current
1a405f
+  // group.
1a405f
+  this->state_ = FINDING_STUB_SECTION;
1a405f
+  this->group_size_ = group_size;
1a405f
+  this->group_end_addr_ = end_addr;
1a405f
+  return false;
1a405f
 }
1a405f
 
1a405f
 // Look over all the input sections, deciding where to place stubs.
1a405f
@@ -2887,7 +2934,7 @@ Target_powerpc<size, big_endian>::do_rel
1a405f
 	}
1a405f
       this->stub_tables_.clear();
1a405f
       this->stub_group_size_ = this->stub_group_size_ / 4 * 3;
1a405f
-      gold_info(_("%s: stub group size is too large; retrying with %d"),
1a405f
+      gold_info(_("%s: stub group size is too large; retrying with %#x"),
1a405f
 		program_name, this->stub_group_size_);
1a405f
       this->group_sections(layout, task, true);
1a405f
     }
1a405f
@@ -2982,7 +3029,13 @@ Target_powerpc<size, big_endian>::do_rel
1a405f
 	      Stub_table<size, big_endian>* stub_table
1a405f
 		= static_cast<Stub_table<size, big_endian>*>(
1a405f
 		    i->relaxed_input_section());
1a405f
-	      off += stub_table->set_address_and_size(os, off);
1a405f
+	      Address stub_table_size = stub_table->set_address_and_size(os, off);
1a405f
+	      off += stub_table_size;
1a405f
+	      // After a few iterations, set current stub table size
1a405f
+	      // as min size threshold, so later stub tables can only
1a405f
+	      // grow in size.
1a405f
+	      if (pass >= 4)
1a405f
+		stub_table->set_min_size_threshold(stub_table_size);
1a405f
 	    }
1a405f
 	  else
1a405f
 	    off += i->data_size();
1a405f
@@ -3634,8 +3687,8 @@ class Stub_table : public Output_relaxed
1a405f
       targ_(targ), plt_call_stubs_(), long_branch_stubs_(),
1a405f
       orig_data_size_(owner->current_data_size()),
1a405f
       plt_size_(0), last_plt_size_(0),
1a405f
-      branch_size_(0), last_branch_size_(0), eh_frame_added_(false),
1a405f
-      need_save_res_(false)
1a405f
+      branch_size_(0), last_branch_size_(0), min_size_threshold_(0),
1a405f
+      eh_frame_added_(false), need_save_res_(false)
1a405f
   {
1a405f
     this->set_output_section(output_section);
1a405f
 
1a405f
@@ -3726,6 +3779,11 @@ class Stub_table : public Output_relaxed
1a405f
       off = align_address(off, this->stub_align());
1a405f
     // Include original section size and alignment padding in size
1a405f
     my_size += off - start_off;
1a405f
+    // Ensure new size is always larger than min size
1a405f
+    // threshold. Alignment requirement is included in "my_size", so
1a405f
+    // increase "my_size" does not invalidate alignment.
1a405f
+    if (my_size < this->min_size_threshold_)
1a405f
+      my_size = this->min_size_threshold_;
1a405f
     this->reset_address_and_file_offset();
1a405f
     this->set_current_data_size(my_size);
1a405f
     this->set_address_and_file_offset(os->address() + start_off,
1a405f
@@ -3751,6 +3809,9 @@ class Stub_table : public Output_relaxed
1a405f
   plt_size() const
1a405f
   { return this->plt_size_; }
1a405f
 
1a405f
+  void set_min_size_threshold(Address min_size)
1a405f
+  { this->min_size_threshold_ = min_size; }
1a405f
+
1a405f
   bool
1a405f
   size_update()
1a405f
   {
1a405f
@@ -4015,6 +4076,13 @@ class Stub_table : public Output_relaxed
1a405f
   section_size_type orig_data_size_;
1a405f
   // size of stubs
1a405f
   section_size_type plt_size_, last_plt_size_, branch_size_, last_branch_size_;
1a405f
+  // Some rare cases cause (PR/20529) fluctuation in stub table
1a405f
+  // size, which leads to an endless relax loop. This is to be fixed
1a405f
+  // by, after the first few iterations, allowing only increase of
1a405f
+  // stub table size. This variable sets the minimal possible size of
1a405f
+  // a stub table, it is zero for the first few iterations, then
1a405f
+  // increases monotonically.
1a405f
+  Address min_size_threshold_;
1a405f
   // Whether .eh_frame info has been created for this stub section.
1a405f
   bool eh_frame_added_;
1a405f
   // Set if this stub group needs a copy of out-of-line register
1a405f
@@ -6024,7 +6092,7 @@ Target_powerpc<size, big_endian>::Scan::
1a405f
 	  ppc_object->set_opd_discard(reloc.get_r_offset());
1a405f
 	  break;
1a405f
 	}
1a405f
-      // Fall thru
1a405f
+      // Fall through.
1a405f
     case elfcpp::R_PPC64_UADDR64:
1a405f
     case elfcpp::R_POWERPC_ADDR32:
1a405f
     case elfcpp::R_POWERPC_UADDR32:
1a405f
@@ -6131,7 +6199,7 @@ Target_powerpc<size, big_endian>::Scan::
1a405f
 		      || gsym->is_preemptible())))
1a405f
 	    target->make_plt_entry(symtab, layout, gsym);
1a405f
 	}
1a405f
-      // Fall thru
1a405f
+      // Fall through.
1a405f
 
1a405f
     case elfcpp::R_PPC64_REL64:
1a405f
     case elfcpp::R_POWERPC_REL32:
1a405f
@@ -7521,6 +7589,7 @@ Target_powerpc<size, big_endian>::Reloca
1a405f
       if (size != 64)
1a405f
 	// R_PPC_TLSGD, R_PPC_TLSLD, R_PPC_EMB_RELST_LO, R_PPC_EMB_RELST_HI
1a405f
 	break;
1a405f
+      // Fall through.
1a405f
     case elfcpp::R_POWERPC_TPREL16:
1a405f
     case elfcpp::R_POWERPC_TPREL16_LO:
1a405f
     case elfcpp::R_POWERPC_TPREL16_HI:
1a405f
@@ -7544,6 +7613,7 @@ Target_powerpc<size, big_endian>::Reloca
1a405f
 	// R_PPC_EMB_NADDR32, R_PPC_EMB_NADDR16, R_PPC_EMB_NADDR16_LO
1a405f
 	// R_PPC_EMB_NADDR16_HI, R_PPC_EMB_NADDR16_HA, R_PPC_EMB_SDAI16
1a405f
 	break;
1a405f
+      // Fall through.
1a405f
     case elfcpp::R_POWERPC_DTPREL16:
1a405f
     case elfcpp::R_POWERPC_DTPREL16_LO:
1a405f
     case elfcpp::R_POWERPC_DTPREL16_HI:
1a405f
@@ -7572,6 +7642,7 @@ Target_powerpc<size, big_endian>::Reloca
1a405f
     case elfcpp::R_POWERPC_ADDR14_BRTAKEN:
1a405f
     case elfcpp::R_POWERPC_REL14_BRTAKEN:
1a405f
       branch_bit = 1 << 21;
1a405f
+      // Fall through.
1a405f
     case elfcpp::R_POWERPC_ADDR14_BRNTAKEN:
1a405f
     case elfcpp::R_POWERPC_REL14_BRNTAKEN:
1a405f
       {
1a405f
@@ -7936,6 +8007,7 @@ Target_powerpc<size, big_endian>::Reloca
1a405f
 	  maybe_dq_reloc = true;
1a405f
 	  break;
1a405f
 	}
1a405f
+      // Fall through.
1a405f
     case elfcpp::R_POWERPC_ADDR16:
1a405f
     case elfcpp::R_POWERPC_REL16:
1a405f
     case elfcpp::R_PPC64_TOC16:
1a405f
@@ -7970,6 +8042,7 @@ Target_powerpc<size, big_endian>::Reloca
1a405f
       if (size == 32)
1a405f
 	// R_PPC_EMB_MRKREF, R_PPC_EMB_RELST_LO, R_PPC_EMB_RELST_HA
1a405f
 	goto unsupp;
1a405f
+      // Fall through.
1a405f
     case elfcpp::R_POWERPC_ADDR16_HI:
1a405f
     case elfcpp::R_POWERPC_REL16_HI:
1a405f
     case elfcpp::R_PPC64_TOC16_HI:
1a405f
@@ -7990,6 +8063,7 @@ Target_powerpc<size, big_endian>::Reloca
1a405f
       if (size == 32)
1a405f
 	// R_PPC_EMB_RELSEC16, R_PPC_EMB_RELST_HI, R_PPC_EMB_BIT_FLD
1a405f
 	goto unsupp;
1a405f
+      // Fall through.
1a405f
     case elfcpp::R_POWERPC_ADDR16_HA:
1a405f
     case elfcpp::R_POWERPC_REL16_HA:
1a405f
     case elfcpp::R_PPC64_TOC16_HA:
1a405f
@@ -8012,6 +8086,7 @@ Target_powerpc<size, big_endian>::Reloca
1a405f
       if (size == 32)
1a405f
 	// R_PPC_EMB_NADDR16_LO
1a405f
 	goto unsupp;
1a405f
+      // Fall through.
1a405f
     case elfcpp::R_PPC64_ADDR16_HIGHER:
1a405f
     case elfcpp::R_PPC64_TPREL16_HIGHER:
1a405f
       Reloc::addr16_hi2(view, value);
1a405f
@@ -8021,6 +8096,7 @@ Target_powerpc<size, big_endian>::Reloca
1a405f
       if (size == 32)
1a405f
 	// R_PPC_EMB_NADDR16_HI
1a405f
 	goto unsupp;
1a405f
+      // Fall through.
1a405f
     case elfcpp::R_PPC64_ADDR16_HIGHERA:
1a405f
     case elfcpp::R_PPC64_TPREL16_HIGHERA:
1a405f
       Reloc::addr16_ha2(view, value);
1a405f
@@ -8030,6 +8106,7 @@ Target_powerpc<size, big_endian>::Reloca
1a405f
       if (size == 32)
1a405f
 	// R_PPC_EMB_NADDR16_HA
1a405f
 	goto unsupp;
1a405f
+      // Fall through.
1a405f
     case elfcpp::R_PPC64_ADDR16_HIGHEST:
1a405f
     case elfcpp::R_PPC64_TPREL16_HIGHEST:
1a405f
       Reloc::addr16_hi3(view, value);
1a405f
@@ -8039,6 +8116,7 @@ Target_powerpc<size, big_endian>::Reloca
1a405f
       if (size == 32)
1a405f
 	// R_PPC_EMB_SDAI16
1a405f
 	goto unsupp;
1a405f
+      // Fall through.
1a405f
     case elfcpp::R_PPC64_ADDR16_HIGHESTA:
1a405f
     case elfcpp::R_PPC64_TPREL16_HIGHESTA:
1a405f
       Reloc::addr16_ha3(view, value);
1a405f
@@ -8049,11 +8127,13 @@ Target_powerpc<size, big_endian>::Reloca
1a405f
       if (size == 32)
1a405f
 	// R_PPC_EMB_NADDR32, R_PPC_EMB_NADDR16
1a405f
 	goto unsupp;
1a405f
+      // Fall through.
1a405f
     case elfcpp::R_PPC64_TPREL16_DS:
1a405f
     case elfcpp::R_PPC64_TPREL16_LO_DS:
1a405f
       if (size == 32)
1a405f
 	// R_PPC_TLSGD, R_PPC_TLSLD
1a405f
 	break;
1a405f
+      // Fall through.
1a405f
     case elfcpp::R_PPC64_ADDR16_DS:
1a405f
     case elfcpp::R_PPC64_ADDR16_LO_DS:
1a405f
     case elfcpp::R_PPC64_TOC16_DS:
1a405f
diff -rup ../binutils-2.27/gold/resolve.cc gold/resolve.cc
1a405f
--- ../binutils-2.27/gold/resolve.cc	2016-08-03 08:36:53.000000000 +0100
1a405f
+++ gold/resolve.cc	2016-11-03 15:05:47.000000000 +0000
1a405f
@@ -193,6 +193,7 @@ symbol_to_bits(elfcpp::STB binding, bool
1a405f
       // table.
1a405f
       gold_error(_("invalid STB_LOCAL symbol in external symbols"));
1a405f
       bits = global_flag;
1a405f
+      break;
1a405f
 
1a405f
     default:
1a405f
       // Any target which wants to handle STB_LOOS, etc., needs to
1a405f
diff -rup ../binutils-2.27/gold/script.cc gold/script.cc
1a405f
--- ../binutils-2.27/gold/script.cc	2016-08-03 08:36:53.000000000 +0100
1a405f
+++ gold/script.cc	2016-11-03 15:05:47.000000000 +0000
1a405f
@@ -1755,6 +1755,7 @@ script_keyword_parsecodes[] =
1a405f
   { "FLOAT", FLOAT },
1a405f
   { "FORCE_COMMON_ALLOCATION", FORCE_COMMON_ALLOCATION },
1a405f
   { "GROUP", GROUP },
1a405f
+  { "HIDDEN", HIDDEN },
1a405f
   { "HLL", HLL },
1a405f
   { "INCLUDE", INCLUDE },
1a405f
   { "INFO", INFO },
1a405f
diff -rup ../binutils-2.27/gold/script-sections.cc gold/script-sections.cc
1a405f
--- ../binutils-2.27/gold/script-sections.cc	2016-08-03 08:36:53.000000000 +0100
1a405f
+++ gold/script-sections.cc	2016-11-03 15:05:48.000000000 +0000
1a405f
@@ -1503,7 +1503,7 @@ class Input_section_info
1a405f
  private:
1a405f
   // Input section, can be a relaxed section.
1a405f
   Output_section::Input_section input_section_;
1a405f
-  // Name of the section. 
1a405f
+  // Name of the section.
1a405f
   std::string section_name_;
1a405f
   // Section size.
1a405f
   uint64_t size_;
1a405f
@@ -1545,7 +1545,7 @@ Input_section_sorter::get_init_priority(
1a405f
   // GCC uses the following section names for the init_priority
1a405f
   // attribute with numerical values 101 and 65535 inclusive. A
1a405f
   // lower value means a higher priority.
1a405f
-  // 
1a405f
+  //
1a405f
   // 1: .init_array.NNNN/.fini_array.NNNN: Where NNNN is the
1a405f
   //    decimal numerical value of the init_priority attribute.
1a405f
   //    The order of execution in .init_array is forward and
1a405f
@@ -1666,7 +1666,7 @@ Output_section_element_input::set_sectio
1a405f
   while (p != input_sections->end())
1a405f
     {
1a405f
       Relobj* relobj = p->relobj();
1a405f
-      unsigned int shndx = p->shndx();      
1a405f
+      unsigned int shndx = p->shndx();
1a405f
       Input_section_info isi(*p);
1a405f
 
1a405f
       // Calling section_name and section_addralign is not very
1a405f
@@ -1758,7 +1758,7 @@ Output_section_element_input::set_sectio
1a405f
 
1a405f
 	  uint64_t this_subalign = sis.addralign();
1a405f
 	  if (!sis.is_input_section())
1a405f
-	    sis.output_section_data()->finalize_data_size();	
1a405f
+	    sis.output_section_data()->finalize_data_size();
1a405f
 	  uint64_t data_size = sis.data_size();
1a405f
 	  if (this_subalign < subalign)
1a405f
 	    {
1a405f
@@ -2029,7 +2029,7 @@ class Output_section_definition : public
1a405f
   void
1a405f
   set_section_vma(Expression* address)
1a405f
   { this->address_ = address; }
1a405f
-  
1a405f
+
1a405f
   void
1a405f
   set_section_lma(Expression* address)
1a405f
   { this->load_address_ = address; }
1a405f
@@ -2037,7 +2037,7 @@ class Output_section_definition : public
1a405f
   const std::string&
1a405f
   get_section_name() const
1a405f
   { return this->name_; }
1a405f
-  
1a405f
+
1a405f
  private:
1a405f
   static const char*
1a405f
   script_section_type_name(Script_section_type);
1a405f
@@ -2402,9 +2402,9 @@ Output_section_definition::set_section_a
1a405f
   uint64_t old_load_address = *load_address;
1a405f
 
1a405f
   // If input section sorting is requested via --section-ordering-file or
1a405f
-  // linker plugins, then do it here.  This is important because we want 
1a405f
+  // linker plugins, then do it here.  This is important because we want
1a405f
   // any sorting specified in the linker scripts, which will be done after
1a405f
-  // this, to take precedence.  The final order of input sections is then 
1a405f
+  // this, to take precedence.  The final order of input sections is then
1a405f
   // guaranteed to be according to the linker script specification.
1a405f
   if (this->output_section_ != NULL
1a405f
       && this->output_section_->input_section_order_specified())
1a405f
@@ -2495,7 +2495,7 @@ Output_section_definition::set_section_a
1a405f
 	    // The LMA address was explicitly set to the given region.
1a405f
 	    laddr = lma_region->get_current_address()->eval(symtab, layout,
1a405f
 							    false);
1a405f
-	  else 
1a405f
+	  else
1a405f
 	    {
1a405f
 	      // We are not going to use the discovered lma_region, so
1a405f
 	      // make sure that we do not update it in the code below.
1a405f
@@ -2987,9 +2987,9 @@ Orphan_output_section::set_section_addre
1a405f
   address = align_address(address, this->os_->addralign());
1a405f
 
1a405f
   // If input section sorting is requested via --section-ordering-file or
1a405f
-  // linker plugins, then do it here.  This is important because we want 
1a405f
+  // linker plugins, then do it here.  This is important because we want
1a405f
   // any sorting specified in the linker scripts, which will be done after
1a405f
-  // this, to take precedence.  The final order of input sections is then 
1a405f
+  // this, to take precedence.  The final order of input sections is then
1a405f
   // guaranteed to be according to the linker script specification.
1a405f
   if (this->os_ != NULL
1a405f
       && this->os_->input_section_order_specified())
1a405f
@@ -3023,7 +3023,7 @@ Orphan_output_section::set_section_addre
1a405f
     {
1a405f
       uint64_t addralign = p->addralign();
1a405f
       if (!p->is_input_section())
1a405f
-	p->output_section_data()->finalize_data_size();	
1a405f
+	p->output_section_data()->finalize_data_size();
1a405f
       uint64_t size = p->data_size();
1a405f
       address = align_address(address, addralign);
1a405f
       this->os_->add_script_input_section(*p);
1a405f
@@ -3605,7 +3605,7 @@ Output_segment*
1a405f
 Script_sections::set_section_addresses(Symbol_table* symtab, Layout* layout)
1a405f
 {
1a405f
   gold_assert(this->saw_sections_clause_);
1a405f
-	 
1a405f
+
1a405f
   // Implement ONLY_IF_RO/ONLY_IF_RW constraints.  These are a pain
1a405f
   // for our representation.
1a405f
   for (Sections_elements::iterator p = this->sections_elements_->begin();
1a405f
@@ -3674,7 +3674,7 @@ Script_sections::set_section_addresses(S
1a405f
       Output_section* os = (*p)->get_output_section();
1a405f
 
1a405f
       // Handle -Ttext, -Tdata and -Tbss options.  We do this by looking for
1a405f
-      // the special sections by names and doing dot assignments. 
1a405f
+      // the special sections by names and doing dot assignments.
1a405f
       if (use_tsection_options
1a405f
 	  && os != NULL
1a405f
 	  && (os->flags() & elfcpp::SHF_ALLOC) != 0)
1a405f
@@ -3703,7 +3703,7 @@ Script_sections::set_section_addresses(S
1a405f
 
1a405f
       (*p)->set_section_addresses(symtab, layout, &dot_value, &dot_alignment,
1a405f
 				  &load_address);
1a405f
-    } 
1a405f
+    }
1a405f
 
1a405f
   if (this->phdrs_elements_ != NULL)
1a405f
     {
1a405f
@@ -3890,7 +3890,7 @@ Script_sections::create_segments(Layout*
1a405f
   layout->get_allocated_sections(&sections);
1a405f
 
1a405f
   // Sort the sections by address.
1a405f
-  std::stable_sort(sections.begin(), sections.end(), 
1a405f
+  std::stable_sort(sections.begin(), sections.end(),
1a405f
 		   Sort_output_sections(this->sections_elements_));
1a405f
 
1a405f
   this->create_note_and_tls_segments(layout, &sections);
1a405f
@@ -4217,7 +4217,7 @@ Script_sections::attach_sections_using_p
1a405f
   // Output sections in the script which do not list segments are
1a405f
   // attached to the same set of segments as the immediately preceding
1a405f
   // output section.
1a405f
-  
1a405f
+
1a405f
   String_list* phdr_names = NULL;
1a405f
   bool load_segments_only = false;
1a405f
   for (Sections_elements::const_iterator p = this->sections_elements_->begin();
1a405f
@@ -4262,7 +4262,7 @@ Script_sections::attach_sections_using_p
1a405f
       // filtering.
1a405f
       if (old_phdr_names != phdr_names)
1a405f
 	load_segments_only = false;
1a405f
-		
1a405f
+
1a405f
       // If this is an orphan section--one that was not explicitly
1a405f
       // mentioned in the linker script--then it should not inherit
1a405f
       // any segment type other than PT_LOAD.  Otherwise, e.g., the
1a405f
@@ -4459,6 +4459,7 @@ Script_sections::release_segments()
1a405f
 	   ++p)
1a405f
 	(*p)->release_segment();
1a405f
     }
1a405f
+  this->segments_created_ = false;
1a405f
 }
1a405f
 
1a405f
 // Print the SECTIONS clause to F for debugging.
1a405f
diff -rup ../binutils-2.27/gold/sparc.cc gold/sparc.cc
1a405f
--- ../binutils-2.27/gold/sparc.cc	2016-08-03 08:36:53.000000000 +0100
1a405f
+++ gold/sparc.cc	2016-11-03 15:05:48.000000000 +0000
1a405f
@@ -2150,6 +2150,7 @@ Target_sparc<size, big_endian>::Scan::ch
1a405f
 	case elfcpp::R_SPARC_RELATIVE:
1a405f
 	case elfcpp::R_SPARC_IRELATIVE:
1a405f
 	case elfcpp::R_SPARC_COPY:
1a405f
+	case elfcpp::R_SPARC_32:
1a405f
 	case elfcpp::R_SPARC_64:
1a405f
 	case elfcpp::R_SPARC_GLOB_DAT:
1a405f
 	case elfcpp::R_SPARC_JMP_SLOT:
1a405f
@@ -2304,7 +2305,7 @@ Target_sparc<size, big_endian>::Scan::lo
1a405f
 				       reloc.get_r_addend(), is_ifunc);
1a405f
 	  break;
1a405f
 	}
1a405f
-      /* Fall through.  */
1a405f
+      // Fall through.
1a405f
 
1a405f
     case elfcpp::R_SPARC_HIX22:
1a405f
     case elfcpp::R_SPARC_LOX10:
1a405f
@@ -2814,6 +2815,7 @@ Target_sparc<size, big_endian>::Scan::gl
1a405f
 	  // and code transform the GOT load into an addition.
1a405f
 	  break;
1a405f
 	}
1a405f
+      // Fall through.
1a405f
     case elfcpp::R_SPARC_GOT10:
1a405f
     case elfcpp::R_SPARC_GOT13:
1a405f
     case elfcpp::R_SPARC_GOT22:
1a405f
@@ -3353,6 +3355,7 @@ Target_sparc<size, big_endian>::Relocate
1a405f
 	  gdop_valid = true;
1a405f
 	  break;
1a405f
 	}
1a405f
+      // Fall through.
1a405f
     case elfcpp::R_SPARC_GOT10:
1a405f
     case elfcpp::R_SPARC_GOT13:
1a405f
     case elfcpp::R_SPARC_GOT22:
1a405f
@@ -3468,6 +3471,13 @@ Target_sparc<size, big_endian>::Relocate
1a405f
       Reloc::lo10(view, object, psymval, addend);
1a405f
       break;
1a405f
 
1a405f
+    case elfcpp::R_SPARC_GOTDATA_OP_LOX10:
1a405f
+      if (gdop_valid)
1a405f
+	{
1a405f
+	  Reloc::gdop_lox10(view, got_offset);
1a405f
+	  break;
1a405f
+	}
1a405f
+      // Fall through.
1a405f
     case elfcpp::R_SPARC_GOT10:
1a405f
       Reloc::lo10(view, got_offset, addend);
1a405f
       break;
1a405f
@@ -3486,13 +3496,6 @@ Target_sparc<size, big_endian>::Relocate
1a405f
 	}
1a405f
       break;
1a405f
 
1a405f
-    case elfcpp::R_SPARC_GOTDATA_OP_LOX10:
1a405f
-      if (gdop_valid)
1a405f
-	{
1a405f
-	  Reloc::gdop_lox10(view, got_offset);
1a405f
-	  break;
1a405f
-	}
1a405f
-      /* Fall through.  */
1a405f
     case elfcpp::R_SPARC_GOT13:
1a405f
       Reloc::rela32_13(view, got_offset, addend);
1a405f
       break;
1a405f
@@ -3503,7 +3506,7 @@ Target_sparc<size, big_endian>::Relocate
1a405f
 	  Reloc::gdop_hix22(view, got_offset);
1a405f
 	  break;
1a405f
 	}
1a405f
-      /* Fall through.  */
1a405f
+      // Fall through.
1a405f
     case elfcpp::R_SPARC_GOT22:
1a405f
       Reloc::hi22(view, got_offset, addend);
1a405f
       break;
1a405f
diff -rup ../binutils-2.27/gold/symtab.cc gold/symtab.cc
1a405f
--- ../binutils-2.27/gold/symtab.cc	2016-08-03 08:36:53.000000000 +0100
1a405f
+++ gold/symtab.cc	2016-11-03 15:05:49.000000000 +0000
1a405f
@@ -882,6 +882,7 @@ Symbol_table::define_default_version(Siz
1a405f
 	;
1a405f
       else if (pdef->second->is_from_dynobj()
1a405f
 	       && sym->is_from_dynobj()
1a405f
+	       && pdef->second->is_defined()
1a405f
 	       && pdef->second->object() != sym->object())
1a405f
         ;
1a405f
       else
1a405f
@@ -1325,6 +1326,9 @@ Symbol_table::add_from_relobj(
1a405f
       res = this->add_from_object(relobj, name, name_key, ver, ver_key,
1a405f
 				  is_default_version, *psym, st_shndx,
1a405f
 				  is_ordinary, orig_st_shndx);
1a405f
+
1a405f
+      if (res == NULL)
1a405f
+	continue;
1a405f
       
1a405f
       if (is_forced_local)
1a405f
 	this->force_local(res);
1a405f
@@ -1406,6 +1410,9 @@ Symbol_table::add_from_pluginobj(
1a405f
 		              is_default_version, *sym, st_shndx,
1a405f
 			      is_ordinary, st_shndx);
1a405f
 
1a405f
+  if (res == NULL)
1a405f
+    return NULL;
1a405f
+
1a405f
   if (is_forced_local)
1a405f
     this->force_local(res);
1a405f
 
1a405f
@@ -1602,6 +1609,9 @@ Symbol_table::add_from_dynobj(
1a405f
 	    }
1a405f
 	}
1a405f
 
1a405f
+      if (res == NULL)
1a405f
+	continue;
1a405f
+
1a405f
       // Note that it is possible that RES was overridden by an
1a405f
       // earlier object, in which case it can't be aliased here.
1a405f
       if (st_shndx != elfcpp::SHN_UNDEF
1a405f
@@ -1640,7 +1650,6 @@ Symbol_table::add_from_incrobj(
1a405f
 
1a405f
   Stringpool::Key ver_key = 0;
1a405f
   bool is_default_version = false;
1a405f
-  bool is_forced_local = false;
1a405f
 
1a405f
   Stringpool::Key name_key;
1a405f
   name = this->namepool_.add(name, true, &name_key);
1a405f
@@ -1650,9 +1659,6 @@ Symbol_table::add_from_incrobj(
1a405f
 		              is_default_version, *sym, st_shndx,
1a405f
 			      is_ordinary, st_shndx);
1a405f
 
1a405f
-  if (is_forced_local)
1a405f
-    this->force_local(res);
1a405f
-
1a405f
   return res;
1a405f
 }
1a405f
 
1a405f
diff -rup ../binutils-2.27/gold/tilegx.cc gold/tilegx.cc
1a405f
--- ../binutils-2.27/gold/tilegx.cc	2016-08-03 08:36:53.000000000 +0100
1a405f
+++ gold/tilegx.cc	2016-11-03 15:05:50.000000000 +0000
1a405f
@@ -4428,6 +4428,7 @@ Target_tilegx<size, big_endian>::Relocat
1a405f
       psymval = &symval;
1a405f
       always_apply_relocation = true;
1a405f
       addend = 0;
1a405f
+      // Fall through.
1a405f
 
1a405f
     // when under PIC mode, these relocations are deferred to rtld
1a405f
     case elfcpp::R_TILEGX_IMM16_X0_HW0:
1a405f
@@ -4618,6 +4619,7 @@ Target_tilegx<size, big_endian>::Relocat
1a405f
                 got_type = GOT_TYPE_TLS_OFFSET;
1a405f
                 have_got_offset = true;
1a405f
               }
1a405f
+	      // Fall through.
1a405f
             do_update_value:
1a405f
               if (have_got_offset) {
1a405f
                 if (gsym != NULL) {
1a405f
@@ -4647,10 +4649,8 @@ Target_tilegx<size, big_endian>::Relocat
1a405f
               } // else if (opt_t == tls::TLSOPT_TO_LE)
1a405f
                 //   both GD/IE are turned into LE, which
1a405f
                 //   is absolute relocation.
1a405f
-                //
1a405f
-                //  |  go through
1a405f
-                //  |
1a405f
-                //  V
1a405f
+                // Fall through.
1a405f
+
1a405f
             // LE
1a405f
             //
1a405f
             // tp
1a405f
diff -rup ../binutils-2.27/gold/x86_64.cc gold/x86_64.cc
1a405f
--- ../binutils-2.27/gold/x86_64.cc	2016-08-03 08:36:53.000000000 +0100
1a405f
+++ gold/x86_64.cc	2016-11-03 15:05:52.000000000 +0000
1a405f
@@ -2361,7 +2361,7 @@ Target_x86_64<size>::Scan::check_non_pic
1a405f
 	      && !gsym->is_undefined()
1a405f
 	      && !gsym->is_preemptible()))
1a405f
 	return;
1a405f
-      /* Fall through.  */
1a405f
+      // Fall through.
1a405f
     case elfcpp::R_X86_64_32:
1a405f
       // R_X86_64_32 is OK for x32.
1a405f
       if (size == 32 && r_type == elfcpp::R_X86_64_32)
1a405f
@@ -3505,6 +3505,7 @@ Target_x86_64<size>::Relocate::relocate(
1a405f
   if (this->skip_call_tls_get_addr_)
1a405f
     {
1a405f
       if ((r_type != elfcpp::R_X86_64_PLT32
1a405f
+	   && r_type != elfcpp::R_X86_64_GOTPCREL
1a405f
 	   && r_type != elfcpp::R_X86_64_GOTPCRELX
1a405f
 	   && r_type != elfcpp::R_X86_64_PLT32_BND
1a405f
 	   && r_type != elfcpp::R_X86_64_PC32_BND
1a405f
@@ -3514,6 +3515,7 @@ Target_x86_64<size>::Relocate::relocate(
1a405f
 	{
1a405f
 	  gold_error_at_location(relinfo, relnum, rela.get_r_offset(),
1a405f
 				 _("missing expected TLS relocation"));
1a405f
+	  this->skip_call_tls_get_addr_ = false;
1a405f
 	}
1a405f
       else
1a405f
 	{
1a405f
diff -rup ../binutils-2.27/gold/yyscript.y gold/yyscript.y
1a405f
--- ../binutils-2.27/gold/yyscript.y	2016-08-03 08:36:53.000000000 +0100
1a405f
+++ gold/yyscript.y	2016-11-03 15:05:59.000000000 +0000
1a405f
@@ -137,6 +137,7 @@
1a405f
 %token FORCE_COMMON_ALLOCATION
1a405f
 %token GLOBAL		/* global */
1a405f
 %token GROUP
1a405f
+%token HIDDEN
1a405f
 %token HLL
1a405f
 %token INCLUDE
1a405f
 %token INHIBIT_COMMON_ALLOCATION
1a405f
@@ -864,6 +865,8 @@ assignment:
1a405f
 	      Expression_ptr e = script_exp_binary_bitwise_or(s, $3);
1a405f
 	      script_set_symbol(closure, $1.value, $1.length, e, 0, 0);
1a405f
 	    }
1a405f
+	| HIDDEN '(' string '=' parse_exp ')'
1a405f
+	    { script_set_symbol(closure, $3.value, $3.length, $5, 0, 1); }
1a405f
 	| PROVIDE '(' string '=' parse_exp ')'
1a405f
 	    { script_set_symbol(closure, $3.value, $3.length, $5, 1, 0); }
1a405f
 	| PROVIDE_HIDDEN '(' string '=' parse_exp ')'
1a405f
diff -rup binutils.orig/gold/testsuite/pr18689.sh binutils-2.27/gold/testsuite/pr18689.sh
1a405f
--- binutils.orig/gold/testsuite/pr18689.sh	2017-01-17 10:17:46.062813402 +0000
1a405f
+++ gold/testsuite/pr18689.sh	2017-01-17 10:30:51.583556117 +0000
1a405f
@@ -23,6 +23,6 @@
1a405f
 
1a405f
 set -e
1a405f
 
1a405f
-egrep -q "..debug_mac[ro|info][ ]+*" pr18689.stdout
1a405f
+egrep -q "..debug_str[ ]+*" pr18689.stdout
1a405f
 
1a405f
 exit 0