diff mbox series

[v3,1/3] powerpc: Discard more sections in linker script

Message ID 20181210222854.21156-2-joel@jms.id.au (mailing list archive)
State Changes Requested
Headers show
Series powerpc: Add to linker script discards | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success next/apply_patch Successfully applied
snowpatch_ozlabs/checkpatch success total: 0 errors, 0 warnings, 0 checks, 22 lines checked

Commit Message

Joel Stanley Dec. 10, 2018, 10:28 p.m. UTC
Building the ppc64 kernel with a modern binutils results in this
warning:

 powerpc64le-linux-gnu-ld: warning: orphan section `.gnu.hash' from
 `linker stubs' being placed in section `.gnu.hash'

Alan Modra <amodra@gmail.com> explains:

 > .gnu.hash, like .hash, is used by glibc ld.so for dynamic symbol
 > lookup.  I imagine you don't need either section in a kernel, so
 > discarding both sounds reasonable.  Likely you could discard .interp
 > and .dynstr too, and .dynsym when !CONFIG_PPC32.

Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Joel Stanley <joel@jms.id.au>
---
See https://lore.kernel.org/lkml/CACPK8Xft3n5KkpTjN3=7_VUCXHFcK7mxvZm2Rrqu7tppcBoyOg@mail.gmail.com/T/#m58532c86cf0c7b4fb01cc1fe724e48d4c7d8e4a7

v3: Add dynstr hunk to this patch (it was incorrectly left in patch 2)
---
 arch/powerpc/kernel/vmlinux.lds.S | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Michael Ellerman Dec. 20, 2018, 11:18 a.m. UTC | #1
Joel Stanley <joel@jms.id.au> writes:

> Building the ppc64 kernel with a modern binutils results in this
> warning:
>
>  powerpc64le-linux-gnu-ld: warning: orphan section `.gnu.hash' from
>  `linker stubs' being placed in section `.gnu.hash'
>
> Alan Modra <amodra@gmail.com> explains:
>
>  > .gnu.hash, like .hash, is used by glibc ld.so for dynamic symbol
>  > lookup.  I imagine you don't need either section in a kernel, so
>  > discarding both sounds reasonable.  Likely you could discard .interp
>  > and .dynstr too, and .dynsym when !CONFIG_PPC32.
>
> Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
> Signed-off-by: Joel Stanley <joel@jms.id.au>
> ---
> See https://lore.kernel.org/lkml/CACPK8Xft3n5KkpTjN3=7_VUCXHFcK7mxvZm2Rrqu7tppcBoyOg@mail.gmail.com/T/#m58532c86cf0c7b4fb01cc1fe724e48d4c7d8e4a7
>
> v3: Add dynstr hunk to this patch (it was incorrectly left in patch 2)
> ---
>  arch/powerpc/kernel/vmlinux.lds.S | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)

