Skip to content
/ linux Public
forked from torvalds/linux

Commit

Permalink
Makefile: remove redundant tool coverage variables
Browse files Browse the repository at this point in the history
Now Kbuild provides reasonable defaults for objtool, sanitizers, and
profilers.

Remove redundant variables.

Note:

This commit changes the coverage for some objects:

  - include arch/mips/vdso/vdso-image.o into UBSAN, GCOV, KCOV
  - include arch/sparc/vdso/vdso-image-*.o into UBSAN
  - include arch/sparc/vdso/vma.o into UBSAN
  - include arch/x86/entry/vdso/extable.o into KASAN, KCSAN, UBSAN, GCOV, KCOV
  - include arch/x86/entry/vdso/vdso-image-*.o into KASAN, KCSAN, UBSAN, GCOV, KCOV
  - include arch/x86/entry/vdso/vdso32-setup.o into KASAN, KCSAN, UBSAN, GCOV, KCOV
  - include arch/x86/entry/vdso/vma.o into GCOV, KCOV
  - include arch/x86/um/vdso/vma.o into KASAN, GCOV, KCOV

I believe these are positive effects because all of them are kernel
space objects.

Signed-off-by: Masahiro Yamada <[email protected]>
Reviewed-by: Kees Cook <[email protected]>
Tested-by: Roberto Sassu <[email protected]>
  • Loading branch information
masahir0y committed May 14, 2024
1 parent 9c2d132 commit 7f7f6f7
Show file tree
Hide file tree
Showing 34 changed files with 0 additions and 241 deletions.
1 change: 0 additions & 1 deletion arch/arm/boot/bootp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# This file is included by the global makefile so that you can add your own
# architecture-specific flags and dependencies.
#
GCOV_PROFILE := n

ifdef PHYS_OFFSET
add_hex = $(shell printf 0x%x $$(( $(1) + $(2) )) )
Expand Down
7 changes: 0 additions & 7 deletions arch/arm/boot/compressed/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,6 @@ ifeq ($(CONFIG_ARM_VIRT_EXT),y)
OBJS += hyp-stub.o
endif

GCOV_PROFILE := n
KASAN_SANITIZE := n

# Prevents link failures: __sanitizer_cov_trace_pc() is not linked in.
KCOV_INSTRUMENT := n
UBSAN_SANITIZE := n

#
# Architecture dependencies
#
Expand Down
9 changes: 0 additions & 9 deletions arch/arm/vdso/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,6 @@ else
CFLAGS_vgettimeofday.o = -O2 -include $(c-gettimeofday-y)
endif

# Disable gcov profiling for VDSO code
GCOV_PROFILE := n
UBSAN_SANITIZE := n

# Prevents link failures: __sanitizer_cov_trace_pc() is not linked in.
KCOV_INSTRUMENT := n

KASAN_SANITIZE := n

# Force dependency
$(obj)/vdso.o : $(obj)/vdso.so

Expand Down
6 changes: 0 additions & 6 deletions arch/arm64/kernel/pi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_SCS), $(KBUILD_CFLAGS))
# disable LTO
KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_LTO), $(KBUILD_CFLAGS))

GCOV_PROFILE := n
KASAN_SANITIZE := n
KCSAN_SANITIZE := n
UBSAN_SANITIZE := n
KCOV_INSTRUMENT := n

hostprogs := relacheck

quiet_cmd_piobjcopy = $(quiet_cmd_objcopy)
Expand Down
8 changes: 0 additions & 8 deletions arch/arm64/kernel/vdso/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,13 @@ CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE) -Os $(CC_FLAGS_SCS) \
$(RANDSTRUCT_CFLAGS) $(GCC_PLUGINS_CFLAGS) \
$(CC_FLAGS_LTO) $(CC_FLAGS_CFI) \
-Wmissing-prototypes -Wmissing-declarations
KASAN_SANITIZE := n
KCSAN_SANITIZE := n
UBSAN_SANITIZE := n
OBJECT_FILES_NON_STANDARD := y
KCOV_INSTRUMENT := n

