Issue a fatal error on bad fwrite return
authorH.J. Lu <hjl.tools@gmail.com>
Thu, 25 Oct 2012 20:51:32 +0000 (20:51 +0000)
committerH.J. Lu <hjl.tools@gmail.com>
Thu, 25 Oct 2012 20:51:32 +0000 (20:51 +0000)
* dwp.cc (Dwo_file::record_target_info): Issue a fatal error
on bad fwrite return.

gold/ChangeLog
gold/dwp.cc

index 4e52f32402d0ab703b6268fc8617eb05e8947548..a15902ec59b985e31c6ee3d4b48dd6d322ca53ea 100644 (file)
@@ -1,3 +1,8 @@
+2012-10-25  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * dwp.cc (Dwo_file::record_target_info): Issue a fatal error
+       on bad fwrite return.
+
 2012-10-25  H.J. Lu  <hongjiu.lu@intel.com>
 
        * dwp.cc (Dwo_file::remap_str_offset): Use section_offset_type
index aaee4650e52ebf70421fc9e30f9a777547f9e5bb..92e3b6b84a32500954791a51d84dcfaa30a79051 100644 (file)
@@ -1458,7 +1458,9 @@ Dwp_output_file::record_target_info(const char*, int machine,
   // Write zeroes for the ELF header initially.  We'll write
   // the actual header during finalize().
   static const char buf[elfcpp::Elf_sizes<64>::ehdr_size] = { 0 };
-  ::fwrite(buf, 1, this->next_file_offset_, this->fd_);
+  if (::fwrite(buf, 1, this->next_file_offset_, this->fd_)
+      < (size_t) this->next_file_offset_)
+    gold_fatal(_("%s: %s"), this->name_, strerror(errno));
 }
 
 // Add a string to the debug strings section.
This page took 0.032562 seconds and 4 git commands to generate.