Subject: Re: powerpc/ppc64: Allow allmodconfig to build (finally !)

From: Guenter Roeck <[email-masked]>
Date: Wed, 14 May 2014 08:34:30 -0700

On Wed, May 14, 2014 at 03:22:19PM +0930, Alan Modra wrote:
> On Tue, May 13, 2014 at 10:16:51PM -0700, Guenter Roeck wrote:
> > any idea what might cause this one, by any chance ?
> > 
> > arch/powerpc/kernel/built-in.o: In function `exc_debug_crit_book3e':
> > (.text+0x165ee): relocation truncated to fit: R_PPC64_ADDR16_HI against symbol `interrupt_base_book3e' defined in .text section in arch/powerpc/kernel/built-in.o
> > arch/powerpc/kernel/built-in.o: In function `exc_debug_crit_book3e':
> > (.text+0x16602): relocation truncated to fit: R_PPC64_ADDR16_HI against symbol `interrupt_end_book3e' defined in .text section in arch/powerpc/kernel/built-in.o
> > arch/powerpc/kernel/built-in.o: In function `exc_debug_debug_book3e':
> > 
> > I see this if I try to build powerpc:ppc64e_defconfig or powerpc:chroma_defconfig
> > with gcc 4.8.2 and binutils 2.24.
> 
> Blame me.  I changed the ABI, something that had to be done but
> unfortunately happens to break the booke kernel code.  When building
> up a 64-bit value with lis, ori, shl, oris, ori or similar sequences,
> you now should use @high and @higha in place of @h and @ha.  @h and
> @ha (and their associated relocs R_PPC64_ADDR16_HI and
> R_PPC64_ADDR16_HA) now report overflow if the value is out of 32-bit
> signed range.  ie. @h and @ha assume you're building a 32-bit value.
> This is needed to report out-of-range -mcmodel=medium toc pointer
> offsets in @toc@h and @toc@ha expressions, and for consistency I did
> the same for all other @h and @ha relocs.
> 

Bummer. Confirmed, if I replace "@h" with "@high" in just one place,
the builds pass with binutils 2.24. Unfortunately the same builds then
fails with binutils 2.23.

Any idea how to get it to compile with both old and new versions ?
Is there some predefined constant which I could possibly use for
something like

.if as_version_below_2.24_
	oris    reg,reg,(expr)@h;
.else
	oris    reg,reg,(expr)@high;
.endif

Thanks,
Guenter