All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Fixes for gcov-related linker problems
@ 2018-09-13 10:59 Peter Oberparleiter
  2018-09-13 10:59 ` [PATCH 1/2] vmlinux.lds.h: Fix incomplete .text.exit discards Peter Oberparleiter
  2018-09-13 11:00 ` [PATCH 2/2] vmlinux.lds.h: Fix linker warnings about orphan .LPBX sections Peter Oberparleiter
  0 siblings, 2 replies; 3+ messages in thread
From: Peter Oberparleiter @ 2018-09-13 10:59 UTC (permalink / raw)
  To: arnd
  Cc: Peter Oberparleiter, Masami Hiramatsu, Stephen Rothwell,
	Steven Rostedt, Greentime Hu, Russell King,
	Linux Kernel Mailing List

Commit

  6b7dca401cb1 ("tracing: Allow gcov profiling on only ftrace subsystem")

uncovered linker problems when using gcov kernel profiling on some
architectures. These problems were likely introduced earlier, and are
possibly related to compiler changes.

Arnd: Can you pick up these fixes?

Peter Oberparleiter (2):
  vmlinux.lds.h: Fix incomplete .text.exit discards
  vmlinux.lds.h: Fix linker warnings about orphan .LPBX sections

 arch/arm/kernel/vmlinux.lds.h     | 2 ++
 include/asm-generic/vmlinux.lds.h | 6 +++---
 2 files changed, 5 insertions(+), 3 deletions(-)

-- 
2.17.0


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

* [PATCH 1/2] vmlinux.lds.h: Fix incomplete .text.exit discards
  2018-09-13 10:59 [PATCH 0/2] Fixes for gcov-related linker problems Peter Oberparleiter
@ 2018-09-13 10:59 ` Peter Oberparleiter
  2018-09-13 11:00 ` [PATCH 2/2] vmlinux.lds.h: Fix linker warnings about orphan .LPBX sections Peter Oberparleiter
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Oberparleiter @ 2018-09-13 10:59 UTC (permalink / raw)
  To: arnd
  Cc: Peter Oberparleiter, Masami Hiramatsu, Stephen Rothwell,
	Steven Rostedt, Greentime Hu, Russell King,
	Linux Kernel Mailing List

Enabling CONFIG_GCOV_PROFILE_ALL=y causes linker errors on ARM:

  `.text.exit' referenced in section `.ARM.exidx.text.exit':
  defined in discarded section `.text.exit'

  `.text.exit' referenced in section `.fini_array.00100':
  defined in discarded section `.text.exit'

And related errors on NDS32:

  `.text.exit' referenced in section `.dtors.65435':
  defined in discarded section `.text.exit'

The gcov compiler flags cause certain compiler versions to generate
additional destructor-related sections that are not yet handled by the
linker script, resulting in references between discarded and
non-discarded sections.

Since destructors are not used in the Linux kernel, fix this by
discarding these additional sections.

Reported-by: Arnd Bergmann <arnd@arndb.de>
Reported-by: Greentime Hu <green.hu@gmail.com>
Tested-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Peter Oberparleiter <oberpar@linux.ibm.com>
---
 arch/arm/kernel/vmlinux.lds.h     | 2 ++
 include/asm-generic/vmlinux.lds.h | 4 ++--
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/arm/kernel/vmlinux.lds.h b/arch/arm/kernel/vmlinux.lds.h
index ae5fdff18406..8247bc15addc 100644
--- a/arch/arm/kernel/vmlinux.lds.h
+++ b/arch/arm/kernel/vmlinux.lds.h
@@ -49,6 +49,8 @@
 #define ARM_DISCARD							\
 		*(.ARM.exidx.exit.text)					\
 		*(.ARM.extab.exit.text)					\
+		*(.ARM.exidx.text.exit)					\
+		*(.ARM.extab.text.exit)					\
 		ARM_CPU_DISCARD(*(.ARM.exidx.cpuexit.text))		\
 		ARM_CPU_DISCARD(*(.ARM.extab.cpuexit.text))		\
 		ARM_EXIT_DISCARD(EXIT_TEXT)				\
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 7b75ff6e2fce..b4d74b1c1e1d 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -613,8 +613,8 @@
 
 #define EXIT_DATA							\
 	*(.exit.data .exit.data.*)					\
-	*(.fini_array)							\
-	*(.dtors)							\
+	*(.fini_array .fini_array.*)					\
+	*(.dtors .dtors.*)						\
 	MEM_DISCARD(exit.data*)						\
 	MEM_DISCARD(exit.rodata*)
 
-- 
2.17.0


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

* [PATCH 2/2] vmlinux.lds.h: Fix linker warnings about orphan .LPBX sections
  2018-09-13 10:59 [PATCH 0/2] Fixes for gcov-related linker problems Peter Oberparleiter
  2018-09-13 10:59 ` [PATCH 1/2] vmlinux.lds.h: Fix incomplete .text.exit discards Peter Oberparleiter
@ 2018-09-13 11:00 ` Peter Oberparleiter
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Oberparleiter @ 2018-09-13 11:00 UTC (permalink / raw)
  To: arnd
  Cc: Peter Oberparleiter, Masami Hiramatsu, Stephen Rothwell,
	Steven Rostedt, Greentime Hu, Russell King,
	Linux Kernel Mailing List

Enabling both CONFIG_LD_DEAD_CODE_DATA_ELIMINATION=y and
CONFIG_GCOV_PROFILE_ALL=y results in linker warnings:

  warning: orphan section `.data..LPBX1' being placed in
  section `.data..LPBX1'.

LD_DEAD_CODE_DATA_ELIMINATION adds compiler flag -fdata-sections. This
option causes GCC to create separate data sections for data objects,
including those generated by GCC internally for gcov profiling. The
names of these objects start with a dot (.LPBX0, .LPBX1), resulting in
section names starting with 'data..'.

As section names starting with 'data..' are used for specific purposes
in the Linux kernel, the linker script does not automatically include
them in the output data section, resulting in the "orphan section"
linker warnings.

Fix this by specifically including sections named "data..LPBX*" in the
data section.

Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Tested-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Peter Oberparleiter <oberpar@linux.ibm.com>
---
 include/asm-generic/vmlinux.lds.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index b4d74b1c1e1d..d7701d466b60 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -68,7 +68,7 @@
  */
 #ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION
 #define TEXT_MAIN .text .text.[0-9a-zA-Z_]*
-#define DATA_MAIN .data .data.[0-9a-zA-Z_]*
+#define DATA_MAIN .data .data.[0-9a-zA-Z_]* .data..LPBX*
 #define SDATA_MAIN .sdata .sdata.[0-9a-zA-Z_]*
 #define RODATA_MAIN .rodata .rodata.[0-9a-zA-Z_]*
 #define BSS_MAIN .bss .bss.[0-9a-zA-Z_]*
-- 
2.17.0


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

end of thread, other threads:[~2018-09-13 11:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-13 10:59 [PATCH 0/2] Fixes for gcov-related linker problems Peter Oberparleiter
2018-09-13 10:59 ` [PATCH 1/2] vmlinux.lds.h: Fix incomplete .text.exit discards Peter Oberparleiter
2018-09-13 11:00 ` [PATCH 2/2] vmlinux.lds.h: Fix linker warnings about orphan .LPBX sections Peter Oberparleiter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.