linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc: link error on orphan sections
@ 2016-10-12  7:00 Nicholas Piggin
  2016-10-14  0:46 ` Michael Ellerman
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Nicholas Piggin @ 2016-10-12  7:00 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Nicholas Piggin

Add --orphan-handling=error to final link flags. This ensures we have to
handle all sections. 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.
- .sfpr is a linker generated section for register save functions.
- .sdata2, .dynsbss, .plt are used by PPC32
- We previously did not specify DWARF_DEBUG or STABS_DEBUG
- DWARF_DEBUG did not include DWARF3 .debug_ranges
- A number of sections are unused.

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

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/Makefile             |  2 +-
 arch/powerpc/kernel/vmlinux.lds.S | 16 ++++++++++++++--
 include/asm-generic/vmlinux.lds.h |  3 +++
 3 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 50d020a..a3f2784 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -90,7 +90,7 @@ endif
 
 LDFLAGS_vmlinux-y := -Bstatic
 LDFLAGS_vmlinux-$(CONFIG_RELOCATABLE) := -pie
-LDFLAGS_vmlinux	:= $(LDFLAGS_vmlinux-y)
+LDFLAGS_vmlinux	:= $(LDFLAGS_vmlinux-y) --orphan-handling=error
 
 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 8295f51..9f4d85e 100644
--- a/arch/powerpc/kernel/vmlinux.lds.S
+++ b/arch/powerpc/kernel/vmlinux.lds.S
@@ -97,7 +97,7 @@ SECTIONS
 	.text : AT(ADDR(.text) - LOAD_OFFSET) {
 		ALIGN_FUNCTION();
 		/* 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 .sfpr) \
 		SCHED_TEXT
 		CPUIDLE_TEXT
 		LOCK_TEXT
@@ -256,7 +256,9 @@ SECTIONS
 	.data : AT(ADDR(.data) - LOAD_OFFSET) {
 		DATA_DATA
 		*(.sdata)
+		*(.sdata2)
 		*(.got.plt) *(.got)
+		*(.plt)
 	}
 #else
 	.data : AT(ADDR(.data) - LOAD_OFFSET) {
@@ -317,6 +319,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 3e42bcd..264ebb3 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -581,6 +581,7 @@
 #define SBSS(sbss_align)						\
 	. = ALIGN(sbss_align);						\
 	.sbss : AT(ADDR(.sbss) - LOAD_OFFSET) {				\
+		*(.dynsbss)						\
 		*(.sbss)						\
 		*(.scommon)						\
 	}
@@ -627,6 +628,8 @@
 		.debug_str      0 : { *(.debug_str) }			\
 		.debug_loc      0 : { *(.debug_loc) }			\
 		.debug_macinfo  0 : { *(.debug_macinfo) }		\
+		/* DWARF 3 */						\
+		.debug_ranges	0 : { *(.debug_ranges) }		\
 		/* SGI/MIPS DWARF 2 extensions */			\
 		.debug_weaknames 0 : { *(.debug_weaknames) }		\
 		.debug_funcnames 0 : { *(.debug_funcnames) }		\
-- 
2.9.3

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

* Re: [PATCH] powerpc: link error on orphan sections
  2016-10-12  7:00 [PATCH] powerpc: link error on orphan sections Nicholas Piggin
@ 2016-10-14  0:46 ` Michael Ellerman
  2016-10-14 10:54   ` David Laight
  2016-10-14  2:35 ` Balbir Singh
  2016-10-14  3:27 ` Michael Ellerman
  2 siblings, 1 reply; 9+ messages in thread
From: Michael Ellerman @ 2016-10-14  0:46 UTC (permalink / raw)
  To: Nicholas Piggin, linuxppc-dev; +Cc: Nicholas Piggin

Nicholas Piggin <npiggin@gmail.com> writes:

> Add --orphan-handling=error to final link flags. This ensures we have to
> handle all sections. 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.
> - .sfpr is a linker generated section for register save functions.
> - .sdata2, .dynsbss, .plt are used by PPC32
> - We previously did not specify DWARF_DEBUG or STABS_DEBUG
> - DWARF_DEBUG did not include DWARF3 .debug_ranges
> - A number of sections are unused.
>
> I don't know if I've exactly got everything right here, particularly
> with ppc32, so would appreciate people casting their eye over it.
>
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> ---
>  arch/powerpc/Makefile             |  2 +-
>  arch/powerpc/kernel/vmlinux.lds.S | 16 ++++++++++++++--
>  include/asm-generic/vmlinux.lds.h |  3 +++
>  3 files changed, 18 insertions(+), 3 deletions(-)
>
> diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
> index 50d020a..a3f2784 100644
> --- a/arch/powerpc/Makefile
> +++ b/arch/powerpc/Makefile
> @@ -90,7 +90,7 @@ endif
>  
>  LDFLAGS_vmlinux-y := -Bstatic
>  LDFLAGS_vmlinux-$(CONFIG_RELOCATABLE) := -pie
> -LDFLAGS_vmlinux	:= $(LDFLAGS_vmlinux-y)
> +LDFLAGS_vmlinux	:= $(LDFLAGS_vmlinux-y) --orphan-handling=error

At least some old(er) toolchains don't support that:

  /opt/cross/kisskb/gcc-4.6.3-nolibc/powerpc-linux/bin/powerpc-linux-ld: unrecognized option '--orphan-handling=error'

So we'll need an ld-option wrapper around it.

cheers

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

* Re: [PATCH] powerpc: link error on orphan sections
  2016-10-12  7:00 [PATCH] powerpc: link error on orphan sections Nicholas Piggin
  2016-10-14  0:46 ` Michael Ellerman
