linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/3] powerpc: Add to linker script discards
@ 2018-12-10 22:28 Joel Stanley
  2018-12-10 22:28 ` [PATCH v3 1/3] powerpc: Discard more sections in linker script Joel Stanley
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Joel Stanley @ 2018-12-10 22:28 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Stephen Rothwell, Alan Modra

v3 fixes up the splitting of the patches, moving the dynstr hunk from
patch 2 to patch 1.

v2 pulls in the branch_lt patch too. No changes to the first two
patches.

Joel Stanley (3):
  powerpc: Discard more sections in linker script
  powerpc: Discard dynsym section for !PPC32
  powerpc: Discard .branch_lt section

 arch/powerpc/kernel/vmlinux.lds.S | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

-- 
2.19.1


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

* [PATCH v3 1/3] powerpc: Discard more sections in linker script
  2018-12-10 22:28 [PATCH v3 0/3] powerpc: Add to linker script discards Joel Stanley
@ 2018-12-10 22:28 ` Joel Stanley
  2018-12-20 11:18   ` Michael Ellerman
  2018-12-10 22:28 ` [PATCH v3 2/3] powerpc: Discard dynsym section for !PPC32 Joel Stanley
  2018-12-10 22:28 ` [PATCH v3 3/3] powerpc: Discard .branch_lt section Joel Stanley
  2 siblings, 1 reply; 6+ messages in thread
From: Joel Stanley @ 2018-12-10 22:28 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Stephen Rothwell, Alan Modra

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

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)
 	}
 }
-- 
2.19.1


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

* [PATCH v3 2/3] powerpc: Discard dynsym section for !PPC32
  2018-12-10 22:28 [PATCH v3 0/3] powerpc: Add to linker script discards Joel Stanley
  2018-12-10 22:28 ` [PATCH v3 1/3] powerpc: Discard more sections in linker script Joel Stanley
@ 2018-12-10 22:28 ` Joel Stanley
  2018-12-20 11:20   ` Michael Ellerman
  2018-12-10 22:28 ` [PATCH v3 3/3] powerpc: Discard .branch_lt section Joel Stanley
  2 siblings, 1 reply; 6+ messages in thread
From: Joel Stanley @ 2018-12-10 22:28 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Stephen Rothwell, Alan Modra

Alan Modra <amodra@gmail.com> explains:

 > Likely you could discard .interp > and .dynstr too, and .dynsym when
 > !CONFIG_PPC32.

Discarding of interp and dynstr happened in a previous patch. The dynsym
cleanup was a bit less straightforward, so it gets it's own patch.

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

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

diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
index 779b8b3075a1..2c93a420f456 100644
--- a/arch/powerpc/kernel/vmlinux.lds.S
+++ b/arch/powerpc/kernel/vmlinux.lds.S
@@ -266,13 +266,13 @@ SECTIONS
 	}
 #ifdef CONFIG_RELOCATABLE
 	. = ALIGN(8);
+#ifdef CONFIG_PPC32
 	.dynsym : AT(ADDR(.dynsym) - LOAD_OFFSET)
 	{
-#ifdef CONFIG_PPC32
 		__dynamic_symtab = .;
-#endif
 		*(.dynsym)
 	}
+#endif
 	.dynamic : AT(ADDR(.dynamic) - LOAD_OFFSET)
 	{
 		__dynamic_start = .;
@@ -388,5 +388,8 @@ SECTIONS
 		*(.hash .gnu.hash)
 		*(.interp)
 		*(.dynstr)
+#ifndef CONFIG_PPC32
+		*(.dynsym)
+#endif
 	}
 }
-- 
2.19.1


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

* [PATCH v3 3/3] powerpc: Discard .branch_lt section
  2018-12-10 22:28 [PATCH v3 0/3] powerpc: Add to linker script discards Joel Stanley
  2018-12-10 22:28 ` [PATCH v3 1/3] powerpc: Discard more sections in linker script Joel Stanley
  2018-12-10 22:28 ` [PATCH v3 2/3] powerpc: Discard dynsym section for !PPC32 Joel Stanley
@ 2018-12-10 22:28 ` Joel Stanley
  2 siblings, 0 replies; 6+ messages in thread
From: Joel Stanley @ 2018-12-10 22:28 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Stephen Rothwell, Alan Modra

When building a 32 bit powerpc kernel with Binutils 2.31.1 this warning
is emitted:

 powerpc-linux-gnu-ld: warning: orphan section `.branch_lt' from
 `arch/powerpc/kernel/head_44x.o' being placed in section `.branch_lt'