CFLAGS_vgettimeofday.o = -O2 -mcmodel=tiny -fasynchronous-unwind-tables

ifneq ($(c-gettimeofday-y),)
CFLAGS_vgettimeofday.o += -include $(c-gettimeofday-y)
endif

# Disable gcov profiling for VDSO code
GCOV_PROFILE := n

targets += vdso.lds
CPPFLAGS_vdso.lds += -P -C -U$(ARCH)

Expand Down
13 changes: 0 additions & 13 deletions arch/arm64/kvm/hyp/nvhe/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,3 @@ KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_FTRACE) $(CC_FLAGS_SCS) $(CC_FLAGS_CFI)
# causes a build failure. Remove profile optimization flags.
KBUILD_CFLAGS := $(filter-out -fprofile-sample-use=% -fprofile-use=%, $(KBUILD_CFLAGS))
KBUILD_CFLAGS += -fno-asynchronous-unwind-tables -fno-unwind-tables

# KVM nVHE code is run at a different exception code with a different map, so
# compiler instrumentation that inserts callbacks or checks into the code may
# cause crashes. Just disable it.
GCOV_PROFILE := n
KASAN_SANITIZE := n
KCSAN_SANITIZE := n
UBSAN_SANITIZE := n
KCOV_INSTRUMENT := n

# Skip objtool checking for this directory because nVHE code is compiled with
# non-standard build rules.
OBJECT_FILES_NON_STANDARD := y
4 changes: 0 additions & 4 deletions arch/csky/kernel/vdso/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ obj-vdso := $(addprefix $(obj)/, $(obj-vdso))
obj-y += vdso.o vdso-syms.o
CPPFLAGS_vdso.lds += -P -C -U$(ARCH)

# Disable gcov profiling for VDSO code
GCOV_PROFILE := n
KCOV_INSTRUMENT := n

# Force dependency
$(obj)/vdso.o: $(obj)/vdso.so

Expand Down
7 changes: 0 additions & 7 deletions arch/loongarch/vdso/Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
# SPDX-License-Identifier: GPL-2.0
# Objects to go into the VDSO.

KASAN_SANITIZE := n
UBSAN_SANITIZE := n
KCOV_INSTRUMENT := n
OBJECT_FILES_NON_STANDARD := y

# Include the generic Makefile to check the built vdso.
include $(srctree)/lib/vdso/Makefile

Expand Down Expand Up @@ -39,8 +34,6 @@ ldflags-y := -Bsymbolic --no-undefined -soname=linux-vdso.so.1 \
$(filter -E%,$(KBUILD_CFLAGS)) -nostdlib -shared \
--hash-style=sysv --build-id -T

GCOV_PROFILE := n

#
# Shared build commands.
#
Expand Down
6 changes: 0 additions & 6 deletions arch/mips/boot/compressed/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,6 @@ KBUILD_AFLAGS := $(KBUILD_AFLAGS) -D__ASSEMBLY__ \
-DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) \
-DKERNEL_ENTRY=$(VMLINUX_ENTRY_ADDRESS)

# Prevents link failures: __sanitizer_cov_trace_pc() is not linked in.
KCOV_INSTRUMENT := n
GCOV_PROFILE := n
UBSAN_SANITIZE := n
KCSAN_SANITIZE := n

# decompressor objects (linked with vmlinuz)
vmlinuzobjs-y := $(obj)/head.o $(obj)/decompress.o $(obj)/string.o $(obj)/bswapsi.o

Expand Down
7 changes: 0 additions & 7 deletions arch/mips/vdso/Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# SPDX-License-Identifier: GPL-2.0
# Objects to go into the VDSO.

# Sanitizer runtimes are unavailable and cannot be linked here.
KCSAN_SANITIZE := n

