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: [gold commit] PR 21040: Fix compile errors with GCC 4.2


On Thu, Jan 12, 2017 at 08:27:37AM -0800, H.J. Lu wrote:
> I still got
> 
> /export/gnu/import/git/sources/binutils-gdb/gold/powerpc.cc:8783:
> instantiated from ‘void<unnamed>::Target_powerpc<size,
> big_endian>::relocate_section(const gold::Relocate_info<size,
> big_endian>*, unsigned int, const unsigned char*, size_t,
> gold::Output_section*, bool, unsigned char*, typename
> elfcpp::Elf_types<size>::Elf_Addr, gold::section_size_type, const
> gold::Reloc_symbol_changes*) [with int size = 32, bool big_endian =
> true]’
> /export/gnu/import/git/sources/binutils-gdb/gold/powerpc.cc:9411:
> instantiated from here
> /export/gnu/import/git/sources/binutils-gdb/gold/powerpc.cc:2013:
> warning: comparison is always false due to limited range of data type
> make: *** [powerpc.o] Error 1
> 
> This patch:
> 
> 
> diff --git a/gold/powerpc.cc b/gold/powerpc.cc
> index 3e4e08b..a67c336 100644
> --- a/gold/powerpc.cc
> +++ b/gold/powerpc.cc
> @@ -2010,7 +2010,7 @@ Powerpc_relobj<size, big_endian>::make_toc_relative(
>    Address got_base = (target->got_section()->output_section()->address()
>             + this->toc_base_offset());
>    addr -= got_base;
> -  if (addr + 0x80008000 >= (uint64_t) 1 << 32)
> +  if (addr + (uint64_t) 0x80008000 >= (uint64_t) 1 << 32)
>      return false;
> 
>    *value = addr;
> 
> works for me.

Believe it or not, I originally wrote it exactly as in your patch,
then decided the cast wasn't necessary.  Which is actually true
because the function is templated and "if (size != 64) return false"
before this means the 32-bit warning is a false positive.

Please apply, branch too.

-- 
Alan Modra
Australia Development Lab, IBM


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