As of binutils commit 2d7ad24e8726 ("Support PLT16 relocs against local
symbols")[1], 32 bit targets can produce .branch_lt sections in their
output.

These sections should be empty for the kernel build so discard them for
both PPC64 and PPC32.

[1] https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commitdiff;h=2d7ad24e8726ba4c45c9e67be08223a146a837ce
Signed-off-by: Joel Stanley <joel@jms.id.au>
---
v2: Discard instead of keep. Alan said "[discarding] can be a recipe for
finding linker bugs", so lets go with that.
---
 arch/powerpc/kernel/vmlinux.lds.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
index 2c93a420f456..af0f81df8bb9 100644
--- a/arch/powerpc/kernel/vmlinux.lds.S
+++ b/arch/powerpc/kernel/vmlinux.lds.S
@@ -316,7 +316,6 @@ SECTIONS
 		DATA_DATA
 		*(.data.rel*)
 		*(.toc1)
-		*(.branch_lt)
 	}
 
 	.opd : AT(ADDR(.opd) - LOAD_OFFSET) {
@@ -388,6 +387,7 @@ SECTIONS
 		*(.hash .gnu.hash)
 		*(.interp)
 		*(.dynstr)
+		*(.branch_lt)
 #ifndef CONFIG_PPC32
 		*(.dynsym)
 #endif
-- 
2.19.1


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

* Re: [PATCH v3 1/3] powerpc: Discard more sections in linker script
  2018-12-10 22:28 ` [PATCH v3 1/3] powerpc: Discard more sections in linker script Joel Stanley
@ 2018-12-20 11:18   ` Michael Ellerman
  0 siblings, 0 replies; 6+ messages in thread
From: Michael Ellerman @ 2018-12-20 11:18 UTC (permalink / raw)
  To: Joel Stanley, linuxppc-dev; +Cc: Stephen Rothwell, Alan Modra

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

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

* Re: [PATCH v3 2/3] powerpc: Discard dynsym section for !PPC32
  2018-12-10 22:28 ` [PATCH v3 2/3] powerpc: Discard dynsym section for !PPC32 Joel Stanley
@ 2018-12-20 11:20   ` Michael Ellerman
  0 siblings, 0 replies; 6+ messages in thread
From: Michael Ellerman @ 2018-12-20 11:20 UTC (permalink / raw)
  To: Joel Stanley, linuxppc-dev; +Cc: Stephen Rothwell, Alan Modra

Joel Stanley <joel@jms.id.au> writes:

> Alan Modra <amodra@gmail.com> explains:
>
>  > Likely you could discard .interp > and .dynstr too, and .dynsym when
>  > !CONFIG_PPC32.
>
> Discarding of interp and dynstr happened in a previous patch. The dynsym
> cleanup was a bit less straightforward, so it gets it's own patch.
>
> Signed-off-by: Joel Stanley <joel@jms.id.au>

And with the same toolchain this gives me:

  /opt/cross/kisskb/korg/gcc-8.1.0-nolibc/powerpc64-linux/bin/powerpc64-linux-objdump: vmlinux: not a dynamic object
  /opt/cross/kisskb/korg/gcc-8.1.0-nolibc/powerpc64-linux/bin/powerpc64-linux-objdump: vmlinux: Invalid operation
  /opt/cross/kisskb/korg/gcc-8.1.0-nolibc/powerpc64-linux/bin/powerpc64-linux-objdump: vmlinux: not a dynamic object
  /opt/cross/kisskb/korg/gcc-8.1.0-nolibc/powerpc64-linux/bin/powerpc64-linux-objdump: vmlinux: Invalid operation
  /opt/cross/kisskb/korg/gcc-8.1.0-nolibc/powerpc64-linux/bin/powerpc64-linux-objdump: --stop-address: bad number: 0x


cheers

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

end of thread, other threads:[~2018-12-20 11:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-10 22:28 [PATCH v3 0/3] powerpc: Add to linker script discards Joel Stanley
2018-12-10 22:28 ` [PATCH v3 1/3] powerpc: Discard more sections in linker script Joel Stanley
2018-12-20 11:18   ` Michael Ellerman
2018-12-10 22:28 ` [PATCH v3 2/3] powerpc: Discard dynsym section for !PPC32 Joel Stanley
2018-12-20 11:20   ` Michael Ellerman
2018-12-10 22:28 ` [PATCH v3 3/3] powerpc: Discard .branch_lt section Joel Stanley

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