linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] Try orphan section warning again
@ 2016-11-29  4:39 Nicholas Piggin
  2016-11-29  4:39 ` [PATCH 1/4] powerpc/64: place sfpr section explicitly with the linker script Nicholas Piggin
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Nicholas Piggin @ 2016-11-29  4:39 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: Nicholas Piggin, linuxppc-dev

Hi,

The orphan section warning patch had a minor issue with unhandled
.text.save.restore last time I sent it. I went back and tidied up
crtsavres a bit, so after these, I think we can enable orphan section
warnings.

There is a further step we can take which is to enable
--save-restore-funcs for module link, which means 64-bit does not
need crtsavres at all. That option is only in binutils 2.25 though,
so I'll send that later.

Thanks,
Nick

Nicholas Piggin (4):
  powerpc/64: place sfpr section explicitly with the linker script
  powerpc/64: do not link crtsavres routines into vmlinux
  powerpc/64: do not create new section for save/restore functions
  powerpc: link warning for orphan sections

 arch/powerpc/Makefile             |  1 +
 arch/powerpc/kernel/vmlinux.lds.S | 24 ++++++++++++++++++++++--
 arch/powerpc/lib/Makefile         |  8 ++++++--
 arch/powerpc/lib/crtsavres.S      |  6 ++----
 include/asm-generic/vmlinux.lds.h | 11 +++++++++++
 5 files changed, 42 insertions(+), 8 deletions(-)

-- 
2.10.2

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

* [PATCH 1/4] powerpc/64: place sfpr section explicitly with the linker script
  2016-11-29  4:39 [PATCH 0/4] Try orphan section warning again Nicholas Piggin
@ 2016-11-29  4:39 ` Nicholas Piggin
  2016-11-29  4:39 ` [PATCH 2/4] powerpc/64: do not link crtsavres routines into vmlinux Nicholas Piggin
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Nicholas Piggin @ 2016-11-29  4:39 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: Nicholas Piggin, linuxppc-dev

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/kernel/vmlinux.lds.S | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
index 861f4e1..f710d15 100644
--- a/arch/powerpc/kernel/vmlinux.lds.S
+++ b/arch/powerpc/kernel/vmlinux.lds.S
@@ -93,6 +93,14 @@ SECTIONS
 		KPROBES_TEXT
 		IRQENTRY_TEXT
 		SOFTIRQENTRY_TEXT
+		/*
+		 * -Os builds call FP save/restore functions. The powerpc64
+		 * linker generates those on demand in the .sfpr section.
+		 * .sfpr gets placed at the beginning of a group of input
+		 * sections, which can break start-of-text offset if it is
+		 * included with the main text sections, so put it by itself.
+		 */
+		*(.sfpr);
 		MEM_KEEP(init.text)
 		MEM_KEEP(exit.text)
 
-- 
2.10.2

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

* [PATCH 2/4] powerpc/64: do not link crtsavres routines into vmlinux
  2016-11-29  4:39 [PATCH 0/4] Try orphan section warning again Nicholas Piggin
  2016-11-29  4:39 ` [PATCH 1/4] powerpc/64: place sfpr section explicitly with the linker script Nicholas Piggin