Building ppc64le_defconfig with gcc 8.1.0 / binutils 2.30, this is giving me:

  /opt/cross/kisskb/korg/gcc-8.1.0-nolibc/powerpc64-linux/bin/powerpc64-linux-nm: .tmp_vmlinux1: attempt to load strings from a non-string section (number 0)
  /opt/cross/kisskb/korg/gcc-8.1.0-nolibc/powerpc64-linux/bin/powerpc64-linux-nm: .tmp_vmlinux1: attempt to load strings from a non-string section (number 0)
  /opt/cross/kisskb/korg/gcc-8.1.0-nolibc/powerpc64-linux/bin/powerpc64-linux-nm: .tmp_vmlinux1: attempt to load strings from a non-string section (number 0)
  /opt/cross/kisskb/korg/gcc-8.1.0-nolibc/powerpc64-linux/bin/powerpc64-linux-nm: .tmp_vmlinux1: attempt to load strings from a non-string section (number 0)
  /opt/cross/kisskb/korg/gcc-8.1.0-nolibc/powerpc64-linux/bin/powerpc64-linux-nm: .tmp_vmlinux1: attempt to load strings from a non-string section (number 0)
  /opt/cross/kisskb/korg/gcc-8.1.0-nolibc/powerpc64-linux/bin/powerpc64-linux-nm: .tmp_vmlinux1: attempt to load strings from a non-string section (number 0)
  /opt/cross/kisskb/korg/gcc-8.1.0-nolibc/powerpc64-linux/bin/powerpc64-linux-nm: .tmp_vmlinux1: attempt to load strings from a non-string section (number 0)
  /opt/cross/kisskb/korg/gcc-8.1.0-nolibc/powerpc64-linux/bin/powerpc64-linux-nm: .tmp_vmlinux1: attempt to load strings from a non-string section (number 0)
  /opt/cross/kisskb/korg/gcc-8.1.0-nolibc/powerpc64-linux/bin/powerpc64-linux-nm: .tmp_vmlinux1: attempt to load strings from a non-string section (number 0)
  /opt/cross/kisskb/korg/gcc-8.1.0-nolibc/powerpc64-linux/bin/powerpc64-linux-nm: .tmp_vmlinux2: attempt to load strings from a non-string section (number 0)
  /opt/cross/kisskb/korg/gcc-8.1.0-nolibc/powerpc64-linux/bin/powerpc64-linux-nm: .tmp_vmlinux2: attempt to load strings from a non-string section (number 0)
  /opt/cross/kisskb/korg/gcc-8.1.0-nolibc/powerpc64-linux/bin/powerpc64-linux-nm: vmlinux: attempt to load strings from a non-string section (number 0)
  /opt/cross/kisskb/korg/gcc-8.1.0-nolibc/powerpc64-linux/bin/powerpc64-linux-nm: vmlinux: attempt to load strings from a non-string section (number 0)
  /opt/cross/kisskb/korg/gcc-8.1.0-nolibc/powerpc64-linux/bin/powerpc64-linux-nm: .tmp_vmlinux2: attempt to load strings from a non-string section (number 0)
  /opt/cross/kisskb/korg/gcc-8.1.0-nolibc/powerpc64-linux/bin/powerpc64-linux-nm: .tmp_vmlinux2: attempt to load strings from a non-string section (number 0)
  /opt/cross/kisskb/korg/gcc-8.1.0-nolibc/powerpc64-linux/bin/powerpc64-linux-nm: vmlinux: attempt to load strings from a non-string section (number 0)
  /opt/cross/kisskb/korg/gcc-8.1.0-nolibc/powerpc64-linux/bin/powerpc64-linux-nm: vmlinux: attempt to load strings from a non-string section (number 0)
  /opt/cross/kisskb/korg/gcc-8.1.0-nolibc/powerpc64-linux/bin/powerpc64-linux-objdump: vmlinux: attempt to load strings from a non-string section (number 0)
  /opt/cross/kisskb/korg/gcc-8.1.0-nolibc/powerpc64-linux/bin/powerpc64-linux-objdump: vmlinux: attempt to load strings from a non-string section (number 0)
  WARNING: 2 bad relocations
  c000000001490a50 R_PPC64_ADDR64    (null)
  c000000001490a68 R_PPC64_ADDR64    (null)
  /opt/cross/kisskb/korg/gcc-8.1.0-nolibc/powerpc64-linux/bin/powerpc64-linux-objdump: vmlinux: attempt to load strings from a non-string section (number 0)
  /opt/cross/kisskb/korg/gcc-8.1.0-nolibc/powerpc64-linux/bin/powerpc64-linux-objdump: vmlinux: attempt to load strings from a non-string section (number 0)
  /opt/cross/kisskb/korg/gcc-8.1.0-nolibc/powerpc64-linux/bin/powerpc64-linux-objdump: vmlinux: attempt to load strings from a non-string section (number 0)
  /opt/cross/kisskb/korg/gcc-8.1.0-nolibc/powerpc64-linux/bin/powerpc64-linux-objdump: vmlinux: attempt to load strings from a non-string section (number 0)

Haven't had time to dig into why yet.

cheers
diff mbox series

Patch

diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
index 434581bcd5b4..779b8b3075a1 100644
--- a/arch/powerpc/kernel/vmlinux.lds.S
+++ b/arch/powerpc/kernel/vmlinux.lds.S
@@ -273,14 +273,11 @@  SECTIONS
 #endif
 		*(.dynsym)
 	}
-	.dynstr : AT(ADDR(.dynstr) - LOAD_OFFSET) { *(.dynstr) }
 	.dynamic : AT(ADDR(.dynamic) - LOAD_OFFSET)
 	{
 		__dynamic_start = .;
 		*(.dynamic)
 	}
-	.hash : AT(ADDR(.hash) - LOAD_OFFSET) { *(.hash) }
-	.interp : AT(ADDR(.interp) - LOAD_OFFSET) { *(.interp) }
 	.rela.dyn : AT(ADDR(.rela.dyn) - LOAD_OFFSET)
 	{
 		__rela_dyn_start = .;
@@ -388,5 +385,8 @@  SECTIONS
 		*(.gnu.version*)
 		*(.gnu.attributes)
 		*(.eh_frame)
+		*(.hash .gnu.hash)
+		*(.interp)
+		*(.dynstr)
 	}
 }