Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ELF/MIPS build fix

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 <ralf@linux-mips.org>
Reviewed-by: James Hogan <james.hogan@imgtec.com>
Cc: "Maciej W. Rozycki" <macro@linux-mips.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Ralf Baechle and committed by
Linus Torvalds
f43edca7 ededb49a

+10 -3
+1
arch/mips/Kconfig
··· 3117 3117 config BINFMT_ELF32 3118 3118 bool 3119 3119 default y if MIPS32_O32 || MIPS32_N32 3120 + select ELFCORE 3120 3121 3121 3122 endmenu 3122 3123
+8
fs/Kconfig.binfmt
··· 1 1 config BINFMT_ELF 2 2 bool "Kernel support for ELF binaries" 3 3 depends on MMU && (BROKEN || !FRV) 4 + select ELFCORE 4 5 default y 5 6 ---help--- 6 7 ELF (Executable and Linkable Format) is a format for libraries and ··· 27 26 config COMPAT_BINFMT_ELF 28 27 bool 29 28 depends on COMPAT && BINFMT_ELF 29 + select ELFCORE 30 30 31 31 config ARCH_BINFMT_ELF_STATE 32 32 bool ··· 36 34 bool "Kernel support for FDPIC ELF binaries" 37 35 default y 38 36 depends on (FRV || BLACKFIN || (SUPERH32 && !MMU) || C6X) 37 + select ELFCORE 39 38 help 40 39 ELF FDPIC binaries are based on ELF, but allow the individual load 41 40 segments of a binary to be located in memory independently of each ··· 45 42 even if data segments are not. 46 43 47 44 It is also possible to run FDPIC ELF binaries on MMU linux also. 45 + 46 + config ELFCORE 47 + bool 48 + help 49 + This option enables kernel/elfcore.o. 48 50 49 51 config CORE_DUMP_DEFAULT_ELF_HEADERS 50 52 bool "Write ELF core dumps with partial segments"
+1 -3
kernel/Makefile
··· 91 91 obj-$(CONFIG_TASKSTATS) += taskstats.o tsacct.o 92 92 obj-$(CONFIG_TRACEPOINTS) += tracepoint.o 93 93 obj-$(CONFIG_LATENCYTOP) += latencytop.o 94 - obj-$(CONFIG_BINFMT_ELF) += elfcore.o 95 - obj-$(CONFIG_COMPAT_BINFMT_ELF) += elfcore.o 96 - obj-$(CONFIG_BINFMT_ELF_FDPIC) += elfcore.o 94 + obj-$(CONFIG_ELFCORE) += elfcore.o 97 95 obj-$(CONFIG_FUNCTION_TRACER) += trace/ 98 96 obj-$(CONFIG_TRACING) += trace/ 99 97 obj-$(CONFIG_TRACE_CLOCK) += trace/