# Include the generic Makefile to check the built vdso.
include $(srctree)/lib/vdso/Makefile

Expand Down Expand Up @@ -60,10 +57,6 @@ ldflags-y := -Bsymbolic --no-undefined -soname=linux-vdso.so.1 \

CFLAGS_REMOVE_vdso.o = $(CC_FLAGS_FTRACE)

GCOV_PROFILE := n
UBSAN_SANITIZE := n
KCOV_INSTRUMENT := n

# Check that we don't have PIC 'jalr t9' calls left
quiet_cmd_vdso_mips_check = VDSOCHK $@
cmd_vdso_mips_check = if $(OBJDUMP) --disassemble $@ | grep -E -h "jalr.*t9" > /dev/null; \
Expand Down
4 changes: 0 additions & 4 deletions arch/parisc/boot/compressed/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
# create a compressed self-extracting vmlinux image from the original vmlinux
#

KCOV_INSTRUMENT := n
GCOV_PROFILE := n
UBSAN_SANITIZE := n

OBJECTS := head.o real2.o firmware.o misc.o piggy.o
targets := vmlinux.lds vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2
targets += vmlinux.bin.xz vmlinux.bin.lzma vmlinux.bin.lzo vmlinux.bin.lz4
Expand Down
8 changes: 0 additions & 8 deletions arch/powerpc/kernel/vdso/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,6 @@ obj-vdso32 := $(addprefix $(obj)/, $(obj-vdso32))
targets += $(obj-vdso64) vdso64.so.dbg vgettimeofday-64.o
obj-vdso64 := $(addprefix $(obj)/, $(obj-vdso64))

GCOV_PROFILE := n
KCOV_INSTRUMENT := n
UBSAN_SANITIZE := n
KASAN_SANITIZE := n
KCSAN_SANITIZE := n

ccflags-y := -fno-common -fno-builtin
ldflags-y := -Wl,--hash-style=both -nostdlib -shared -z noexecstack $(CLANG_FLAGS)
ldflags-$(CONFIG_LD_IS_LLD) += $(call cc-option,--ld-path=$(LD),-fuse-ld=lld)
Expand Down Expand Up @@ -114,5 +108,3 @@ quiet_cmd_vdso64ld_and_check = VDSO64L $@
cmd_vdso64ld_and_check = $(VDSOCC) $(ldflags-y) $(LD64FLAGS) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^); $(cmd_vdso_check)
quiet_cmd_vdso64as = VDSO64A $@
cmd_vdso64as = $(VDSOCC) $(a_flags) $(AS64FLAGS) -c -o $@ $<

OBJECT_FILES_NON_STANDARD := y
3 changes: 0 additions & 3 deletions arch/powerpc/purgatory/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-2.0

KASAN_SANITIZE := n
KCSAN_SANITIZE := n

targets += trampoline_$(BITS).o purgatory.ro

# When profile-guided optimization is enabled, llvm emits two different
Expand Down
2 changes: 0 additions & 2 deletions arch/riscv/boot/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
# Based on the ia64 and arm64 boot/Makefile.
#

KCOV_INSTRUMENT := n

OBJCOPYFLAGS_Image :=-O binary -R .note -R .note.gnu.build-id -R .comment -S
OBJCOPYFLAGS_loader.bin :=-O binary
OBJCOPYFLAGS_xipImage :=-O binary -R .note -R .note.gnu.build-id -R .comment -S
Expand Down
6 changes: 0 additions & 6 deletions arch/riscv/kernel/compat_vdso/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,6 @@ obj-compat_vdso := $(addprefix $(obj)/, $(obj-compat_vdso))
obj-y += compat_vdso.o
CPPFLAGS_compat_vdso.lds += -P -C -DCOMPAT_VDSO -U$(ARCH)

# Disable profiling and instrumentation for VDSO code
GCOV_PROFILE := n
KCOV_INSTRUMENT := n
KASAN_SANITIZE := n
UBSAN_SANITIZE := n

