This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [gold commit] PR 21040: Fix compile errors with GCC 4.2
- From: Alan Modra <amodra at gmail dot com>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: Cary Coutant <ccoutant at gmail dot com>, Binutils <binutils at sourceware dot org>
- Date: Fri, 13 Jan 2017 10:12:14 +1030
- Subject: Re: [gold commit] PR 21040: Fix compile errors with GCC 4.2
- Authentication-results: sourceware.org; auth=none
- References: <CAJimCsGJ5pPsLOzK9Vcbyr=Rw45=c72G=RZ_RWyq2jUHTomimQ@mail.gmail.com> <CAMe9rOpLyFkR24tGLxjsBks77CYz1oydmsTydWFUH=APSuHagw@mail.gmail.com> <CAJimCsGte0kRvM=vMx5KbDUzM2K6q4bwp_MpbGG=J-UmHjXmTg@mail.gmail.com> <CAMe9rOqCgtsxuJW80Uz9oqJ0Cu8SWd_X_koQ_p_+bwHemLjoPw@mail.gmail.com>
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