linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH]: ELF/MIPS build fix
@ 2016-05-20 14:17 Ralf Baechle
  2016-05-20 14:49 ` James Hogan
  2016-05-20 16:37 ` Maciej W. Rozycki
  0 siblings, 2 replies; 4+ messages in thread
From: Ralf Baechle @ 2016-05-20 14:17 UTC (permalink / raw)
  To: Alexander Viro, Andrew Morton, linux-mips, linux-kernel,
	linux-fsdevel, Maciej W. Rozycki, James Hogan, Paul.Burton

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.

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
---
 arch/mips/Kconfig | 1 +
 fs/Kconfig.binfmt | 8 ++++++++
 kernel/Makefile   | 4 +---
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 5663f41..f19e15c 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -3116,6 +3116,7 @@ config MIPS32_N32
 config BINFMT_ELF32
 	bool
 	default y if MIPS32_O32 || MIPS32_N32
+	select ELFCORE
 
 endmenu
 
diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
index 2d0cbbd..72c0335 100644
--- 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
diff --git a/kernel/Makefile b/kernel/Makefile
index f0c40bf..e2ec54e 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -91,9 +91,7 @@ obj-$(CONFIG_TASK_DELAY_ACCT) += delayacct.o
 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/

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH]: ELF/MIPS build fix
  2016-05-20 14:17 [PATCH]: ELF/MIPS build fix Ralf Baechle
@ 2016-05-20 14:49 ` James Hogan
  2016-05-20 16:37 ` Maciej W. Rozycki
  1 sibling, 0 replies; 4+ messages in thread
From: James Hogan @ 2016-05-20 14:49 UTC (permalink / raw)
  To: Ralf Baechle
  Cc: Alexander Viro, Andrew Morton, linux-mips, linux-kernel,
	linux-fsdevel, Maciej W. Rozycki, Paul.Burton

[-- Attachment #1: Type: text/plain, Size: 4047 bytes --]

On Fri, May 20, 2016 at 04:17:05PM +0200, Ralf Baechle wrote:
> 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.
> 
> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

FWIW this looks good to me,

Reviewed-by: James Hogan <james.hogan@imgtec.com>

Cheers
James

> ---
>  arch/mips/Kconfig | 1 +
>  fs/Kconfig.binfmt | 8 ++++++++
>  kernel/Makefile   | 4 +---
>  3 files changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
> index 5663f41..f19e15c 100644
> --- a/arch/mips/Kconfig
> +++ b/arch/mips/Kconfig
> @@ -3116,6 +3116,7 @@ config MIPS32_N32
>  config BINFMT_ELF32
>  	bool
>  	default y if MIPS32_O32 || MIPS32_N32
> +	select ELFCORE
>  
>  endmenu
>  
> diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
> index 2d0cbbd..72c0335 100644
> --- 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
> diff --git a/kernel/Makefile b/kernel/Makefile
> index f0c40bf..e2ec54e 100644
> --- a/kernel/Makefile
> +++ b/kernel/Makefile
> @@ -91,9 +91,7 @@ obj-$(CONFIG_TASK_DELAY_ACCT) += delayacct.o
>  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/

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH]: ELF/MIPS build fix
  2016-05-20 14:17 [PATCH]: ELF/MIPS build fix Ralf Baechle
  2016-05-20 14:49 ` James Hogan
@ 2016-05-20 16:37 ` Maciej W. Rozycki
  2016-05-20 16:40   ` Ralf Baechle
  1 sibling, 1 reply; 4+ messages in thread
From: Maciej W. Rozycki @ 2016-05-20 16:37 UTC (permalink / raw)
  To: Ralf Baechle
  Cc: Alexander Viro, Andrew Morton, linux-mips, linux-kernel,
	linux-fsdevel, James Hogan, Paul.Burton

On Fri, 20 May 2016, Ralf Baechle wrote:

> CONFIG_MIPS32_N32=y but CONFIG_BINFMT_ELF disabled results in the following
> linker errors:

 Is this for a configuration with native (n64) ELF disabled, but one or 
more compat ELF formats (o32, n32) enabled?  An interesting use case then.

  Maciej

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH]: ELF/MIPS build fix
  2016-05-20 16:37 ` Maciej W. Rozycki
@ 2016-05-20 16:40   ` Ralf Baechle
  0 siblings, 0 replies; 4+ messages in thread
From: Ralf Baechle @ 2016-05-20 16:40 UTC (permalink / raw)
  To: Maciej W. Rozycki
  Cc: Alexander Viro, Andrew Morton, linux-mips, linux-kernel,
	linux-fsdevel, James Hogan, Paul.Burton

On Fri, May 20, 2016 at 05:37:17PM +0100, Maciej W. Rozycki wrote:

> > CONFIG_MIPS32_N32=y but CONFIG_BINFMT_ELF disabled results in the following
> > linker errors:
> 
>  Is this for a configuration with native (n64) ELF disabled, but one or 
> more compat ELF formats (o32, n32) enabled?  An interesting use case then.

Yes.  Fairly sensible for one of those systems where we only support 64 bit
kernels but don't need a 64 bit userland.

  Ralf

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-05-20 16:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-20 14:17 [PATCH]: ELF/MIPS build fix Ralf Baechle
2016-05-20 14:49 ` James Hogan
2016-05-20 16:37 ` Maciej W. Rozycki
2016-05-20 16:40   ` Ralf Baechle

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).