# Force dependency
$(obj)/compat_vdso.o: $(obj)/compat_vdso.so

Expand Down
6 changes: 0 additions & 6 deletions arch/riscv/kernel/pi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@ KBUILD_CFLAGS += -mcmodel=medany
CFLAGS_cmdline_early.o += -D__NO_FORTIFY
CFLAGS_lib-fdt_ro.o += -D__NO_FORTIFY

GCOV_PROFILE := n
KASAN_SANITIZE := n
KCSAN_SANITIZE := n
UBSAN_SANITIZE := n
KCOV_INSTRUMENT := n

$(obj)/%.pi.o: OBJCOPYFLAGS := --prefix-symbols=__pi_ \
--remove-section=.note.gnu.property \
--prefix-alloc-sections=.init.pi
Expand Down
6 changes: 0 additions & 6 deletions arch/riscv/kernel/vdso/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@ endif
CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE) $(CC_FLAGS_SCS)
CFLAGS_REMOVE_hwprobe.o = $(CC_FLAGS_FTRACE) $(CC_FLAGS_SCS)

# Disable profiling and instrumentation for VDSO code
GCOV_PROFILE := n
KCOV_INSTRUMENT := n
KASAN_SANITIZE := n
UBSAN_SANITIZE := n

# Force dependency
$(obj)/vdso.o: $(obj)/vdso.so

Expand Down
8 changes: 0 additions & 8 deletions arch/riscv/purgatory/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# SPDX-License-Identifier: GPL-2.0
OBJECT_FILES_NON_STANDARD := y

purgatory-y := purgatory.o sha256.o entry.o string.o ctype.o memcpy.o memset.o
purgatory-y += strcmp.o strlen.o strncmp.o
Expand Down Expand Up @@ -47,13 +46,6 @@ LDFLAGS_purgatory.ro := -r $(PURGATORY_LDFLAGS)
LDFLAGS_purgatory.chk := $(PURGATORY_LDFLAGS)
targets += purgatory.ro purgatory.chk

# Sanitizer, etc. runtimes are unavailable and cannot be linked here.
GCOV_PROFILE := n
KASAN_SANITIZE := n
UBSAN_SANITIZE := n
KCSAN_SANITIZE := n
KCOV_INSTRUMENT := n

# These are adjustments to the compiler flags used for objects that
# make up the standalone purgatory.ro

Expand Down
8 changes: 0 additions & 8 deletions arch/s390/kernel/vdso32/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# SPDX-License-Identifier: GPL-2.0
# List of files in the vdso

KCOV_INSTRUMENT := n

# Include the generic Makefile to check the built vdso.
include $(srctree)/lib/vdso/Makefile
obj-vdso32 = vdso_user_wrapper-32.o note-32.o
Expand Down Expand Up @@ -32,12 +30,6 @@ obj-y += vdso32_wrapper.o
targets += vdso32.lds
CPPFLAGS_vdso32.lds += -P -C -U$(ARCH)

# Disable gcov profiling, ubsan and kasan for VDSO code
GCOV_PROFILE := n
UBSAN_SANITIZE := n
KASAN_SANITIZE := n
KCSAN_SANITIZE := n

# Force dependency (incbin is bad)
$(obj)/vdso32_wrapper.o : $(obj)/vdso32.so

Expand Down
8 changes: 0 additions & 8 deletions arch/s390/kernel/vdso64/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# SPDX-License-Identifier: GPL-2.0
# List of files in the vdso

KCOV_INSTRUMENT := n

# Include the generic Makefile to check the built vdso.
include $(srctree)/lib/vdso/Makefile
obj-vdso64 = vdso_user_wrapper.o note.o
Expand Down Expand Up @@ -37,12 +35,6 @@ obj-y += vdso64_wrapper.o
targets += vdso64.lds
CPPFLAGS_vdso64.lds += -P -C -U$(ARCH)

