From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756701AbcBCK0F (ORCPT ); Wed, 3 Feb 2016 05:26:05 -0500 Received: from mail-lb0-f176.google.com ([209.85.217.176]:33225 "EHLO mail-lb0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756316AbcBCK0B (ORCPT ); Wed, 3 Feb 2016 05:26:01 -0500 Subject: Re: [PATCH 4/5] MIPS: Support R_MIPS_PC16 rel-style reloc To: Paul Burton , linux-mips@linux-mips.org, Ralf Baechle References: <1454471085-20963-1-git-send-email-paul.burton@imgtec.com> <1454471085-20963-5-git-send-email-paul.burton@imgtec.com> Cc: Andrey Konovalov , Andrey Ryabinin , linux-kernel@vger.kernel.org, Andrew Morton From: Sergei Shtylyov Message-ID: <56B1D5B5.6050208@cogentembedded.com> Date: Wed, 3 Feb 2016 13:25:57 +0300 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <1454471085-20963-5-git-send-email-paul.burton@imgtec.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello. On 2/3/2016 6:44 AM, Paul Burton wrote: > MIPS32 code uses rel-style relocs, and MIPS32r6 modules may include the > R_MIPS_PC16 relocation. We thus need to support R_MIPS_PC16 rel-style > relocations in order to load MIPS32r6 kernel modules. This patch adds > such support, which is similar to the rela-style R_MIPS_PC16 support but R_MIPS_LO16, you mean? > making use of the implicit addend from the instruction encoding. > > Signed-off-by: Paul Burton > --- > > arch/mips/kernel/module.c | 14 +++++++++++++- > 1 file changed, 13 insertions(+), 1 deletion(-) > > diff --git a/arch/mips/kernel/module.c b/arch/mips/kernel/module.c > index 2adf572..f2de9b8 100644 > --- a/arch/mips/kernel/module.c > +++ b/arch/mips/kernel/module.c > @@ -183,13 +183,25 @@ out_danger: > return -ENOEXEC; > } > > +static int apply_r_mips_pc16_rel(struct module *me, u32 *location, Elf_Addr v) > +{ > + u16 val; > + > + val = *location; > + val += (v - (Elf_Addr)location) >> 2; > + *location = (*location & 0xffff0000) | val; > + > + return 0; > +} > + > static int (*reloc_handlers_rel[]) (struct module *me, u32 *location, > Elf_Addr v) = { > [R_MIPS_NONE] = apply_r_mips_none, > [R_MIPS_32] = apply_r_mips_32_rel, > [R_MIPS_26] = apply_r_mips_26_rel, > [R_MIPS_HI16] = apply_r_mips_hi16_rel, > - [R_MIPS_LO16] = apply_r_mips_lo16_rel > + [R_MIPS_LO16] = apply_r_mips_lo16_rel, > + [R_MIPS_PC16] = apply_r_mips_pc16_rel, > }; > > int apply_relocate(Elf_Shdr *sechdrs, const char *strtab, MBR, Sergei