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]

[PATCH] gold: fix some signed-unsigned comparison warnings


I got some warnings (errors, given default -Werror) when compiling gold
with gcc 4.7.0.

Ok for trunk?


Thanks,
Roland


gold/
2012-11-01  Roland McGrath  <mcgrathr@google.com>

	* arm.cc (relocate_special_relocatable): Cast INVALID_ADDRESS to off_t
	before comparing it to OFFSET_IN_OUTPUT_SECTION.
	* dwarf_reader.cc (Sized_elf_reloc_mapper::symbol_section): Cast
	SYMNDX to off_t before comparing it to this->data_size().
	* output.cc (Output_symtab_xindex::endian_do_write): Likewise.
	* incremental.cc (Output_section_incremental_inputs::do_write):
	Cast GLOBAL_SYM_COUNT to off_t before comparing it to SYMTAB_SIZE.


diff --git a/gold/arm.cc b/gold/arm.cc
index 5770c8a..d53ef6b 100644
--- a/gold/arm.cc
+++ b/gold/arm.cc
@@ -9688,7 +9688,7 @@ Target_arm<big_endian>::relocate_special_relocatable(

   Arm_address offset = reloc.get_r_offset();
   Arm_address new_offset;
-  if (offset_in_output_section != invalid_address)
+  if (offset_in_output_section != (off_t) invalid_address)
     new_offset = offset + offset_in_output_section;
   else
     {
@@ -9707,7 +9707,7 @@ Target_arm<big_endian>::relocate_special_relocatable(
   if (!parameters->options().relocatable())
     {
       new_offset += view_address;
-      if (offset_in_output_section != invalid_address)
+      if (offset_in_output_section != (off_t) invalid_address)
 	new_offset -= offset_in_output_section;
     }

diff --git a/gold/dwarf_reader.cc b/gold/dwarf_reader.cc
index c80e8cb..50942d6 100644
--- a/gold/dwarf_reader.cc
+++ b/gold/dwarf_reader.cc
@@ -57,7 +57,7 @@ Sized_elf_reloc_mapper<size, big_endian>::symbol_section(
     unsigned int symndx, Address* value, bool* is_ordinary)
 {
   const int symsize = elfcpp::Elf_sizes<size>::sym_size;
-  gold_assert((symndx + 1) * symsize <= this->symtab_size_);
+  gold_assert((off_t) ((symndx + 1) * symsize) <= this->symtab_size_);
   elfcpp::Sym<size, big_endian> elfsym(this->symtab_ + symndx * symsize);
   *value = elfsym.get_st_value();
   return this->object_->adjust_sym_shndx(symndx, elfsym.get_st_shndx(),
diff --git a/gold/incremental.cc b/gold/incremental.cc
index acabaea..9898434 100644
--- a/gold/incremental.cc
+++ b/gold/incremental.cc
@@ -1432,7 +1432,7 @@ Output_section_incremental_inputs<size,
big_endian>::do_write(Output_file* of)
   gold_assert(pov - oview == oview_size);

   // Write the .gnu_incremental_symtab section.
-  gold_assert(global_sym_count * 4 == symtab_size);
+  gold_assert((off_t) global_sym_count * 4 == symtab_size);
   this->write_symtab(symtab_view, global_syms, global_sym_count);

   delete[] global_syms;
diff --git a/gold/output.cc b/gold/output.cc
index 6e5cd25..24bc6d6 100644
--- a/gold/output.cc
+++ b/gold/output.cc
@@ -1935,7 +1935,7 @@ Output_symtab_xindex::endian_do_write(unsigned
char* const oview)
        ++p)
     {
       unsigned int symndx = p->first;
-      gold_assert(symndx * 4 < this->data_size());
+      gold_assert((off_t) symndx * 4 < this->data_size());
       elfcpp::Swap<32, big_endian>::writeval(oview + symndx * 4, p->second);
     }
 }


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