From f455adfd91eccb035749a32cab6715aff8b3d7c6 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 8 Feb 2021 10:58:26 +0100 Subject: [PATCH] 4.4-stable patches added patches: elf-mips-build-fix.patch elfcore-fix-building-with-clang.patch --- queue-4.4/elf-mips-build-fix.patch | 110 ++++++++++++++++++ .../elfcore-fix-building-with-clang.patch | 109 +++++++++++++++++ queue-4.4/series | 2 + 3 files changed, 221 insertions(+) create mode 100644 queue-4.4/elf-mips-build-fix.patch create mode 100644 queue-4.4/elfcore-fix-building-with-clang.patch diff --git a/queue-4.4/elf-mips-build-fix.patch b/queue-4.4/elf-mips-build-fix.patch new file mode 100644 index 00000000000..df23949803b --- /dev/null +++ b/queue-4.4/elf-mips-build-fix.patch @@ -0,0 +1,110 @@ +From f43edca7ed08fc02279f2a62015da5cb6aa0ad61 Mon Sep 17 00:00:00 2001 +From: Ralf Baechle +Date: Mon, 23 May 2016 16:22:26 -0700 +Subject: ELF/MIPS build fix + +From: Ralf Baechle + +commit f43edca7ed08fc02279f2a62015da5cb6aa0ad61 upstream. + +CONFIG_MIPS32_N32=y but CONFIG_BINFMT_ELF disabled results in the +following linker errors: + + arch/mips/built-in.o: In function `elf_core_dump': + binfmt_elfn32.c:(.text+0x23dbc): undefined reference to `elf_core_extra_phdrs' + binfmt_elfn32.c:(.text+0x246e4): undefined reference to `elf_core_extra_data_size' + binfmt_elfn32.c:(.text+0x248d0): undefined reference to `elf_core_write_extra_phdrs' + binfmt_elfn32.c:(.text+0x24ac4): undefined reference to `elf_core_write_extra_data' + +CONFIG_MIPS32_O32=y but CONFIG_BINFMT_ELF disabled results in the following +linker errors: + + arch/mips/built-in.o: In function `elf_core_dump': + binfmt_elfo32.c:(.text+0x28a04): undefined reference to `elf_core_extra_phdrs' + binfmt_elfo32.c:(.text+0x29330): undefined reference to `elf_core_extra_data_size' + binfmt_elfo32.c:(.text+0x2951c): undefined reference to `elf_core_write_extra_phdrs' + binfmt_elfo32.c:(.text+0x29710): undefined reference to `elf_core_write_extra_data' + +This is because binfmt_elfn32 and binfmt_elfo32 are using symbols from +elfcore but for these configurations elfcore will not be built. + +Fixed by making elfcore selectable by a separate config symbol which +unlike the current mechanism can also be used from other directories +than kernel/, then having each flavor of ELF that relies on elfcore.o, +select it in Kconfig, including CONFIG_MIPS32_N32 and CONFIG_MIPS32_O32 +which fixes this issue. + +Link: http://lkml.kernel.org/r/20160520141705.GA1913@linux-mips.org +Signed-off-by: Ralf Baechle +Reviewed-by: James Hogan +Cc: "Maciej W. Rozycki" +Signed-off-by: Andrew Morton +Signed-off-by: Linus Torvalds +Signed-off-by: Greg Kroah-Hartman +--- + arch/mips/Kconfig | 1 + + fs/Kconfig.binfmt | 8 ++++++++ + kernel/Makefile | 4 +--- + 3 files changed, 10 insertions(+), 3 deletions(-) + +--- a/arch/mips/Kconfig ++++ b/arch/mips/Kconfig +@@ -2990,6 +2990,7 @@ config MIPS32_N32 + config BINFMT_ELF32 + bool + default y if MIPS32_O32 || MIPS32_N32 ++ select ELFCORE + + endmenu + +--- a/fs/Kconfig.binfmt ++++ b/fs/Kconfig.binfmt +@@ -1,6 +1,7 @@ + config BINFMT_ELF + bool "Kernel support for ELF binaries" + depends on MMU && (BROKEN || !FRV) ++ select ELFCORE + default y + ---help--- + ELF (Executable and Linkable Format) is a format for libraries and +@@ -26,6 +27,7 @@ config BINFMT_ELF + config COMPAT_BINFMT_ELF + bool + depends on COMPAT && BINFMT_ELF ++ select ELFCORE + + config ARCH_BINFMT_ELF_STATE + bool +@@ -34,6 +36,7 @@ config BINFMT_ELF_FDPIC + bool "Kernel support for FDPIC ELF binaries" + default y + depends on (FRV || BLACKFIN || (SUPERH32 && !MMU) || C6X) ++ select ELFCORE + help + ELF FDPIC binaries are based on ELF, but allow the individual load + segments of a binary to be located in memory independently of each +@@ -43,6 +46,11 @@ config BINFMT_ELF_FDPIC + + It is also possible to run FDPIC ELF binaries on MMU linux also. + ++config ELFCORE ++ bool ++ help ++ This option enables kernel/elfcore.o. ++ + config CORE_DUMP_DEFAULT_ELF_HEADERS + bool "Write ELF core dumps with partial segments" + default y +--- a/kernel/Makefile ++++ b/kernel/Makefile +@@ -77,9 +77,7 @@ obj-$(CONFIG_TASK_DELAY_ACCT) += delayac + obj-$(CONFIG_TASKSTATS) += taskstats.o tsacct.o + obj-$(CONFIG_TRACEPOINTS) += tracepoint.o + obj-$(CONFIG_LATENCYTOP) += latencytop.o +-obj-$(CONFIG_BINFMT_ELF) += elfcore.o +-obj-$(CONFIG_COMPAT_BINFMT_ELF) += elfcore.o +-obj-$(CONFIG_BINFMT_ELF_FDPIC) += elfcore.o ++obj-$(CONFIG_ELFCORE) += elfcore.o + obj-$(CONFIG_FUNCTION_TRACER) += trace/ + obj-$(CONFIG_TRACING) += trace/ + obj-$(CONFIG_TRACE_CLOCK) += trace/ diff --git a/queue-4.4/elfcore-fix-building-with-clang.patch b/queue-4.4/elfcore-fix-building-with-clang.patch new file mode 100644 index 00000000000..a6a31e5cb22 --- /dev/null +++ b/queue-4.4/elfcore-fix-building-with-clang.patch @@ -0,0 +1,109 @@ +From 6e7b64b9dd6d96537d816ea07ec26b7dedd397b9 Mon Sep 17 00:00:00 2001 +From: Arnd Bergmann +Date: Fri, 11 Dec 2020 13:36:46 -0800 +Subject: elfcore: fix building with clang + +From: Arnd Bergmann + +commit 6e7b64b9dd6d96537d816ea07ec26b7dedd397b9 upstream. + +kernel/elfcore.c only contains weak symbols, which triggers a bug with +clang in combination with recordmcount: + + Cannot find symbol for section 2: .text. + kernel/elfcore.o: failed + +Move the empty stubs into linux/elfcore.h as inline functions. As only +two architectures use these, just use the architecture specific Kconfig +symbols to key off the declaration. + +Link: https://lkml.kernel.org/r/20201204165742.3815221-2-arnd@kernel.org +Signed-off-by: Arnd Bergmann +Cc: Nathan Chancellor +Cc: Nick Desaulniers +Cc: Barret Rhoden +Signed-off-by: Andrew Morton +Signed-off-by: Linus Torvalds +Signed-off-by: Greg Kroah-Hartman +--- + include/linux/elfcore.h | 22 ++++++++++++++++++++++ + kernel/Makefile | 1 - + kernel/elfcore.c | 25 ------------------------- + 3 files changed, 22 insertions(+), 26 deletions(-) + delete mode 100644 kernel/elfcore.c + +--- a/include/linux/elfcore.h ++++ b/include/linux/elfcore.h +@@ -55,6 +55,7 @@ static inline int elf_core_copy_task_xfp + } + #endif + ++#if defined(CONFIG_UM) || defined(CONFIG_IA64) + /* + * These functions parameterize elf_core_dump in fs/binfmt_elf.c to write out + * extra segments containing the gate DSO contents. Dumping its +@@ -69,5 +70,26 @@ elf_core_write_extra_phdrs(struct coredu + extern int + elf_core_write_extra_data(struct coredump_params *cprm); + extern size_t elf_core_extra_data_size(void); ++#else ++static inline Elf_Half elf_core_extra_phdrs(void) ++{ ++ return 0; ++} ++ ++static inline int elf_core_write_extra_phdrs(struct coredump_params *cprm, loff_t offset) ++{ ++ return 1; ++} ++ ++static inline int elf_core_write_extra_data(struct coredump_params *cprm) ++{ ++ return 1; ++} ++ ++static inline size_t elf_core_extra_data_size(void) ++{ ++ return 0; ++} ++#endif + + #endif /* _LINUX_ELFCORE_H */ +--- a/kernel/Makefile ++++ b/kernel/Makefile +@@ -77,7 +77,6 @@ obj-$(CONFIG_TASK_DELAY_ACCT) += delayac + obj-$(CONFIG_TASKSTATS) += taskstats.o tsacct.o + obj-$(CONFIG_TRACEPOINTS) += tracepoint.o + obj-$(CONFIG_LATENCYTOP) += latencytop.o +-obj-$(CONFIG_ELFCORE) += elfcore.o + obj-$(CONFIG_FUNCTION_TRACER) += trace/ + obj-$(CONFIG_TRACING) += trace/ + obj-$(CONFIG_TRACE_CLOCK) += trace/ +--- a/kernel/elfcore.c ++++ /dev/null +@@ -1,25 +0,0 @@ +-#include +-#include +-#include +-#include +-#include +- +-Elf_Half __weak elf_core_extra_phdrs(void) +-{ +- return 0; +-} +- +-int __weak elf_core_write_extra_phdrs(struct coredump_params *cprm, loff_t offset) +-{ +- return 1; +-} +- +-int __weak elf_core_write_extra_data(struct coredump_params *cprm) +-{ +- return 1; +-} +- +-size_t __weak elf_core_extra_data_size(void) +-{ +- return 0; +-} diff --git a/queue-4.4/series b/queue-4.4/series index 91b1e49ea77..dd9c7ab7dca 100644 --- a/queue-4.4/series +++ b/queue-4.4/series @@ -18,3 +18,5 @@ usb-serial-cp210x-add-new-vid-pid-for-supporting-teraoka-ad2000.patch usb-serial-option-adding-support-for-cinterion-mv31.patch input-i8042-unbreak-pegatron-c15b.patch net-lapb-copy-the-skb-before-sending-a-packet.patch +elf-mips-build-fix.patch +elfcore-fix-building-with-clang.patch -- 2.47.3