Skip to content

Commit 83a092c

Browse files
npigginmpe
authored andcommitted
powerpc: Link warning for orphan sections
Add --orphan-handling=warn to final link flags. This ensures we can handle all sections explicitly. This would have caught subtle breakage such as 7de3b27 at build-time. Also bring existing orphan 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 and can be discarded. Signed-off-by: Nicholas Piggin <[email protected]> Signed-off-by: Michael Ellerman <[email protected]>
1 parent c494ade commit 83a092c

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

arch/powerpc/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ endif
9898
LDFLAGS_vmlinux-y := -Bstatic
9999
LDFLAGS_vmlinux-$(CONFIG_RELOCATABLE) := -pie
100100
LDFLAGS_vmlinux := $(LDFLAGS_vmlinux-y)
101+
LDFLAGS_vmlinux += $(call ld-option,--orphan-handling=warn)
101102

102103
ifeq ($(CONFIG_PPC64),y)
103104
ifeq ($(call cc-option-yn,-mcmodel=medium),y)

arch/powerpc/kernel/vmlinux.lds.S

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ SECTIONS
9191
ALIGN_FUNCTION();
9292
#endif
9393
/* careful! __ftr_alt_* sections need to be close to .text */
94-
*(.text .fixup __ftr_alt_* .ref.text)
94+
*(.text.hot .text .text.fixup .text.unlikely .fixup __ftr_alt_* .ref.text);
9595
SCHED_TEXT
9696
CPUIDLE_TEXT
9797
LOCK_TEXT
@@ -258,7 +258,9 @@ SECTIONS
258258
.data : AT(ADDR(.data) - LOAD_OFFSET) {
259259
DATA_DATA
260260
*(.sdata)
261+
*(.sdata2)
261262
*(.got.plt) *(.got)
263+
*(.plt)
262264
}
263265
#else
264266
.data : AT(ADDR(.data) - LOAD_OFFSET) {
@@ -321,6 +323,16 @@ SECTIONS
321323
_end = . ;
322324
PROVIDE32 (end = .);
323325

324-
/* Sections to be discarded. */
326+
STABS_DEBUG
327+
328+
DWARF_DEBUG
329+
325330
DISCARDS
331+
/DISCARD/ : {
332+
*(*.EMB.apuinfo)
333+
*(.glink .iplt .plt .rela* .comment)
334+
*(.gnu.version*)
335+
*(.gnu.attributes)
336+
*(.eh_frame)
337+
}
326338
}

include/asm-generic/vmlinux.lds.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,7 @@
595595
#define SBSS(sbss_align) \
596596
. = ALIGN(sbss_align); \
597597
.sbss : AT(ADDR(.sbss) - LOAD_OFFSET) { \
598+
*(.dynsbss) \
598599
*(.sbss) \
599600
*(.scommon) \
600601
}
@@ -641,11 +642,22 @@
641642
.debug_str 0 : { *(.debug_str) } \
642643
.debug_loc 0 : { *(.debug_loc) } \
643644
.debug_macinfo 0 : { *(.debug_macinfo) } \
645+
.debug_pubtypes 0 : { *(.debug_pubtypes) } \
646+
/* DWARF 3 */ \
647+
.debug_ranges 0 : { *(.debug_ranges) } \
644648
/* SGI/MIPS DWARF 2 extensions */ \
645649
.debug_weaknames 0 : { *(.debug_weaknames) } \
646650
.debug_funcnames 0 : { *(.debug_funcnames) } \
647651
.debug_typenames 0 : { *(.debug_typenames) } \
648652
.debug_varnames 0 : { *(.debug_varnames) } \
653+
/* GNU DWARF 2 extensions */ \
654+
.debug_gnu_pubnames 0 : { *(.debug_gnu_pubnames) } \
655+
.debug_gnu_pubtypes 0 : { *(.debug_gnu_pubtypes) } \
656+
/* DWARF 4 */ \
657+
.debug_types 0 : { *(.debug_types) } \
658+
/* DWARF 5 */ \
659+
.debug_macro 0 : { *(.debug_macro) } \
660+
.debug_addr 0 : { *(.debug_addr) }
649661

650662
/* Stabs debugging sections. */
651663
#define STABS_DEBUG \

0 commit comments

Comments
 (0)