This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch 6/7] [gold] Add initial source code for dwp utility.


On Wed, Oct 24, 2012 at 5:10 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Thu, Oct 18, 2012 at 11:16 AM, Cary Coutant <ccoutant@google.com> wrote:
>> This patch adds the new source files for the dwp utility itself, and updates
>> the gold Makefiles to build it.
>>
>> gold/
>>         * dwp.h: New header file.
>>         * dwp.cc: New source file.
>>         * Makefile.am: Add dwp.
>>         * Makefile.in: Regenerate.
>> ---
>>  gold/Makefile.am |    6 +-
>>  gold/Makefile.in |   22 +-
>>  gold/dwp.cc      | 2036 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
>>  gold/dwp.h       |  222 ++++++
>>  4 files changed, 2280 insertions(+), 6 deletions(-)
>>  create mode 100644 gold/dwp.cc
>>  create mode 100644 gold/dwp.h
>>
>
> It failed to build on 32-bit host:
>
> g++ -m32  -DHAVE_CONFIG_H -I.
> -I/export/linux/src/binutils/binutils/gold
> -I/export/linux/src/binutils/binutils/gold
> -I/export/linux/src/binutils/binutils/gold/../include
> -I/export/linux/src/binutils/binutils/gold/../elfcpp
> -DLOCALEDIR="\"/usr/local32/share/locale\""
> -DBINDIR="\"/usr/local32/bin\""
> -DTOOLBINDIR="\"/usr/local32/i686-linux/bin\""
> -DTOOLLIBDIR="\"/usr/local32/i686-linux/lib\""   -W -Wall    -Werror
> -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -frandom-seed=dwp.o -g -O2
> -MT dwp.o -MD -MP -MF .deps/dwp.Tpo -c -o dwp.o
> /export/linux/src/binutils/binutils/gold/dwp.cc
> /export/linux/src/binutils/binutils/gold/dwp.cc: In member function
> ‘unsigned int gold::Dwo_file::remap_str_offset(unsigned int)’:
> /export/linux/src/binutils/binutils/gold/dwp.cc:1334:54: error:
> comparison between signed and unsigned integer expressions
> [-Werror=sign-compare]
> /export/linux/src/binutils/binutils/gold/dwp.cc:1339:7: error:
> comparison between signed and unsigned integer expressions
> [-Werror=sign-compare]
>
>

Another problem:

g++ -DHAVE_CONFIG_H -I. -I/export/linux/src/binutils/binutils/gold
-I/export/linux/src/binutils/binutils/gold
-I/export/linux/src/binutils/binutils/gold/../include
-I/export/linux/src/binutils/binutils/gold/../elfcpp
-DLOCALEDIR="\"/usr/local/share/locale\""
-DBINDIR="\"/usr/local/bin\""
-DTOOLBINDIR="\"/usr/local/x86_64-unknown-linux-gnu/bin\""
-DTOOLLIBDIR="\"/usr/local/x86_64-unknown-linux-gnu/lib\""   -W -Wall
  -Werror -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
-frandom-seed=dwp.o  -MT dwp.o -MD -MP -MF .deps/dwp.Tpo -c -o dwp.o
/export/linux/src/binutils/binutils/gold/dwp.cc
-Wp,-D_FORTIFY_SOURCE=2
-O2
/export/linux/src/binutils/binutils/gold/dwp.cc: In member function
‘void gold::Dwp_output_file::record_target_info(const char*, int, int,
bool, int, int)’:
/export/linux/src/binutils/binutils/gold/dwp.cc:1461:55: error:
ignoring return value of ‘size_t fwrite(const void*, size_t, size_t,
FILE*)’, declared with attribute warn_unused_result
[-Werror=unused-result]
cc1plus: all warnings being treated as errors

This patch works for me.  OK to install?

Thanks.

-- 
H.J.
---
2012-10-24  H.J. Lu  <hongjiu.lu@intel.com>

	* dwp.cc (Dwo_file::record_target_info): Issue a fatal error
	on bad fwrite return.

diff --git a/gold/dwp.cc b/gold/dwp.cc
index 445d1af..92e3b6b 100644
--- a/gold/dwp.cc
+++ b/gold/dwp.cc
@@ -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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]