 +naclrestbp, 2, 0x01, None, 1, Cpu64, W|Modrm|No_sSuf|No_ldSuf, { Unspecified|BaseIndex|Disp8|Disp32S|Reg32, Reg64 }
 +naclrestsp, 2, 0x01, None, 1, Cpu64, W|Modrm|No_sSuf|No_ldSuf, { Unspecified|BaseIndex|Disp8|Disp32S|Reg32, Reg64 }
 +
-+// Native client string operations
++// Native client string operations.
 +cmps, 3, 0xa6, None, 1, Cpu64, W|No_sSuf|No_ldSuf|IsString, { Byte|Word|Dword|Qword|Unspecified|BaseIndex|Disp8|Disp16|Disp32|Disp32S|EsSeg, Byte|Word|Dword|Qword|Unspecified|BaseIndex|Disp8|Disp16|Disp32|Disp32S, Reg64 }
 +scmp, 3, 0xa6, None, 1, Cpu64, W|No_sSuf|No_ldSuf|IsString, { Byte|Word|Dword|Qword|Unspecified|BaseIndex|Disp8|Disp16|Disp32|Disp32S|EsSeg, Byte|Word|Dword|Qword|Unspecified|BaseIndex|Disp8|Disp16|Disp32|Disp32S, Reg64 }
 +ins, 3, 0x6c, None, 1, Cpu64, W|No_sSuf|No_qSuf|No_ldSuf|IsString, { InOutPortReg, Byte|Word|Dword|Unspecified|BaseIndex|Disp8|Disp16|Disp32|Disp32S|EsSeg, Reg64 }

 <EXPRESSION,BOTH,SCRIPT>"ASSERT"	{ RTOKEN(ASSERT_K); }
 <BOTH,SCRIPT>"ENTRY"			{ RTOKEN(ENTRY);}
 <BOTH,SCRIPT,MRI>"EXTERN"		{ RTOKEN(EXTERN);}
diff -Naur ../PRISTINE/binutils-2.20/ld/scripttempl/naclelf.sc binutils-2.20/ld/scripttempl/naclelf.sc
--- ../PRISTINE/binutils-2.20/ld/scripttempl/naclelf.sc	1969-12-31 16:00:00.000000000 -0800
+++ binutils-2.20/ld/scripttempl/naclelf.sc	2010-01-05 13:21:03.846110000 -0800

diff -Naur ../PRISTINE/binutils-2.20/bfd/elf.c binutils-2.20/bfd/elf.c
--- ../PRISTINE/binutils-2.20/bfd/elf.c	2009-09-10 13:47:12.000000000 +0200
+++ binutils-2.20/bfd/elf.c	2010-05-17 17:38:36.000000000 +0200
@@ -7258,6 +7258,8 @@
   return ret;
 }
 
+int _bfd_elf_set_section_contents_hlts = 0;
+
 bfd_boolean
 _bfd_elf_set_section_contents (bfd *abfd,
 			       sec_ptr section,
@@ -7274,6 +7276,34 @@
 
   hdr = &elf_section_data (section)->this_hdr;
   pos = hdr->sh_offset + offset;
+
+  /* TODO(khim): make the behaviour configurable */
+  if (_bfd_elf_set_section_contents_hlts)
+    {
+      bfd_signed_vma hlts_pos = ((pos + count - 1) & ~0xFFFF) + 0xFFE0;
+      static unsigned char HLTs[0x20] = {
+        0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4,
+        0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4,
+        0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4,
+        0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4
+      };
+      if (hlts_pos > pos)
+        {
+          if ((bfd_get_section_flags (abfd, section) & SEC_CODE) &&
+              (bfd_seek (abfd, hlts_pos, SEEK_SET) != 0
+               || bfd_bwrite(HLTs, 0x20, abfd) != 0x20))
+           return FALSE;
+        }
+      else
+        {
+          bfd_size_type hlts_count = 0x20 + hlts_pos - pos;
+          if ((bfd_get_section_flags (abfd, section) & SEC_CODE) &&
+              (bfd_seek (abfd, pos, SEEK_SET) != 0
+               || bfd_bwrite(HLTs, hlts_count, abfd) != hlts_count))
+          return FALSE;
+        }
+    }
+
   if (bfd_seek (abfd, pos, SEEK_SET) != 0
       || bfd_bwrite (location, count, abfd) != count)