@ 2016-11-29  4:39 ` Nicholas Piggin
  2016-11-29  4:39 ` [PATCH 3/4] powerpc/64: do not create new section for save/restore functions Nicholas Piggin
  2016-11-29  4:39 ` [PATCH 4/4] powerpc: link warning for orphan sections Nicholas Piggin
  3 siblings, 0 replies; 5+ messages in thread
From: Nicholas Piggin @ 2016-11-29  4:39 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: Nicholas Piggin, linuxppc-dev

The 64-bit linker creates save/restore functions on demand. crtsavres.o
is still required to link against modules (which do not get their
save/restore created automatically, due to not being a final link).

Make crtsavres.o extra-y on 64-bit, rather than obj-y.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/lib/Makefile | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/lib/Makefile b/arch/powerpc/lib/Makefile
index 309361e8..cb02027 100644
--- a/arch/powerpc/lib/Makefile
+++ b/arch/powerpc/lib/Makefile
@@ -9,8 +9,12 @@ ccflags-$(CONFIG_PPC64)	:= $(NO_MINIMAL_TOC)
 CFLAGS_REMOVE_code-patching.o = $(CC_FLAGS_FTRACE)
 CFLAGS_REMOVE_feature-fixups.o = $(CC_FLAGS_FTRACE)
 
-obj-y += string.o alloc.o crtsavres.o code-patching.o \
-	 feature-fixups.o
+obj-y += string.o alloc.o code-patching.o feature-fixups.o
+
+# 64-bit linker creates .sfpr on demand for final link (vmlinux),
+# so it is only needed for modules.
+obj-$(CONFIG_PPC32) += crtsavres.o
+extra-$(CONFIG_PPC64) += crtsavres.o
 
 obj-$(CONFIG_PPC32)	+= div64.o copy_32.o
 
-- 
2.10.2

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

* [PATCH 3/4] powerpc/64: do not create new section for save/restore functions
  2016-11-29  4:39 [PATCH 0/4] Try orphan section warning again Nicholas Piggin
  2016-11-29  4:39 ` [PATCH 1/4] powerpc/64: place sfpr section explicitly with the linker script Nicholas Piggin
  2016-11-29  4:39 ` [PATCH 2/4] powerpc/64: do not link crtsavres routines into vmlinux Nicholas Piggin
@ 2016-11-29  4:39 ` Nicholas Piggin
  2016-11-29  4:39 ` [PATCH 4/4] powerpc: link warning for orphan sections Nicholas Piggin
  3 siblings, 0 replies; 5+ messages in thread
From: Nicholas Piggin @ 2016-11-29  4:39 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: Nicholas Piggin, linuxppc-dev

There is no need to create a new section for these. Consolidate
with 32-bit and just use .text.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/lib/crtsavres.S | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/lib/crtsavres.S b/arch/powerpc/lib/crtsavres.S
index 18af0b3..7e5e1c2 100644
--- a/arch/powerpc/lib/crtsavres.S
+++ b/arch/powerpc/lib/crtsavres.S
@@ -44,10 +44,10 @@
 
 #ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
 
-#ifndef CONFIG_PPC64
-
 	.section ".text"
 
+#ifndef CONFIG_PPC64
+
 /* Routines for saving integer registers, called by the compiler.  */
 /* Called with r11 pointing to the stack header word of the caller of the */
 /* function, just beyond the end of the integer save area.  */
@@ -314,8 +314,6 @@ _GLOBAL(_restvr_31)
 
 #else /* CONFIG_PPC64 */
 
-	.section ".text.save.restore","ax",@progbits
-
 .globl	_savegpr0_14
 _savegpr0_14:
 	std	r14,-144(r1)
-- 
2.10.2

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

* [PATCH 4/4] powerpc: link warning for orphan sections
  2016-11-29  4:39 [PATCH 0/4] Try orphan section warning again Nicholas Piggin
                   ` (2 preceding siblings ...)
  2016-11-29  4:39 ` [PATCH 3/4] powerpc/64: do not create new section for save/restore functions Nicholas Piggin
@ 2016-11-29  4:39 ` Nicholas Piggin
  3 siblings, 0 replies; 5+ messages in thread
From: Nicholas Piggin @ 2016-11-29  4:39 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: Nicholas Piggin, linuxppc-dev

Add --orphan-handling=warn to final link flags. This ensures we can
handle all sections explicitly. This would have caught subtle breakage
such as 7de3b27bac47da9de08409df1d69664acbb72197 at build-time.

Also bring some wayward sections into the fold:
- .text.hot and .text.unlikely are compiler generated sections.
- .sdata2, .dynsbss, .plt are used by PPC32
- We previously did not specify DWARF_DEBUG or STABS_DEBUG
- DWARF_DEBUG did not include all DWARF sections that can be emitted
- A number of sections are unused.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---

I don't know if I've exactly got everything right here, particularly
with ppc32, so would appreciate people casting their eye over it.

 arch/powerpc/Makefile             |  1 +
 arch/powerpc/kernel/vmlinux.lds.S | 16 ++++++++++++++--
 include/asm-generic/vmlinux.lds.h | 11 +++++++++++
 3 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 9fbc1c8..6a9f319 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -102,6 +102,7 @@ endif
 LDFLAGS_vmlinux-y := -Bstatic
 LDFLAGS_vmlinux-$(CONFIG_RELOCATABLE) := -pie
 LDFLAGS_vmlinux	:= $(LDFLAGS_vmlinux-y)
