lkml.org 
[lkml]   [2020]   [Apr]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v3] MIPS: Truncate link address into 32bit for 32bit kernel
On Fri, 10 Apr 2020, Kees Cook wrote:

> > diff --git a/arch/mips/kernel/Makefile b/arch/mips/kernel/Makefile
> > index d6e97df51cfb..0178f7085317 100644
> > --- a/arch/mips/kernel/Makefile
> > +++ b/arch/mips/kernel/Makefile
> > @@ -112,4 +112,13 @@ obj-$(CONFIG_MIPS_CPC) += mips-cpc.o
> > obj-$(CONFIG_CPU_PM) += pm.o
> > obj-$(CONFIG_MIPS_CPS_PM) += pm-cps.o
> >
> > -CPPFLAGS_vmlinux.lds := $(KBUILD_CFLAGS)
> > +# When linking a 32-bit executable the LLVM linker cannot cope with a
> > +# 32-bit load address that has been sign-extended to 64 bits. Simply
> > +# remove the upper 32 bits then, as it is safe to do so with other
> > +# linkers.
> > +ifdef CONFIG_64BIT
> > + load-ld = $(VMLINUX_LOAD_ADDRESS)
> > +else
> > + load-ld = $(shell $(objtree)/arch/mips/tools/truncate32 $(VMLINUX_LOAD_ADDRESS))
>
> This is major overkill. Just use the Makefile's builtin text
> manipulation:
>
> load-ld = $(subst 0xffffffff,0x,$(VMLINUX_LOAD_ADDRESS))

This looks like the best approach to me, thank you for the hint! And we
only ever want to strip 0xffffffff anyway. (I forgot about this function
of `make', doh!)

Maciej

\
 
 \ /
  Last update: 2020-04-11 01:41    [W:0.059 / U:5.776 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site