# Disable gcov profiling, ubsan and kasan for VDSO code
GCOV_PROFILE := n
UBSAN_SANITIZE := n
KASAN_SANITIZE := n
KCSAN_SANITIZE := n

# Force dependency (incbin is bad)
$(obj)/vdso64_wrapper.o : $(obj)/vdso64.so

Expand Down
8 changes: 0 additions & 8 deletions arch/s390/purgatory/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# SPDX-License-Identifier: GPL-2.0

OBJECT_FILES_NON_STANDARD := y

purgatory-y := head.o purgatory.o string.o sha256.o mem.o

targets += $(purgatory-y) purgatory.lds purgatory purgatory.chk purgatory.ro
Expand All @@ -15,12 +13,6 @@ CFLAGS_sha256.o := -D__DISABLE_EXPORTS -D__NO_FORTIFY
$(obj)/mem.o: $(srctree)/arch/s390/lib/mem.S FORCE
$(call if_changed_rule,as_o_S)

KCOV_INSTRUMENT := n
GCOV_PROFILE := n
UBSAN_SANITIZE := n
KASAN_SANITIZE := n
KCSAN_SANITIZE := n

KBUILD_CFLAGS := -fno-strict-aliasing -Wall -Wstrict-prototypes
KBUILD_CFLAGS += -Wno-pointer-sign -Wno-sign-compare
KBUILD_CFLAGS += -fno-zero-initialized-in-bss -fno-builtin -ffreestanding
Expand Down
3 changes: 0 additions & 3 deletions arch/sh/boot/compressed/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ OBJECTS := head_32.o misc.o cache.o piggy.o \
targets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 \
vmlinux.bin.lzma vmlinux.bin.xz vmlinux.bin.lzo $(OBJECTS)

GCOV_PROFILE := n
UBSAN_SANITIZE := n

#
# IMAGE_OFFSET is the load offset of the compression loader
#
Expand Down
2 changes: 0 additions & 2 deletions arch/sparc/vdso/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#
# Building vDSO images for sparc.
#
UBSAN_SANITIZE := n

# files to link into the vdso
vobjs-y := vdso-note.o vclock_gettime.o
Expand Down Expand Up @@ -106,4 +105,3 @@ quiet_cmd_vdso = VDSO $@
sh $(src)/checkundef.sh '$(OBJDUMP)' '$@'

VDSO_LDFLAGS = -shared --hash-style=both --build-id=sha1 -Bsymbolic
GCOV_PROFILE := n
15 changes: 0 additions & 15 deletions arch/x86/boot/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,6 @@
# Changed by many, many contributors over the years.
#

# Sanitizer runtimes are unavailable and cannot be linked for early boot code.
KASAN_SANITIZE := n
KCSAN_SANITIZE := n
KMSAN_SANITIZE := n
OBJECT_FILES_NON_STANDARD := y

# Kernel does not boot with kcov instrumentation here.
# One of the problems observed was insertion of __sanitizer_cov_trace_pc()
# callback into middle of per-cpu data enabling code. Thus the callback observed
# inconsistent state and crashed. We are interested mostly in syscall coverage,
# so boot code is not interesting anyway.
KCOV_INSTRUMENT := n

# If you want to preset the SVGA mode, uncomment the next line and
# set SVGA_MODE to whatever number you want.
# Set it to -DSVGA_MODE=NORMAL_VGA if you just want the EGA/VGA mode.
Expand Down Expand Up @@ -69,8 +56,6 @@ KBUILD_CFLAGS := $(REALMODE_CFLAGS) -D_SETUP
KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
KBUILD_CFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
KBUILD_CFLAGS += -fno-asynchronous-unwind-tables
GCOV_PROFILE := n
UBSAN_SANITIZE := n

$(obj)/bzImage: asflags-y := $(SVGA_MODE)

Expand Down
Loading

0 comments on commit 7f7f6f7

Please sign in to comment.