@ 2016-10-14  2:35 ` Balbir Singh
  2016-10-14  5:37   ` Nicholas Piggin
  2016-10-14  3:27 ` Michael Ellerman
  2 siblings, 1 reply; 9+ messages in thread
From: Balbir Singh @ 2016-10-14  2:35 UTC (permalink / raw)
  To: Nicholas Piggin, linuxppc-dev



On 12/10/16 18:00, Nicholas Piggin wrote:
> Add --orphan-handling=error to final link flags. This ensures we have to
> handle all sections. 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.
> - .sfpr is a linker generated section for register save functions.
> - .sdata2, .dynsbss, .plt are used by PPC32
> - We previously did not specify DWARF_DEBUG or STABS_DEBUG
> - DWARF_DEBUG did not include DWARF3 .debug_ranges
> - A number of sections are unused.
> 
> I don't know if I've exactly got everything right here, particularly
> with ppc32, so would appreciate people casting their eye over it.
> 
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> ---
>  arch/powerpc/Makefile             |  2 +-
>  arch/powerpc/kernel/vmlinux.lds.S | 16 ++++++++++++++--
>  include/asm-generic/vmlinux.lds.h |  3 +++
>  3 files changed, 18 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
> index 50d020a..a3f2784 100644
> --- a/arch/powerpc/Makefile
> +++ b/arch/powerpc/Makefile
> @@ -90,7 +90,7 @@ endif
>  
>  LDFLAGS_vmlinux-y := -Bstatic
>  LDFLAGS_vmlinux-$(CONFIG_RELOCATABLE) := -pie
> -LDFLAGS_vmlinux	:= $(LDFLAGS_vmlinux-y)
> +LDFLAGS_vmlinux	:= $(LDFLAGS_vmlinux-y) --orphan-handling=error
>  
>  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 8295f51..9f4d85e 100644
> --- a/arch/powerpc/kernel/vmlinux.lds.S
> +++ b/arch/powerpc/kernel/vmlinux.lds.S
> @@ -97,7 +97,7 @@ SECTIONS
>  	.text : AT(ADDR(.text) - LOAD_OFFSET) {
>  		ALIGN_FUNCTION();
>  		/* 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 .sfpr) \
>  		SCHED_TEXT

Is the "\" to pack the sched_text with the rest of .text?

>  		CPUIDLE_TEXT
>  		LOCK_TEXT
> @@ -256,7 +256,9 @@ SECTIONS
>  	.data : AT(ADDR(.data) - LOAD_OFFSET) {
>  		DATA_DATA
>  		*(.sdata)
> +		*(.sdata2)
>  		*(.got.plt) *(.got)
> +		*(.plt)
>  	}
>  #else
>  	.data : AT(ADDR(.data) - LOAD_OFFSET) {
> @@ -317,6 +319,16 @@ SECTIONS
>  	_end = . ;
>  	PROVIDE32 (end = .);
>  
> -	/* Sections to be discarded. */
> +	STABS_DEBUG
> +
> +	DWARF_DEBUG
> +

Are the debug sections discarded or is the above
comment misplaced? I guess they are discarded because of them
being outside of _end at relocation.

>  	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 3e42bcd..264ebb3 100644
> --- a/include/asm-generic/vmlinux.lds.h
> +++ b/include/asm-generic/vmlinux.lds.h
> @@ -581,6 +581,7 @@
>  #define SBSS(sbss_align)						\
>  	. = ALIGN(sbss_align);						\
>  	.sbss : AT(ADDR(.sbss) - LOAD_OFFSET) {				\
> +		*(.dynsbss)						\
>  		*(.sbss)						\
>  		*(.scommon)						\
>  	}
> @@ -627,6 +628,8 @@
>  		.debug_str      0 : { *(.debug_str) }			\
>  		.debug_loc      0 : { *(.debug_loc) }			\
>  		.debug_macinfo  0 : { *(.debug_macinfo) }		\
> +		/* DWARF 3 */						\
> +		.debug_ranges	0 : { *(.debug_ranges) }		\
>  		/* SGI/MIPS DWARF 2 extensions */			\
>  		.debug_weaknames 0 : { *(.debug_weaknames) }		\
>  		.debug_funcnames 0 : { *(.debug_funcnames) }		\
> 

Balbir Singh.

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

* Re: [PATCH] powerpc: link error on orphan sections
  2016-10-12  7:00 [PATCH] powerpc: link error on orphan sections Nicholas Piggin
  2016-10-14  0:46 ` Michael Ellerman
  2016-10-14  2:35 ` Balbir Singh
@ 2016-10-14  3:27 ` Michael Ellerman
  2016-10-14  5:24   ` Nicholas Piggin
  2 siblings, 1 reply; 9+ messages in thread
From: Michael Ellerman @ 2016-10-14  3:27 UTC (permalink / raw)
  To: Nicholas Piggin, linuxppc-dev; +Cc: Nicholas Piggin

Nicholas Piggin <npiggin@gmail.com> writes:

> diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
> index 8295f51..9f4d85e 100644
> --- a/arch/powerpc/kernel/vmlinux.lds.S
> +++ b/arch/powerpc/kernel/vmlinux.lds.S
> @@ -317,6 +319,16 @@ SECTIONS
>  	_end = . ;
>  	PROVIDE32 (end = .);
>  
> -	/* Sections to be discarded. */
> +	STABS_DEBUG
> +
> +	DWARF_DEBUG

With DEBUG_INFO=y I'm seeing:

  /opt/toolchains/6/powerpc/bin/ld: error: unplaced orphan section `.debug_addr' from `arch/powerpc/kernel/prom_init.o'.
  /opt/toolchains/6/powerpc/bin/ld: error: unplaced orphan section `.debug_gnu_pubnames' from `arch/powerpc/kernel/prom_init.o'.
  /opt/toolchains/6/powerpc/bin/ld: error: unplaced orphan section `.debug_gnu_pubtypes' from `arch/powerpc/kernel/prom_init.o'.