+LDFLAGS_vmlinux += $(call ld-option,--orphan-handling=warn)
 
 ifeq ($(CONFIG_PPC64),y)
 ifeq ($(call cc-option-yn,-mcmodel=medium),y)
diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
index f710d15..6bd42d3 100644
--- a/arch/powerpc/kernel/vmlinux.lds.S
+++ b/arch/powerpc/kernel/vmlinux.lds.S
@@ -86,7 +86,7 @@ SECTIONS
 		ALIGN_FUNCTION();
 #endif
 		/* careful! __ftr_alt_* sections need to be close to .text */
-		*(.text .fixup __ftr_alt_* .ref.text)
+		*(.text.hot .text .text.fixup .text.unlikely .fixup __ftr_alt_* .ref.text);
 		SCHED_TEXT
 		CPUIDLE_TEXT
 		LOCK_TEXT
@@ -253,7 +253,9 @@ SECTIONS
 	.data : AT(ADDR(.data) - LOAD_OFFSET) {
 		DATA_DATA
 		*(.sdata)
+		*(.sdata2)
 		*(.got.plt) *(.got)
+		*(.plt)
 	}
 #else
 	.data : AT(ADDR(.data) - LOAD_OFFSET) {
@@ -314,6 +316,16 @@ SECTIONS
 	_end = . ;
 	PROVIDE32 (end = .);
 
-	/* Sections to be discarded. */
+	STABS_DEBUG
+
+	DWARF_DEBUG
+
 	DISCARDS
+	/DISCARD/ : {
+		*(*.EMB.apuinfo)
+		*(.glink .iplt .plt .rela* .comment)
+		*(.gnu.version*)
+		*(.gnu.attributes)
+		*(.eh_frame)
+	}
 }
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 31e1d63..6d5d35f 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -595,6 +595,7 @@
 #define SBSS(sbss_align)						\
 	. = ALIGN(sbss_align);						\
 	.sbss : AT(ADDR(.sbss) - LOAD_OFFSET) {				\
+		*(.dynsbss)						\
 		*(.sbss)						\
 		*(.scommon)						\
 	}
@@ -641,11 +642,21 @@
 		.debug_str      0 : { *(.debug_str) }			\
 		.debug_loc      0 : { *(.debug_loc) }			\
 		.debug_macinfo  0 : { *(.debug_macinfo) }		\
+		.debug_pubtypes 0 : { *(.debug_pubtypes) }		\
+		/* DWARF 3 */						\
+		.debug_ranges	0 : { *(.debug_ranges) }		\
 		/* SGI/MIPS DWARF 2 extensions */			\
 		.debug_weaknames 0 : { *(.debug_weaknames) }		\
 		.debug_funcnames 0 : { *(.debug_funcnames) }		\
 		.debug_typenames 0 : { *(.debug_typenames) }		\
 		.debug_varnames  0 : { *(.debug_varnames) }		\
+		/* GNU DWARF 2 extensions */				\
+		.debug_gnu_pubnames 0 : { *(.debug_gnu_pubnames) }	\
+		.debug_gnu_pubtypes 0 : { *(.debug_gnu_pubtypes) }	\
+		/* DWARF 4 */						\
+		.debug_types	0 : { *(.debug_types) }			\
+		/* DWARF 5 */						\
+		.debug_addr	0 : { *(.debug_addr) }
 
 		/* Stabs debugging sections.  */
 #define STABS_DEBUG							\
-- 
2.10.2

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

end of thread, other threads:[~2016-11-29  4:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-29  4:39 [PATCH 0/4] Try orphan section warning again Nicholas Piggin
2016-11-29  4:39 ` [PATCH 1/4] powerpc/64: place sfpr section explicitly with the linker script Nicholas Piggin
2016-11-29  4:39 ` [PATCH 2/4] powerpc/64: do not link crtsavres routines into vmlinux Nicholas Piggin
2016-11-29  4:39 ` [PATCH 3/4] powerpc/64: do not create new section for save/restore functions Nicholas Piggin
2016-11-29  4:39 ` [PATCH 4/4] powerpc: link warning for orphan sections Nicholas Piggin

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