From 9289ea7f952b14ef2627edc49f9508234952a85e Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Thu, 22 Jun 2017 10:56:48 -0400 Subject: [PATCH 01/12] sparc64: Use indirect calls in hamming weight stubs Otherwise, depending upon link order, the branch relocation limits could be exceeded. Signed-off-by: David S. Miller Signed-off-by: Masahiro Yamada --- arch/sparc/lib/hweight.S | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/arch/sparc/lib/hweight.S b/arch/sparc/lib/hweight.S index f9985f129fb6..d21cf20e5c1e 100644 --- a/arch/sparc/lib/hweight.S +++ b/arch/sparc/lib/hweight.S @@ -4,9 +4,9 @@ .text .align 32 ENTRY(__arch_hweight8) - ba,pt %xcc, __sw_hweight8 + sethi %hi(__sw_hweight8), %g1 + jmpl %g1 + %lo(__sw_hweight8), %g0 nop - nop ENDPROC(__arch_hweight8) EXPORT_SYMBOL(__arch_hweight8) .section .popc_3insn_patch, "ax" @@ -17,9 +17,9 @@ EXPORT_SYMBOL(__arch_hweight8) .previous ENTRY(__arch_hweight16) - ba,pt %xcc, __sw_hweight16 + sethi %hi(__sw_hweight16), %g1 + jmpl %g1 + %lo(__sw_hweight16), %g0 nop - nop ENDPROC(__arch_hweight16) EXPORT_SYMBOL(__arch_hweight16) .section .popc_3insn_patch, "ax" @@ -30,9 +30,9 @@ EXPORT_SYMBOL(__arch_hweight16) .previous ENTRY(__arch_hweight32) - ba,pt %xcc, __sw_hweight32 + sethi %hi(__sw_hweight32), %g1 + jmpl %g1 + %lo(__sw_hweight32), %g0 nop - nop ENDPROC(__arch_hweight32) EXPORT_SYMBOL(__arch_hweight32) .section .popc_3insn_patch, "ax" @@ -43,9 +43,9 @@ EXPORT_SYMBOL(__arch_hweight32) .previous ENTRY(__arch_hweight64) - ba,pt %xcc, __sw_hweight64 + sethi %hi(__sw_hweight16), %g1 + jmpl %g1 + %lo(__sw_hweight16), %g0 nop - nop ENDPROC(__arch_hweight64) EXPORT_SYMBOL(__arch_hweight64) .section .popc_3insn_patch, "ax" From 44ea9948e93556a501c6de50b0a77042a0ba077f Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sun, 25 Jun 2017 10:53:08 +0900 Subject: [PATCH 02/12] tile: fix dependency and .*.cmd inclusion for incremental build Build targets using if_changed(_rule) must depend on FORCE so that they are evaluated every time. In order to include .*.cmd files correctly, build targets added to "targets" must not be prefixed with $(obj)/ because it is done by scripts/Makefile.lib . Signed-off-by: Masahiro Yamada --- arch/tile/kernel/vdso/Makefile | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/arch/tile/kernel/vdso/Makefile b/arch/tile/kernel/vdso/Makefile index c54fff37b5ff..cf162a23e866 100644 --- a/arch/tile/kernel/vdso/Makefile +++ b/arch/tile/kernel/vdso/Makefile @@ -42,10 +42,9 @@ $(obj)/vdso.o: $(obj)/vdso.so # link rule for the .so file, .lds has to be first SYSCFLAGS_vdso.so.dbg = $(c_flags) -$(obj)/vdso.so.dbg: $(src)/vdso.lds $(obj-vdso) +$(obj)/vdso.so.dbg: $(src)/vdso.lds $(obj-vdso) FORCE $(call if_changed,vdsold) - # We also create a special relocatable object that should mirror the symbol # table and layout of the linked DSO. With ld -R we can then refer to # these symbols in the kernel code rather than hand-coded addresses. @@ -96,17 +95,17 @@ KBUILD_CFLAGS_32 := $(filter-out -m64,$(KBUILD_CFLAGS)) KBUILD_CFLAGS_32 += -m32 -fPIC -shared obj-vdso32 = $(patsubst %, v%32.o, $(vdso-syms)) -obj-vdso32 := $(addprefix $(obj)/, $(obj-vdso32)) targets += $(obj-vdso32) vdso32.so vdso32.so.dbg +obj-vdso32 := $(addprefix $(obj)/, $(obj-vdso32)) $(obj-vdso32:%=%): KBUILD_AFLAGS = $(KBUILD_AFLAGS_32) $(obj-vdso32:%=%): KBUILD_CFLAGS = $(KBUILD_CFLAGS_32) -$(obj)/vgettimeofday32.o: $(obj)/vgettimeofday.c +$(obj)/vgettimeofday32.o: $(obj)/vgettimeofday.c FORCE $(call if_changed_rule,cc_o_c) -$(obj)/vrt_sigreturn32.o: $(obj)/vrt_sigreturn.S +$(obj)/vrt_sigreturn32.o: $(obj)/vrt_sigreturn.S FORCE $(call if_changed,as_o_S) # Force dependency @@ -114,5 +113,5 @@ $(obj)/vdso32.o: $(obj)/vdso32.so SYSCFLAGS_vdso32.so.dbg = -m32 -shared -s -Wl,-soname=linux-vdso32.so.1 \ $(call cc-ldoption, -Wl$(comma)--hash-style=both) -$(obj)/vdso32.so.dbg: $(src)/vdso.lds $(obj-vdso32) +$(obj)/vdso32.so.dbg: $(src)/vdso.lds $(obj-vdso32) FORCE $(call if_changed,vdsold) From df91b0262e2cff23db5eac77126ea0bef06d54d2 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 30 Jun 2017 00:52:06 +0900 Subject: [PATCH 03/12] ia64: remove unneeded extra-y in Makefile.gate All the files listed in "extra-y" are generated according to the dependency. They are still needed in "targets" to include .*.cmd for incremental building. Signed-off-by: Masahiro Yamada --- arch/ia64/kernel/Makefile.gate | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/arch/ia64/kernel/Makefile.gate b/arch/ia64/kernel/Makefile.gate index a32903ada016..92693c1d65f4 100644 --- a/arch/ia64/kernel/Makefile.gate +++ b/arch/ia64/kernel/Makefile.gate @@ -1,8 +1,6 @@ # The gate DSO image is built using a special linker script. -targets += gate.so gate-syms.o - -extra-y += gate.so gate-syms.o gate.lds gate.o +targets += gate.so gate-syms.o gate.lds gate.o CPPFLAGS_gate.lds := -P -C -U$(ARCH) From 1328a1ae0e9048ff4b7f6b60c497db7a2799e1b1 Mon Sep 17 00:00:00 2001 From: Nicholas Piggin Date: Fri, 9 Jun 2017 15:24:13 +1000 Subject: [PATCH 04/12] kbuild: thin archives final link close --whole-archives option Close the --whole-archives option with --no-whole-archive. Some architectures end up including additional .o and files multiple times after this, and they get duplicate symbols when they are brought under the --whole-archives option. This matches more closely with the incremental final link. Signed-off-by: Nicholas Piggin Signed-off-by: Masahiro Yamada --- scripts/link-vmlinux.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh index c80291319cb2..2a062ea130b5 100755 --- a/scripts/link-vmlinux.sh +++ b/scripts/link-vmlinux.sh @@ -63,7 +63,7 @@ modpost_link() local objects if [ -n "${CONFIG_THIN_ARCHIVES}" ]; then - objects="--whole-archive built-in.o" + objects="--whole-archive built-in.o --no-whole-archive" else objects="${KBUILD_VMLINUX_INIT} \ --start-group \ @@ -83,7 +83,7 @@ vmlinux_link() if [ "${SRCARCH}" != "um" ]; then if [ -n "${CONFIG_THIN_ARCHIVES}" ]; then - objects="--whole-archive built-in.o ${1}" + objects="--whole-archive built-in.o ${1} --no-whole-archive" else objects="${KBUILD_VMLINUX_INIT} \ --start-group \ @@ -96,7 +96,7 @@ vmlinux_link() -T ${lds} ${objects} else if [ -n "${CONFIG_THIN_ARCHIVES}" ]; then - objects="-Wl,--whole-archive built-in.o ${1}" + objects="-Wl,--whole-archive built-in.o ${1} -Wl,--no-whole-archive" else objects="${KBUILD_VMLINUX_INIT} \ -Wl,--start-group \ From 9a6cfca4f4130444cb02536a4fdf7b6e285c713e Mon Sep 17 00:00:00 2001 From: Nicholas Piggin Date: Fri, 9 Jun 2017 15:24:14 +1000 Subject: [PATCH 05/12] kbuild: thin archives use P option to ar The P option makes ar do full path name matching and can prevent ar from discarding files with duplicate names in some cases of creating thin archives from thin archives. The sh architecture in particular loses some object files from its kernel/cpu/sh*/ directories without this option. This could be a bug in binutils ar, but the P option should not cause any negative effects so it is safe to use to work around this with. Signed-off-by: Nicholas Piggin Signed-off-by: Masahiro Yamada --- scripts/Makefile.build | 8 ++++---- scripts/link-vmlinux.sh | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 733e044fff8b..4a9a2cec0a1b 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -437,8 +437,8 @@ $(sort $(subdir-obj-y)): $(subdir-ym) ; ifdef builtin-target ifdef CONFIG_THIN_ARCHIVES - cmd_make_builtin = rm -f $@; $(AR) rcST$(KBUILD_ARFLAGS) - cmd_make_empty_builtin = rm -f $@; $(AR) rcST$(KBUILD_ARFLAGS) + cmd_make_builtin = rm -f $@; $(AR) rcSTP$(KBUILD_ARFLAGS) + cmd_make_empty_builtin = rm -f $@; $(AR) rcSTP$(KBUILD_ARFLAGS) quiet_cmd_link_o_target = AR $@ else cmd_make_builtin = $(LD) $(ld_flags) -r -o @@ -478,7 +478,7 @@ ifdef lib-target quiet_cmd_link_l_target = AR $@ ifdef CONFIG_THIN_ARCHIVES - cmd_link_l_target = rm -f $@; $(AR) rcsT$(KBUILD_ARFLAGS) $@ $(lib-y) + cmd_link_l_target = rm -f $@; $(AR) rcsTP$(KBUILD_ARFLAGS) $@ $(lib-y) else cmd_link_l_target = rm -f $@; $(AR) rcs$(KBUILD_ARFLAGS) $@ $(lib-y) endif @@ -531,7 +531,7 @@ cmd_link_multi-link = $(LD) $(ld_flags) -r -o $@ $(link_multi_deps) $(cmd_secana ifdef CONFIG_THIN_ARCHIVES quiet_cmd_link_multi-y = AR $@ - cmd_link_multi-y = rm -f $@; $(AR) rcST$(KBUILD_ARFLAGS) $@ $(link_multi_deps) + cmd_link_multi-y = rm -f $@; $(AR) rcSTP$(KBUILD_ARFLAGS) $@ $(link_multi_deps) else quiet_cmd_link_multi-y = LD $@ cmd_link_multi-y = $(cmd_link_multi-link) diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh index 2a062ea130b5..72a0aa627c56 100755 --- a/scripts/link-vmlinux.sh +++ b/scripts/link-vmlinux.sh @@ -50,7 +50,7 @@ archive_builtin() if [ -n "${CONFIG_THIN_ARCHIVES}" ]; then info AR built-in.o rm -f built-in.o; - ${AR} rcsT${KBUILD_ARFLAGS} built-in.o \ + ${AR} rcsTP${KBUILD_ARFLAGS} built-in.o \ ${KBUILD_VMLINUX_INIT} \ ${KBUILD_VMLINUX_MAIN} fi From 3a166fc2d4ef7a6b7e440271ee6bd1799c066605 Mon Sep 17 00:00:00 2001 From: Nicholas Piggin Date: Tue, 20 Jun 2017 01:52:05 +1000 Subject: [PATCH 06/12] kbuild: handle libs-y archives separately from built-in.o archives The thin archives build currently puts all lib.a and built-in.o files together and links them with --whole-archive. This works because thin archives can recursively refer to thin archives. However some architectures include libgcc.a, which may not be a thin archive, or it may not be constructed with the "P" option, in which case its contents do not get linked correctly. So don't pull .a libs into the root built-in.o archive. These libs should already have symbol tables and indexes built, so they can be direct linker inputs. Move them out of the --whole-archive option, which restore the conditional linking behaviour of lib.a to thin archives builds. Signed-off-by: Nicholas Piggin Signed-off-by: Masahiro Yamada --- Documentation/kbuild/kbuild.txt | 8 ++++-- Makefile | 8 +++--- scripts/link-vmlinux.sh | 45 ++++++++++++++++++++++++++------- 3 files changed, 46 insertions(+), 15 deletions(-) diff --git a/Documentation/kbuild/kbuild.txt b/Documentation/kbuild/kbuild.txt index 0ff6a466a05b..ac2363ea05c5 100644 --- a/Documentation/kbuild/kbuild.txt +++ b/Documentation/kbuild/kbuild.txt @@ -236,5 +236,9 @@ Files specified with KBUILD_VMLINUX_INIT are linked first. KBUILD_VMLINUX_MAIN -------------------------------------------------- All object files for the main part of vmlinux. -KBUILD_VMLINUX_INIT and KBUILD_VMLINUX_MAIN together specify -all the object files used to link vmlinux. + +KBUILD_VMLINUX_LIBS +-------------------------------------------------- +All .a "lib" files for vmlinux. +KBUILD_VMLINUX_INIT, KBUILD_VMLINUX_MAIN, and KBUILD_VMLINUX_LIBS together +specify all the object files used to link vmlinux. diff --git a/Makefile b/Makefile index 853ae9179af9..1177775fa410 100644 --- a/Makefile +++ b/Makefile @@ -952,19 +952,19 @@ core-y := $(patsubst %/, %/built-in.o, $(core-y)) drivers-y := $(patsubst %/, %/built-in.o, $(drivers-y)) net-y := $(patsubst %/, %/built-in.o, $(net-y)) libs-y1 := $(patsubst %/, %/lib.a, $(libs-y)) -libs-y2 := $(patsubst %/, %/built-in.o, $(libs-y)) -libs-y := $(libs-y1) $(libs-y2) +libs-y2 := $(filter-out %.a, $(patsubst %/, %/built-in.o, $(libs-y))) virt-y := $(patsubst %/, %/built-in.o, $(virt-y)) # Externally visible symbols (used by link-vmlinux.sh) export KBUILD_VMLINUX_INIT := $(head-y) $(init-y) -export KBUILD_VMLINUX_MAIN := $(core-y) $(libs-y) $(drivers-y) $(net-y) $(virt-y) +export KBUILD_VMLINUX_MAIN := $(core-y) $(libs-y2) $(drivers-y) $(net-y) $(virt-y) +export KBUILD_VMLINUX_LIBS := $(libs-y1) export KBUILD_LDS := arch/$(SRCARCH)/kernel/vmlinux.lds export LDFLAGS_vmlinux # used by scripts/pacmage/Makefile export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) arch Documentation include samples scripts tools) -vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_INIT) $(KBUILD_VMLINUX_MAIN) +vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_INIT) $(KBUILD_VMLINUX_MAIN) $(KBUILD_VMLINUX_LIBS) # Include targets which we want to execute sequentially if the rest of the # kernel build went well. If CONFIG_TRIM_UNUSED_KSYMS is set, this might be diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh index 72a0aa627c56..e7b7eee31538 100755 --- a/scripts/link-vmlinux.sh +++ b/scripts/link-vmlinux.sh @@ -3,9 +3,12 @@ # link vmlinux # # vmlinux is linked from the objects selected by $(KBUILD_VMLINUX_INIT) and -# $(KBUILD_VMLINUX_MAIN). Most are built-in.o files from top-level directories -# in the kernel tree, others are specified in arch/$(ARCH)/Makefile. -# Ordering when linking is important, and $(KBUILD_VMLINUX_INIT) must be first. +# $(KBUILD_VMLINUX_MAIN) and $(KBUILD_VMLINUX_LIBS). Most are built-in.o files +# from top-level directories in the kernel tree, others are specified in +# arch/$(ARCH)/Makefile. Ordering when linking is important, and +# $(KBUILD_VMLINUX_INIT) must be first. $(KBUILD_VMLINUX_LIBS) are archives +# which are linked conditionally (not within --whole-archive), and do not +# require symbol indexes added. # # vmlinux # ^ @@ -16,6 +19,9 @@ # +--< $(KBUILD_VMLINUX_MAIN) # | +--< drivers/built-in.o mm/built-in.o + more # | +# +--< $(KBUILD_VMLINUX_LIBS) +# | +--< lib/lib.a + more +# | # +-< ${kallsymso} (see description in KALLSYMS section) # # vmlinux version (uname -v) cannot be updated during normal @@ -37,9 +43,10 @@ info() fi } -# Thin archive build here makes a final archive with -# symbol table and indexes from vmlinux objects, which can be -# used as input to linker. +# Thin archive build here makes a final archive with symbol table and indexes +# from vmlinux objects INIT and MAIN, which can be used as input to linker. +# KBUILD_VMLINUX_LIBS archives should already have symbol table and indexes +# added. # # Traditional incremental style of link does not require this step # @@ -63,11 +70,17 @@ modpost_link() local objects if [ -n "${CONFIG_THIN_ARCHIVES}" ]; then - objects="--whole-archive built-in.o --no-whole-archive" + objects="--whole-archive \ + built-in.o \ + --no-whole-archive \ + --start-group \ + ${KBUILD_VMLINUX_LIBS} \ + --end-group" else objects="${KBUILD_VMLINUX_INIT} \ --start-group \ ${KBUILD_VMLINUX_MAIN} \ + ${KBUILD_VMLINUX_LIBS} \ --end-group" fi ${LD} ${LDFLAGS} -r -o ${1} ${objects} @@ -83,11 +96,18 @@ vmlinux_link() if [ "${SRCARCH}" != "um" ]; then if [ -n "${CONFIG_THIN_ARCHIVES}" ]; then - objects="--whole-archive built-in.o ${1} --no-whole-archive" + objects="--whole-archive \ + built-in.o \ + --no-whole-archive \ + --start-group \ + ${KBUILD_VMLINUX_LIBS} \ + --end-group \ + ${1}" else objects="${KBUILD_VMLINUX_INIT} \ --start-group \ ${KBUILD_VMLINUX_MAIN} \ + ${KBUILD_VMLINUX_LIBS} \ --end-group \ ${1}" fi @@ -96,11 +116,18 @@ vmlinux_link() -T ${lds} ${objects} else if [ -n "${CONFIG_THIN_ARCHIVES}" ]; then - objects="-Wl,--whole-archive built-in.o ${1} -Wl,--no-whole-archive" + objects="-Wl,--whole-archive \ + built-in.o \ + -Wl,--no-whole-archive \ + -Wl,--start-group \ + ${KBUILD_VMLINUX_LIBS} \ + -Wl,--end-group \ + ${1}" else objects="${KBUILD_VMLINUX_INIT} \ -Wl,--start-group \ ${KBUILD_VMLINUX_MAIN} \ + ${KBUILD_VMLINUX_LIBS} \ -Wl,--end-group \ ${1}" fi From 8f5ef7c74ac778a16a89bc054e316dcade304784 Mon Sep 17 00:00:00 2001 From: Nicholas Piggin Date: Thu, 22 Jun 2017 22:39:27 +1000 Subject: [PATCH 07/12] sh: thin archives fix linking The VDSO symbols can't be linked into built-in.o when building with thin archives, so change this to linking a new object file that is included into the built-in.o. Cc: Yoshinori Sato Cc: Rich Felker Cc: linux-sh@vger.kernel.org Signed-off-by: Nicholas Piggin Signed-off-by: Masahiro Yamada --- arch/sh/kernel/vsyscall/Makefile | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/arch/sh/kernel/vsyscall/Makefile b/arch/sh/kernel/vsyscall/Makefile index 8f0ea5fc835c..6ab108f1a0c6 100644 --- a/arch/sh/kernel/vsyscall/Makefile +++ b/arch/sh/kernel/vsyscall/Makefile @@ -1,11 +1,11 @@ -obj-y += vsyscall.o vsyscall-syscall.o +obj-y += vsyscall.o vsyscall-syscall.o vsyscall-syms.o $(obj)/vsyscall-syscall.o: \ $(foreach F,trapa,$(obj)/vsyscall-$F.so) # Teach kbuild about targets targets += $(foreach F,trapa,vsyscall-$F.o vsyscall-$F.so) -targets += vsyscall-note.o vsyscall.lds +targets += vsyscall-note.o vsyscall.lds vsyscall-dummy.o # The DSO images are built using a special linker script quiet_cmd_syscall = SYSCALL $@ @@ -26,11 +26,11 @@ $(obj)/vsyscall-%.so: $(src)/vsyscall.lds $(obj)/vsyscall-%.o FORCE # We also create a special relocatable object that should mirror the symbol # table and layout of the linked DSO. With ld -R we can then refer to # these symbols in the kernel code rather than hand-coded addresses. -extra-y += vsyscall-syms.o -$(obj)/built-in.o: $(obj)/vsyscall-syms.o -$(obj)/built-in.o: ld_flags += -R $(obj)/vsyscall-syms.o - -SYSCFLAGS_vsyscall-syms.o = -r -$(obj)/vsyscall-syms.o: $(src)/vsyscall.lds \ +SYSCFLAGS_vsyscall-dummy.o = -r +$(obj)/vsyscall-dummy.o: $(src)/vsyscall.lds \ $(obj)/vsyscall-trapa.o $(obj)/vsyscall-note.o FORCE $(call if_changed,syscall) + +LDFLAGS_vsyscall-syms.o := -r -R +$(obj)/vsyscall-syms.o: $(obj)/vsyscall-dummy.o FORCE + $(call if_changed,ld) From 26160371359ea91d8e2bdad6245f39e7ed0c17a3 Mon Sep 17 00:00:00 2001 From: Nicholas Piggin Date: Fri, 23 Jun 2017 23:44:15 +1000 Subject: [PATCH 08/12] ia64: thin archives fix linking The VDSO symbols can't be linked into built-in.o when building with thin archives, so change this to linking a new object file that is included into the built-in.o. Cc: Tony Luck Cc: Fenghua Yu Cc: linux-ia64@vger.kernel.org Signed-off-by: Nicholas Piggin Signed-off-by: Masahiro Yamada --- arch/ia64/kernel/Makefile.gate | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/arch/ia64/kernel/Makefile.gate b/arch/ia64/kernel/Makefile.gate index 92693c1d65f4..7da7c65a9bb1 100644 --- a/arch/ia64/kernel/Makefile.gate +++ b/arch/ia64/kernel/Makefile.gate @@ -1,6 +1,8 @@ # The gate DSO image is built using a special linker script. -targets += gate.so gate-syms.o gate.lds gate.o +targets += gate.so gate.lds gate.o gate-dummy.o + +obj-y += gate-syms.o CPPFLAGS_gate.lds := -P -C -U$(ARCH) @@ -12,13 +14,14 @@ GATECFLAGS_gate.so = -shared -s -Wl,-soname=linux-gate.so.1 \ $(obj)/gate.so: $(obj)/gate.lds $(obj)/gate.o FORCE $(call if_changed,gate) -$(obj)/built-in.o: $(obj)/gate-syms.o -$(obj)/built-in.o: ld_flags += -R $(obj)/gate-syms.o - -GATECFLAGS_gate-syms.o = -r -$(obj)/gate-syms.o: $(obj)/gate.lds $(obj)/gate.o FORCE +GATECFLAGS_gate-dummy.o = -r +$(obj)/gate-dummy.o: $(obj)/gate.lds $(obj)/gate.o FORCE $(call if_changed,gate) +LDFLAGS_gate-syms.o := -r -R +$(obj)/gate-syms.o: $(obj)/gate-dummy.o FORCE + $(call if_changed,ld) + # gate-data.o contains the gate DSO image as data in section .data..gate. # We must build gate.so before we can assemble it. # Note: kbuild does not track this dependency due to usage of .incbin From d6d62a1c1e2276ee6fb4c25610dbcb39beb62240 Mon Sep 17 00:00:00 2001 From: Nicholas Piggin Date: Thu, 22 Jun 2017 22:39:29 +1000 Subject: [PATCH 09/12] tile: thin archives fix linking The VDSO symbols can't be linked into built-in.o when building with thin archives, so change this to linking a new object file that is included into the built-in.o. Cc: Chris Metcalf Signed-off-by: Nicholas Piggin Signed-off-by: Masahiro Yamada --- arch/tile/kernel/vdso/Makefile | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/arch/tile/kernel/vdso/Makefile b/arch/tile/kernel/vdso/Makefile index cf162a23e866..0603ce6f047c 100644 --- a/arch/tile/kernel/vdso/Makefile +++ b/arch/tile/kernel/vdso/Makefile @@ -5,13 +5,13 @@ vdso-syms = rt_sigreturn gettimeofday obj-vdso = $(patsubst %, v%.o, $(vdso-syms)) # Build rules -targets := $(obj-vdso) vdso.so vdso.so.dbg vdso.lds +targets := $(obj-vdso) vdso.so vdso.so.dbg vdso.lds vdso-dummy.o obj-vdso := $(addprefix $(obj)/, $(obj-vdso)) # vdso32 is only for tilegx -m32 compat task. VDSO32-$(CONFIG_COMPAT) := y -obj-y += vdso.o +obj-y += vdso.o vdso-syms.o obj-$(VDSO32-y) += vdso32.o extra-y += vdso.lds CPPFLAGS_vdso.lds += -P -C -U$(ARCH) @@ -48,16 +48,16 @@ $(obj)/vdso.so.dbg: $(src)/vdso.lds $(obj-vdso) FORCE # We also create a special relocatable object that should mirror the symbol # table and layout of the linked DSO. With ld -R we can then refer to # these symbols in the kernel code rather than hand-coded addresses. -extra-y += vdso-syms.o -$(obj)/built-in.o: $(obj)/vdso-syms.o -$(obj)/built-in.o: ld_flags += -R $(obj)/vdso-syms.o SYSCFLAGS_vdso.so.dbg = -shared -s -Wl,-soname=linux-vdso.so.1 \ $(call cc-ldoption, -Wl$(comma)--hash-style=both) -SYSCFLAGS_vdso_syms.o = -r -$(obj)/vdso-syms.o: $(src)/vdso.lds $(obj)/vrt_sigreturn.o FORCE +SYSCFLAGS_vdso_dummy.o = -r +$(obj)/vdso-dummy.o: $(src)/vdso.lds $(obj)/vrt_sigreturn.o FORCE $(call if_changed,vdsold) +LDFLAGS_vdso-syms.o := -r -R +$(obj)/vdso-syms.o: $(obj)/vdso-dummy.o FORCE + $(call if_changed,ld) # strip rule for the .so file $(obj)/%.so: OBJCOPYFLAGS := -S From 827880ec260ba048f95fe646b96a205c394fa0f0 Mon Sep 17 00:00:00 2001 From: Nicholas Piggin Date: Fri, 9 Jun 2017 15:24:16 +1000 Subject: [PATCH 10/12] x86/um: thin archives build fix The linker does not like vdso-syms.lds in input archive files. Make it an extra-y instead. Cc: Jeff Dike Cc: Richard Weinberger Cc: user-mode-linux-devel@lists.sourceforge.net Signed-off-by: Nicholas Piggin Signed-off-by: Masahiro Yamada --- arch/x86/um/vdso/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/um/vdso/Makefile b/arch/x86/um/vdso/Makefile index d72dec406ccb..329406224330 100644 --- a/arch/x86/um/vdso/Makefile +++ b/arch/x86/um/vdso/Makefile @@ -53,7 +53,7 @@ CFLAGS_REMOVE_vdso-note.o = -pg -fprofile-arcs -ftest-coverage CFLAGS_REMOVE_um_vdso.o = -pg -fprofile-arcs -ftest-coverage targets += vdso-syms.lds -obj-$(VDSO64-y) += vdso-syms.lds +extra-$(VDSO64-y) += vdso-syms.lds # # Match symbols in the DSO that look like VDSO*; produce a file of constants. From 799c43415442414b1032580c47684cb709dfed6d Mon Sep 17 00:00:00 2001 From: Nicholas Piggin Date: Fri, 9 Jun 2017 15:24:17 +1000 Subject: [PATCH 11/12] kbuild: thin archives make default for all archs Make thin archives build the default, but keep the config option to allow exemptions if any breakage can't be quickly solved. Signed-off-by: Nicholas Piggin Signed-off-by: Masahiro Yamada --- Documentation/process/changes.rst | 9 ++++----- arch/Kconfig | 2 +- arch/powerpc/Kconfig | 8 -------- 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/Documentation/process/changes.rst b/Documentation/process/changes.rst index e25d63f8c0da..68be1bbbe631 100644 --- a/Documentation/process/changes.rst +++ b/Documentation/process/changes.rst @@ -31,7 +31,7 @@ you probably needn't concern yourself with isdn4k-utils. ====================== =============== ======================================== GNU C 3.2 gcc --version GNU make 3.81 make --version -binutils 2.12 ld -v +binutils 2.20 ld -v util-linux 2.10o fdformat --version module-init-tools 0.9.10 depmod -V e2fsprogs 1.41.4 e2fsck -V @@ -75,10 +75,9 @@ You will need GNU make 3.81 or later to build the kernel. Binutils -------- -Linux on IA-32 has recently switched from using ``as86`` to using ``gas`` for -assembling the 16-bit boot code, removing the need for ``as86`` to compile -your kernel. This change does, however, mean that you need a recent -release of binutils. +The build system has, as of 4.13, switched to using thin archives (`ar T`) +rather than incremental linking (`ld -r`) for built-in.o intermediate steps. +This requires binutils 2.20 or newer. Perl ---- diff --git a/arch/Kconfig b/arch/Kconfig index 6c00e5b00f8b..3abe581878d6 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -511,7 +511,7 @@ config CC_STACKPROTECTOR_STRONG endchoice config THIN_ARCHIVES - bool + def_bool y help Select this if the architecture wants to use thin archives instead of ld -r to create the built-in.o files. diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index f7c8f9972f61..80d882a78426 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -472,14 +472,6 @@ config MPROFILE_KERNEL depends on PPC64 && CPU_LITTLE_ENDIAN def_bool !DISABLE_MPROFILE_KERNEL -config USE_THIN_ARCHIVES - bool "Build the kernel using thin archives" - default n - select THIN_ARCHIVES - help - Build the kernel using thin archives. - If you're unsure say N. - config IOMMU_HELPER def_bool PPC64 From 42317ea79d9af0a83b6cfdfe43c27a91d468bfb1 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 30 Jun 2017 01:03:32 +0900 Subject: [PATCH 12/12] tile: remove unneeded extra-y in Makefile This extra-y is unneeded because vdso.lds is generated according to the dependency. Signed-off-by: Masahiro Yamada --- arch/tile/kernel/vdso/Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/tile/kernel/vdso/Makefile b/arch/tile/kernel/vdso/Makefile index 0603ce6f047c..71d5f5d71f79 100644 --- a/arch/tile/kernel/vdso/Makefile +++ b/arch/tile/kernel/vdso/Makefile @@ -13,7 +13,6 @@ VDSO32-$(CONFIG_COMPAT) := y obj-y += vdso.o vdso-syms.o obj-$(VDSO32-y) += vdso32.o -extra-y += vdso.lds CPPFLAGS_vdso.lds += -P -C -U$(ARCH) # vDSO code runs in userspace and -pg doesn't help with profiling anyway.