And many more for the same sections from other files.

cheers

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

* Re: [PATCH] powerpc: link error on orphan sections
  2016-10-14  3:27 ` Michael Ellerman
@ 2016-10-14  5:24   ` Nicholas Piggin
  0 siblings, 0 replies; 9+ messages in thread
From: Nicholas Piggin @ 2016-10-14  5:24 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linuxppc-dev, Alan Modra

Cc Alan Modra

On Fri, 14 Oct 2016 14:27:45 +1100
Michael Ellerman <mpe@ellerman.id.au> wrote:

> With DEBUG_INFO=y I'm seeing:
> 
>   /opt/toolchains/6/powerpc/bin/ld: error: unplaced orphan section `.debug_addr' from `arch/powerpc/kernel/prom_init.o'.
>   /opt/toolchains/6/powerpc/bin/ld: error: unplaced orphan section `.debug_gnu_pubnames' from `arch/powerpc/kernel/prom_init.o'.
>   /opt/toolchains/6/powerpc/bin/ld: error: unplaced orphan section `.debug_gnu_pubtypes' from `arch/powerpc/kernel/prom_init.o'.
> 
> And many more for the same sections from other files.

How's this? Might take a few iterations to smooth out all toolchains


From: Nicholas Piggin <npiggin@gmail.com>
Date: Thu, 22 Sep 2016 18:41:14 +1000
Subject: [PATCH] powerpc: link error on orphan sections

Add --orphan-handling=error to final link flags. This ensures we have to
handle all sections. 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.
- .sfpr is a linker generated section for register save functions.
- .sdata2, .dynsbss, .plt are used by PPC32
- We previously did not specify DWARF_DEBUG or STABS_DEBUG
- DWARF_DEBUG did not include DWARF3 .debug_ranges
- A number of sections are unused.

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

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 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 50d020a..6883fca 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -91,6 +91,7 @@ endif
 LDFLAGS_vmlinux-y := -Bstatic
 LDFLAGS_vmlinux-$(CONFIG_RELOCATABLE) := -pie
 LDFLAGS_vmlinux	:= $(LDFLAGS_vmlinux-y)
