1 From 3f0a53bc6482fb09770982a8447981260ea258dc Mon Sep 17 00:00:00 2001
2 From: Yasha Cherikovsky <yasha.che3@gmail.com>
3 Date: Fri, 8 Mar 2019 14:58:51 +0200
4 Subject: MIPS: Ensure ELF appended dtb is relocated
6 From: Yasha Cherikovsky <yasha.che3@gmail.com>
8 commit 3f0a53bc6482fb09770982a8447981260ea258dc upstream.
10 This fixes booting with the combination of CONFIG_RELOCATABLE=y
11 and CONFIG_MIPS_ELF_APPENDED_DTB=y.
13 Sections that appear after the relocation table are not relocated
14 on system boot (except .bss, which has special handling).
16 With CONFIG_MIPS_ELF_APPENDED_DTB, the dtb is part of the
17 vmlinux ELF, so it must be relocated together with everything else.
19 Fixes: 069fd766271d ("MIPS: Reserve space for relocation table")
20 Signed-off-by: Yasha Cherikovsky <yasha.che3@gmail.com>
21 Signed-off-by: Paul Burton <paul.burton@mips.com>
22 Cc: Ralf Baechle <ralf@linux-mips.org>
23 Cc: Paul Burton <paul.burton@mips.com>
24 Cc: James Hogan <jhogan@kernel.org>
25 Cc: linux-mips@linux-mips.org
26 Cc: linux-kernel@vger.kernel.org
27 Cc: stable@vger.kernel.org # v4.7+
28 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
31 arch/mips/kernel/vmlinux.lds.S | 12 +++++++-----
32 1 file changed, 7 insertions(+), 5 deletions(-)
34 --- a/arch/mips/kernel/vmlinux.lds.S
35 +++ b/arch/mips/kernel/vmlinux.lds.S
36 @@ -140,6 +140,13 @@ SECTIONS
37 PERCPU_SECTION(1 << CONFIG_MIPS_L1_CACHE_SHIFT)
40 +#ifdef CONFIG_MIPS_ELF_APPENDED_DTB
41 + .appended_dtb : AT(ADDR(.appended_dtb) - LOAD_OFFSET) {
43 + KEEP(*(.appended_dtb))
47 #ifdef CONFIG_RELOCATABLE
50 @@ -164,11 +171,6 @@ SECTIONS
52 /* leave space for appended DTB */
54 -#elif defined(CONFIG_MIPS_ELF_APPENDED_DTB)
55 - .appended_dtb : AT(ADDR(.appended_dtb) - LOAD_OFFSET) {
57 - KEEP(*(.appended_dtb))
61 * Align to 64K in attempt to eliminate holes before the