From: James Hogan <james.hogan@imgtec.com>
To: Paul Burton <paul.burton@imgtec.com>
Cc: <linux-mips@linux-mips.org>, Ralf Baechle <ralf@linux-mips.org>,
"Andrey Konovalov" <adech.fo@gmail.com>,
Andrey Ryabinin <ryabinin.a.a@gmail.com>,
<linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH 4/5] MIPS: Support R_MIPS_PC16 rel-style reloc
Date: Wed, 3 Feb 2016 12:49:40 +0000 [thread overview]
Message-ID: <20160203124940.GE5464@jhogan-linux.le.imgtec.org> (raw)
In-Reply-To: <1454471085-20963-5-git-send-email-paul.burton@imgtec.com>
[-- Attachment #1: Type: text/plain, Size: 1719 bytes --]
On Wed, Feb 03, 2016 at 03:44:44AM +0000, 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
> making use of the implicit addend from the instruction encoding.
>
> Signed-off-by: Paul Burton <paul.burton@imgtec.com>
> ---
>
> 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;
Looks correct, but presumably this could benefit from some sanity
checking like the other patches.
Cheers
James
> +
> + 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,
> --
> 2.7.0
>
>
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2016-02-03 12:49 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-03 3:44 [PATCH 0/5] Support new MIPSr6 relocations Paul Burton
2016-02-03 3:44 ` [PATCH 1/5] MIPS: Bail on unsupported module relocs Paul Burton
2016-02-03 12:23 ` James Hogan
2016-02-03 12:24 ` Maciej W. Rozycki
2016-02-03 16:15 ` Paul Burton
2016-02-03 16:55 ` Maciej W. Rozycki
2016-02-03 3:44 ` [PATCH 2/5] MIPS: module-rela: Make consistent use of pr_*() Paul Burton
2016-02-03 3:44 ` [PATCH 3/5] MIPS: Add support for 64-bit R6 ELF relocations Paul Burton
2016-02-03 3:44 ` [PATCH 4/5] MIPS: Support R_MIPS_PC16 rel-style reloc Paul Burton
2016-02-03 10:25 ` Sergei Shtylyov
2016-02-03 10:32 ` Paul Burton
2016-02-03 10:36 ` Sergei Shtylyov
2016-02-03 10:48 ` Paul Burton
2016-02-03 12:49 ` James Hogan [this message]
2016-02-03 3:44 ` [PATCH 5/5] MIPS: Implement MIPSr6 R_MIPS_PC2x rel-style relocs Paul Burton
2016-02-03 12:47 ` James Hogan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160203124940.GE5464@jhogan-linux.le.imgtec.org \
--to=james.hogan@imgtec.com \
--cc=adech.fo@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@linux-mips.org \
--cc=paul.burton@imgtec.com \
--cc=ralf@linux-mips.org \
--cc=ryabinin.a.a@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).