+LDFLAGS_vmlinux += $(call ld-option,--orphan-handling=error)
 
 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 8295f51..9f4d85e 100644
--- a/arch/powerpc/kernel/vmlinux.lds.S
+++ b/arch/powerpc/kernel/vmlinux.lds.S
@@ -97,7 +97,7 @@ SECTIONS
 	.text : AT(ADDR(.text) - LOAD_OFFSET) {
 		ALIGN_FUNCTION();
 		/* 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 .sfpr) \
 		SCHED_TEXT
 		CPUIDLE_TEXT
 		LOCK_TEXT
@@ -256,7 +256,9 @@ SECTIONS
 	.data : AT(ADDR(.data) - LOAD_OFFSET) {
 		DATA_DATA
 		*(.sdata)
+		*(.sdata2)
 		*(.got.plt) *(.got)
+		*(.plt)
 	}
 #else
 	.data : AT(ADDR(.data) - LOAD_OFFSET) {
@@ -317,6 +319,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 3e42bcd..2f825de 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -581,6 +581,7 @@
 #define SBSS(sbss_align)						\
 	. = ALIGN(sbss_align);						\
 	.sbss : AT(ADDR(.sbss) - LOAD_OFFSET) {				\
+		*(.dynsbss)						\
 		*(.sbss)						\
 		*(.scommon)						\
 	}
@@ -627,11 +628,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.9.3

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

* Re: [PATCH] powerpc: link error on orphan sections
  2016-10-14  2:35 ` Balbir Singh
@ 2016-10-14  5:37   ` Nicholas Piggin
  0 siblings, 0 replies; 9+ messages in thread
From: Nicholas Piggin @ 2016-10-14  5:37 UTC (permalink / raw)
  To: Balbir Singh; +Cc: linuxppc-dev

On Fri, 14 Oct 2016 13:35:54 +1100
Balbir Singh <bsingharora@gmail.com> wrote:

> On 12/10/16 18:00, Nicholas Piggin wrote:
> > Add --orphan-handling=error to final link flags. This ensures we have to
> > handle all sections. 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.
> > - .sfpr is a linker generated section for register save functions.
> > - .sdata2, .dynsbss, .plt are used by PPC32
> > - We previously did not specify DWARF_DEBUG or STABS_DEBUG
> > - DWARF_DEBUG did not include DWARF3 .debug_ranges
> > - A number of sections are unused.
> > 
> > I don't know if I've exactly got everything right here, particularly
> > with ppc32, so would appreciate people casting their eye over it.
> > 
> > Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> > ---
> >  arch/powerpc/Makefile             |  2 +-
> >  arch/powerpc/kernel/vmlinux.lds.S | 16 ++++++++++++++--
> >  include/asm-generic/vmlinux.lds.h |  3 +++
> >  3 files changed, 18 insertions(+), 3 deletions(-)
> > 
> > diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
> > index 50d020a..a3f2784 100644
> > --- a/arch/powerpc/Makefile
> > +++ b/arch/powerpc/Makefile
> > @@ -90,7 +90,7 @@ endif
> >  
> >  LDFLAGS_vmlinux-y := -Bstatic
> >  LDFLAGS_vmlinux-$(CONFIG_RELOCATABLE) := -pie
> > -LDFLAGS_vmlinux	:= $(LDFLAGS_vmlinux-y)
> > +LDFLAGS_vmlinux	:= $(LDFLAGS_vmlinux-y) --orphan-handling=error
> >  
> >  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 8295f51..9f4d85e 100644
> > --- a/arch/powerpc/kernel/vmlinux.lds.S
> > +++ b/arch/powerpc/kernel/vmlinux.lds.S
> > @@ -97,7 +97,7 @@ SECTIONS
> >  	.text : AT(ADDR(.text) - LOAD_OFFSET) {
> >  		ALIGN_FUNCTION();
> >  		/* 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 .sfpr) \
> >  		SCHED_TEXT  
> 
> Is the "\" to pack the sched_text with the rest of .text?

Actually it looks like a typo that slipped in. Good catch.


> > @@ -256,7 +256,9 @@ SECTIONS
> >  	.data : AT(ADDR(.data) - LOAD_OFFSET) {
> >  		DATA_DATA
> >  		*(.sdata)
> > +		*(.sdata2)
> >  		*(.got.plt) *(.got)
> > +		*(.plt)
> >  	}
> >  #else
> >  	.data : AT(ADDR(.data) - LOAD_OFFSET) {
> > @@ -317,6 +319,16 @@ SECTIONS
> >  	_end = . ;
> >  	PROVIDE32 (end = .);
> >  
> > -	/* Sections to be discarded. */
> > +	STABS_DEBUG
> > +
> > +	DWARF_DEBUG
> > +  
> 
> Are the debug sections discarded or is the above
> comment misplaced? I guess they are discarded because of them
> being outside of _end at relocation.

I just got rid of the comment. Having it right above "DISCARDS" seemed
redundant.

I believe the debug sections will be linked into the file, because they
were not put in the /DISCARD/ output. But they will be outside the _end
symbol.

Thanks,
Nick

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

* RE: [PATCH] powerpc: link error on orphan sections
  2016-10-14  0:46 ` Michael Ellerman
@ 2016-10-14 10:54   ` David Laight
  2016-10-19 11:56     ` Michael Ellerman
  0 siblings, 1 reply; 9+ messages in thread
From: David Laight @ 2016-10-14 10:54 UTC (permalink / raw)
  To: 'Michael Ellerman', Nicholas Piggin,
	linuxppc-dev@lists.ozlabs.org
  Cc: Nicholas Piggin

From: Michael Ellerman
> Sent: 14 October 2016 01:46
...
> > +LDFLAGS_vmlinux	:=3D $(LDFLAGS_vmlinux-y) --orphan-handling=3Derror
>=20
> At least some old(er) toolchains don't support that:
>=20
>   /opt/cross/kisskb/gcc-4.6.3-nolibc/powerpc-linux/bin/powerpc-linux-ld: =
unrecognized option '--
> orphan-handling=3Derror'
>=20
> So we'll need an ld-option wrapper around it.

In the past I've caused orphan sections to error by assigning them
to the same address as something that exists.
Works with all linkers, even if the error message isn't as useful.

	David

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

* RE: [PATCH] powerpc: link error on orphan sections
  2016-10-14 10:54   ` David Laight
@ 2016-10-19 11:56     ` Michael Ellerman
  2016-10-19 12:36       ` David Laight
  0 siblings, 1 reply; 9+ messages in thread
From: Michael Ellerman @ 2016-10-19 11:56 UTC (permalink / raw)
  To: David Laight, Nicholas Piggin, linuxppc-dev@lists.ozlabs.org
  Cc: Nicholas Piggin

David Laight <David.Laight@ACULAB.COM> writes:

> From: Michael Ellerman
>> Sent: 14 October 2016 01:46
> ...
>> > +LDFLAGS_vmlinux	:= $(LDFLAGS_vmlinux-y) --orphan-handling=error
>> 
>> At least some old(er) toolchains don't support that:
>> 
>>   /opt/cross/kisskb/gcc-4.6.3-nolibc/powerpc-linux/bin/powerpc-linux-ld: unrecognized option '--
>> orphan-handling=error'
>> 
>> So we'll need an ld-option wrapper around it.
>
> In the past I've caused orphan sections to error by assigning them
> to the same address as something that exists.
> Works with all linkers, even if the error message isn't as useful.

How do you assign them an address without knowing what they are? With a
wild card rule?

Anyway I think I'm happy for this to only work on newer toolchains.

cheers

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

* RE: [PATCH] powerpc: link error on orphan sections
  2016-10-19 11:56     ` Michael Ellerman
@ 2016-10-19 12:36       ` David Laight
  0 siblings, 0 replies; 9+ messages in thread
From: David Laight @ 2016-10-19 12:36 UTC (permalink / raw)
  To: 'Michael Ellerman', Nicholas Piggin,
	linuxppc-dev@lists.ozlabs.org
  Cc: Nicholas Piggin

From: Michael Ellerman [mailto:mpe@ellerman.id.au]
> > In the past I've caused orphan sections to error by assigning them
> > to the same address as something that exists.
> > Works with all linkers, even if the error message isn't as useful.
>=20
> How do you assign them an address without knowing what they are? With a
> wild card rule?

Right at the end of the ldscript I have:

    /* Anything from any unexpected section ends up here and
     * generates an error because this overlaps another section */
    unwanted _gp : { *(*) }
}

	David

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

end of thread, other threads:[~2016-10-19 12:39 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-12  7:00 [PATCH] powerpc: link error on orphan sections Nicholas Piggin
2016-10-14  0:46 ` Michael Ellerman
2016-10-14 10:54   ` David Laight
2016-10-19 11:56     ` Michael Ellerman
2016-10-19 12:36       ` David Laight
2016-10-14  2:35 ` Balbir Singh
2016-10-14  5:37   ` Nicholas Piggin
2016-10-14  3:27 ` Michael Ellerman
2016-10-14  5:24   ` 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).