Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1325362
| From | James Hogan <james.hogan@imgtec.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 4/5] MIPS: Support R_MIPS_PC16 rel-style reloc |
| Date | 2016-02-03 13:50 +0100 |
| Message-ID | <qY52I-212-53@gated-at.bofh.it> (permalink) |
| References | <qXWC5-4X7-3@gated-at.bofh.it> <qXWC5-4X7-9@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
[Multipart message — attachments visible in raw view] - view raw
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
>
>
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 0/5] Support new MIPSr6 relocations Paul Burton <paul.burton@imgtec.com> - 2016-02-03 04:50 +0100
[PATCH 4/5] MIPS: Support R_MIPS_PC16 rel-style reloc Paul Burton <paul.burton@imgtec.com> - 2016-02-03 04:50 +0100
Re: [PATCH 4/5] MIPS: Support R_MIPS_PC16 rel-style reloc Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> - 2016-02-03 11:30 +0100
Re: [PATCH 4/5] MIPS: Support R_MIPS_PC16 rel-style reloc Paul Burton <paul.burton@imgtec.com> - 2016-02-03 11:40 +0100
Re: [PATCH 4/5] MIPS: Support R_MIPS_PC16 rel-style reloc Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> - 2016-02-03 11:40 +0100
Re: [PATCH 4/5] MIPS: Support R_MIPS_PC16 rel-style reloc Paul Burton <paul.burton@imgtec.com> - 2016-02-03 11:50 +0100
Re: [PATCH 4/5] MIPS: Support R_MIPS_PC16 rel-style reloc James Hogan <james.hogan@imgtec.com> - 2016-02-03 13:50 +0100
[PATCH 3/5] MIPS: Add support for 64-bit R6 ELF relocations Paul Burton <paul.burton@imgtec.com> - 2016-02-03 04:50 +0100
csiph-web