Try orphan section warning again
Subsystems (2)
Nicholas Piggin
reviewercover Try orphan section warning again
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(-)
Signature · 1 line
2.10.2
Nicholas Piggin
reviewerPATCH 1/4 powerpc/64: place sfpr section explicitly with the linker script
--- arch/powerpc/kernel/vmlinux.lds.S | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/powerpc/kernel/vmlinux.lds.S +8 -0
@@ -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)
Signature · 1 line
2.10.2
Nicholas Piggin
reviewerPATCH 2/4 powerpc/64: do not link crtsavres routines into vmlinux
In reply to Nicholas PigginThe 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.
--- arch/powerpc/lib/Makefile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
arch/powerpc/lib/Makefile +6 -2
@@ -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
Signature · 1 line
2.10.2
Nicholas Piggin
reviewerPATCH 3/4 powerpc/64: do not create new section for save/restore functions
In reply to Nicholas PigginThere is no need to create a new section for these. Consolidate with 32-bit and just use .text.
--- arch/powerpc/lib/crtsavres.S | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
arch/powerpc/lib/crtsavres.S +2 -4
@@ -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)
Signature · 1 line
2.10.2
Nicholas Piggin
reviewerPATCH 4/4 powerpc: link warning for orphan sections
In reply to Nicholas PigginAdd --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.
---
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(-)
arch/powerpc/Makefile +1 -0
@@ -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)
arch/powerpc/kernel/vmlinux.lds.S +14 -2
@@ -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) + } }
include/asm-generic/vmlinux.lds.h +11 -0
@@ -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 \
Signature · 1 line
2.10.2