Merge 4.9.258 into android-4.9-q
Linux 4.9.258
kvm: check tlbs_dirty directly
scsi: qla2xxx: Fix crash during driver load on big endian machines
xen-blkback: fix error handling in xen_blkbk_map()
xen-scsiback: don't "handle" error by BUG()
xen-netback: don't "handle" error by BUG()
xen-blkback: don't "handle" error by BUG()
xen/arm: don't ignore return errors from set_phys_to_machine
Xen/gntdev: correct error checking in gntdev_map_grant_pages()
Xen/gntdev: correct dev_bus_addr handling in gntdev_map_grant_pages()
Xen/x86: also check kernel mapping in set_foreign_p2m_mapping()
Xen/x86: don't bail early from clear_foreign_p2m_mapping()
* tracing: Avoid calling cc-option -mrecord-mcount for every Makefile
Makefile
scripts/Makefile.build
* tracing: Fix SKIP_STACK_VALIDATION=1 build due to bad merge with -mrecord-mcount
scripts/Makefile.build
* trace: Use -mcount-record for dynamic ftrace
scripts/Makefile.build
x86/build: Disable CET instrumentation in the kernel for 32-bit too
vsock: fix locking in vsock_shutdown()
vsock/virtio: update credit only if socket is not closed
* net: watchdog: hold device global xmit lock during tx disable
include/linux/netdevice.h
net/vmw_vsock: improve locking in vsock_connect_timeout()
usb: dwc3: ulpi: Replace CPU-based busyloop with Protocol-based one
usb: dwc3: ulpi: fix checkpatch warning
h8300: fix PREEMPTION build, TI_PRE_COUNT undefined
* netfilter: conntrack: skip identical origin tuple in same zone only
net/netfilter/nf_conntrack_core.c
xen/netback: avoid race in xenvif_rx_ring_slots_available()
netfilter: xt_recent: Fix attempt to update deleted entry
* bpf: Check for integer overflow when using roundup_pow_of_two()
kernel/bpf/stackmap.c
* memblock: do not start bottom-up allocations with kernel_end
mm/memblock.c
ARM: dts: lpc32xx: Revert set default clock rate of HCLK PLL
* ovl: skip getxattr of security labels
fs/overlayfs/copy_up.c
* tracing: Check length before giving out the filter buffer
kernel/trace/trace.c
* tracing: Do not count ftrace events in top level enable output
kernel/trace/trace_events.c
squashfs: add more sanity checks in xattr id lookup
squashfs: add more sanity checks in inode lookup
squashfs: add more sanity checks in id lookup
* futex: Cure exit race
kernel/futex.c
* futex: Change locking rules
kernel/futex.c
* futex: Ensure the correct return value from futex_lock_pi()
kernel/futex.c
* memcg: fix a crash in wb_workfn when a device disappears
fs/fs-writeback.c
include/linux/backing-dev.h
include/trace/events/writeback.h
mm/backing-dev.c
* include/trace/events/writeback.h: fix -Wstringop-truncation warnings
include/trace/events/writeback.h
* lib/string: Add strscpy_pad() function
include/linux/string.h
lib/string.c
SUNRPC: Handle 0 length opaque XDR object data properly
* SUNRPC: Move simple_get_bytes and simple_get_netobj into private header
include/linux/sunrpc/xdr.h
iwlwifi: mvm: guard against device removal in reprobe
iwlwifi: pcie: add a NULL check in iwl_pcie_txq_unmap
iwlwifi: mvm: take mutex for calling iwl_mvm_get_sync_time()
* af_key: relax availability checks for skb size calculation
net/key/af_key.c
remoteproc: qcom_q6v5_mss: Validate MBA firmware size before load
* fgraph: Initialize tracing_graph_pause at task creation
include/linux/ftrace.h
* mm: memcontrol: fix NULL pointer crash in test_clear_page_writeback()
include/linux/memcontrol.h
mm/page-writeback.c
Merge 4.9.257 into android-4.9-q
Linux 4.9.257
ALSA: hda/realtek - Fix typo of pincfg for Dell quirk
iommu/vt-d: Do not use flush-queue when caching-mode is on
ACPI: thermal: Do not call acpi_thermal_check() directly
* Input: xpad - sync supported devices with fork on GitHub
drivers/input/joystick/xpad.c
x86/apic: Add extra serialization for non-serializing MSRs
* x86/build: Disable CET instrumentation in the kernel
Makefile
mm: thp: fix MADV_REMOVE deadlock on shmem THP
mm: hugetlb: remove VM_BUG_ON_PAGE from page_huge_active
mm: hugetlb: fix a race between isolating and freeing page
* mm: hugetlbfs: fix cannot migrate the fallocated HugeTLB page
include/linux/hugetlb.h
ARM: footbridge: fix dc21285 PCI configuration accessors
* mmc: core: Limit retries when analyse of SDIO tuples fails
drivers/mmc/core/sdio_cis.c
cifs: report error instead of invalid when revalidating a dentry fails
* xhci: fix bounce buffer usage for non-sg list case
drivers/usb/host/xhci-ring.c
kretprobe: Avoid re-registration of the same kretprobe earlier
mac80211: fix station rate table updates on assoc
usb: dwc2: Fix endpoint direction check in ep_from_windex
USB: usblp: don't call usb_set_interface if there's a single alt
USB: gadget: legacy: fix an error code in eth_bind()
* elfcore: fix building with clang
include/linux/elfcore.h
kernel/Makefile
net: lapb: Copy the skb before sending a packet
Input: i8042 - unbreak Pegatron C15B
USB: serial: option: Adding support for Cinterion MV31
USB: serial: cp210x: add new VID/PID for supporting Teraoka AD2000
USB: serial: cp210x: add pid/vid for WSDA-200-USB
* stable: clamp SUBLEVEL in 4.4 and 4.9
Makefile
objtool: Don't fail on missing symbol table
scsi: ibmvfc: Set default timeout to avoid crash during migration
mac80211: fix fast-rx encryption check
scsi: libfc: Avoid invoking response handler twice if ep is already completed
* futex: Handle faults correctly for PI futexes
kernel/futex.c
* futex: Simplify fixup_pi_state_owner()
kernel/futex.c
* futex: Use pi_state_update_owner() in put_pi_state()
kernel/futex.c
* rtmutex: Remove unused argument from rt_mutex_proxy_unlock()
kernel/futex.c
kernel/locking/rtmutex.c
kernel/locking/rtmutex_common.h
* futex: Provide and use pi_state_update_owner()
kernel/futex.c
* futex: Replace pointless printk in fixup_owner()
kernel/futex.c
* futex: Avoid violating the 10th rule of futex
kernel/futex.c
kernel/locking/rtmutex.c
kernel/locking/rtmutex_common.h
* futex: Rework inconsistent rt_mutex/futex_q state
kernel/futex.c
* futex: Remove rt_mutex_deadlock_account_*()
kernel/locking/rtmutex.c
kernel/locking/rtmutex.h
* futex,rt_mutex: Provide futex specific rt_mutex API
kernel/futex.c
kernel/locking/rtmutex.c
kernel/locking/rtmutex_common.h
* net_sched: reject silly cell_log in qdisc_get_rtab()
net/sched/sch_api.c
ibmvnic: Ensure that CRQ entry read are correctly ordered
net: dsa: bcm_sf2: put device node before return
Merge 4.9.256 into android-4.9-q
Linux 4.9.256
Merge 4.9.255 into android-4.9-q
Linux 4.9.255
NFC: fix possible resource leak
NFC: fix resource leak when target index is invalid
iommu/vt-d: Don't dereference iommu_device if IOMMU_API is not built
iommu/vt-d: Gracefully handle DMAR units with no supported address widths
can: dev: prevent potential information leak in can_fill_info()
mac80211: pause TX while changing interface type
iwlwifi: pcie: reschedule in long-running memory reads
iwlwifi: pcie: use jiffies for memory read spin time limit
RDMA/cxgb4: Fix the reported max_recv_sge value
* xfrm: Fix oops in xfrm_replay_advance_bmp
net/xfrm/xfrm_input.c
netfilter: nft_dynset: add timeout extension to template
ARM: imx: build suspend-imx6.S with arm instruction set
mt7601u: fix rx buffer refcounting
mt7601u: fix kernel crash unplugging the device
* leds: trigger: fix potential deadlock with libata
drivers/leds/led-triggers.c
KVM: x86: get smi pending status correctly
KVM: x86/pmu: Fix HW_REF_CPU_CYCLES event pseudo-encoding in intel_arch_events[]
* futex: Prevent exit livelock
kernel/futex.c
* futex: Provide distinct return value when owner is exiting
kernel/futex.c
* futex: Add mutex around futex exit
include/linux/futex.h
include/linux/sched.h
kernel/futex.c
* futex: Provide state handling for exec() as well
kernel/futex.c
* futex: Sanitize exit state handling
kernel/futex.c
* futex: Mark the begin of futex exit explicitly
include/linux/futex.h
kernel/exit.c
kernel/futex.c
* futex: Set task::futex_state to DEAD right after handling futex exit
kernel/exit.c
kernel/futex.c
* futex: Split futex_mm_release() for exit/exec
include/linux/futex.h
kernel/fork.c
kernel/futex.c
* exit/exec: Seperate mm_release()
fs/exec.c
include/linux/sched.h
kernel/exit.c
kernel/fork.c
* futex: Replace PF_EXITPIDONE with a state
include/linux/futex.h
include/linux/sched.h
kernel/exit.c
kernel/futex.c
* futex: Move futex exit handling into futex code
include/linux/compat.h
include/linux/futex.h
kernel/fork.c
kernel/futex.c
* y2038: futex: Move compat implementation into futex.c
include/linux/futex.h
kernel/Makefile
kernel/futex.c
net: usb: qmi_wwan: added support for Thales Cinterion PLSx3 modem family
* wext: fix NULL-ptr-dereference with cfg80211's lack of commit()
net/wireless/wext-core.c
ACPI: sysfs: Prefer "compatible" modalias
Bug: 181732917
Change-Id: Ice169f5980390199db8f86d42e944cdf5f37c562
Signed-off-by: Lucas Wei <lucaswei@google.com>
681 lines
21 KiB
Makefile
681 lines
21 KiB
Makefile
# ==========================================================================
|
|
# Building
|
|
# ==========================================================================
|
|
|
|
src := $(obj)
|
|
|
|
PHONY := __build
|
|
__build:
|
|
|
|
# Init all relevant variables used in kbuild files so
|
|
# 1) they have correct type
|
|
# 2) they do not inherit any value from the environment
|
|
obj-y :=
|
|
obj-m :=
|
|
lib-y :=
|
|
lib-m :=
|
|
always :=
|
|
targets :=
|
|
subdir-y :=
|
|
subdir-m :=
|
|
EXTRA_AFLAGS :=
|
|
EXTRA_CFLAGS :=
|
|
EXTRA_CPPFLAGS :=
|
|
EXTRA_LDFLAGS :=
|
|
asflags-y :=
|
|
ccflags-y :=
|
|
cppflags-y :=
|
|
ldflags-y :=
|
|
|
|
subdir-asflags-y :=
|
|
subdir-ccflags-y :=
|
|
|
|
# Read auto.conf if it exists, otherwise ignore
|
|
-include include/config/auto.conf
|
|
|
|
include scripts/Kbuild.include
|
|
|
|
# For backward compatibility check that these variables do not change
|
|
save-cflags := $(CFLAGS)
|
|
|
|
# The filename Kbuild has precedence over Makefile
|
|
kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
|
|
kbuild-file := $(if $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Kbuild,$(kbuild-dir)/Makefile)
|
|
include $(kbuild-file)
|
|
|
|
# If the save-* variables changed error out
|
|
ifeq ($(KBUILD_NOPEDANTIC),)
|
|
ifneq ("$(save-cflags)","$(CFLAGS)")
|
|
$(error CFLAGS was changed in "$(kbuild-file)". Fix it to use ccflags-y)
|
|
endif
|
|
endif
|
|
|
|
include scripts/Makefile.lib
|
|
|
|
ifdef host-progs
|
|
ifneq ($(hostprogs-y),$(host-progs))
|
|
$(warning kbuild: $(obj)/Makefile - Usage of host-progs is deprecated. Please replace with hostprogs-y!)
|
|
hostprogs-y += $(host-progs)
|
|
endif
|
|
endif
|
|
|
|
# Do not include host rules unless needed
|
|
ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),)
|
|
include scripts/Makefile.host
|
|
endif
|
|
|
|
# Do not include host rules unless needed
|
|
ifneq ($(dtbo-y),)
|
|
include scripts/Makefile.dtbo
|
|
endif
|
|
|
|
ifneq ($(KBUILD_SRC),)
|
|
# Create output directory if not already present
|
|
_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
|
|
|
|
# Create directories for object files if directory does not exist
|
|
# Needed when obj-y := dir/file.o syntax is used
|
|
_dummy := $(foreach d,$(obj-dirs), $(shell [ -d $(d) ] || mkdir -p $(d)))
|
|
endif
|
|
|
|
ifndef obj
|
|
$(warning kbuild: Makefile.build is included improperly)
|
|
endif
|
|
|
|
# ===========================================================================
|
|
|
|
ifneq ($(strip $(lib-y) $(lib-m) $(lib-)),)
|
|
lib-target := $(obj)/lib.a
|
|
obj-y += $(obj)/lib-ksyms.o
|
|
endif
|
|
|
|
ifneq ($(strip $(obj-y) $(obj-m) $(obj-) $(subdir-m) $(lib-target)),)
|
|
builtin-target := $(obj)/built-in.o
|
|
endif
|
|
|
|
modorder-target := $(obj)/modules.order
|
|
|
|
# We keep a list of all modules in $(MODVERDIR)
|
|
|
|
__build: $(if $(KBUILD_BUILTIN),$(builtin-target) $(lib-target) $(extra-y)) \
|
|
$(if $(KBUILD_MODULES),$(obj-m) $(modorder-target)) \
|
|
$(subdir-ym) $(always)
|
|
@:
|
|
|
|
# Linus' kernel sanity checking tool
|
|
ifneq ($(KBUILD_CHECKSRC),0)
|
|
ifeq ($(KBUILD_CHECKSRC),2)
|
|
quiet_cmd_force_checksrc = CHECK $<
|
|
cmd_force_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< ;
|
|
else
|
|
quiet_cmd_checksrc = CHECK $<
|
|
cmd_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< ;
|
|
endif
|
|
endif
|
|
|
|
# Do section mismatch analysis for each module/built-in.o
|
|
ifdef CONFIG_DEBUG_SECTION_MISMATCH
|
|
cmd_secanalysis = ; scripts/mod/modpost $@
|
|
endif
|
|
|
|
# Compile C sources (.c)
|
|
# ---------------------------------------------------------------------------
|
|
|
|
# Default is built-in, unless we know otherwise
|
|
modkern_cflags = \
|
|
$(if $(part-of-module), \
|
|
$(KBUILD_CFLAGS_MODULE) $(CFLAGS_MODULE), \
|
|
$(KBUILD_CFLAGS_KERNEL) $(CFLAGS_KERNEL))
|
|
quiet_modtag := $(empty) $(empty)
|
|
|
|
$(real-objs-m) : part-of-module := y
|
|
$(real-objs-m:.o=.i) : part-of-module := y
|
|
$(real-objs-m:.o=.s) : part-of-module := y
|
|
$(real-objs-m:.o=.lst): part-of-module := y
|
|
|
|
$(real-objs-m) : quiet_modtag := [M]
|
|
$(real-objs-m:.o=.i) : quiet_modtag := [M]
|
|
$(real-objs-m:.o=.s) : quiet_modtag := [M]
|
|
$(real-objs-m:.o=.lst): quiet_modtag := [M]
|
|
|
|
$(obj-m) : quiet_modtag := [M]
|
|
|
|
# Default for not multi-part modules
|
|
modname = $(basetarget)
|
|
|
|
$(multi-objs-m) : modname = $(modname-multi)
|
|
$(multi-objs-m:.o=.i) : modname = $(modname-multi)
|
|
$(multi-objs-m:.o=.s) : modname = $(modname-multi)
|
|
$(multi-objs-m:.o=.lst) : modname = $(modname-multi)
|
|
$(multi-objs-y) : modname = $(modname-multi)
|
|
$(multi-objs-y:.o=.i) : modname = $(modname-multi)
|
|
$(multi-objs-y:.o=.s) : modname = $(modname-multi)
|
|
$(multi-objs-y:.o=.lst) : modname = $(modname-multi)
|
|
|
|
quiet_cmd_cc_s_c = CC $(quiet_modtag) $@
|
|
cmd_cc_s_c = $(CC) $(c_flags) $(DISABLE_LTO) -fverbose-asm -S -o $@ $<
|
|
|
|
$(obj)/%.s: $(src)/%.c FORCE
|
|
$(call if_changed_dep,cc_s_c)
|
|
|
|
quiet_cmd_cpp_i_c = CPP $(quiet_modtag) $@
|
|
cmd_cpp_i_c = $(CPP) $(c_flags) -o $@ $<
|
|
|
|
$(obj)/%.i: $(src)/%.c FORCE
|
|
$(call if_changed_dep,cpp_i_c)
|
|
|
|
# These mirror gensymtypes_S and co below, keep them in synch.
|
|
cmd_gensymtypes_c = \
|
|
$(CPP) -D__GENKSYMS__ $(c_flags) $< | \
|
|
$(GENKSYMS) $(if $(1), -T $(2)) \
|
|
$(patsubst y,-s _,$(CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX)) \
|
|
$(if $(KBUILD_PRESERVE),-p) \
|
|
-r $(firstword $(wildcard $(2:.symtypes=.symref) /dev/null))
|
|
|
|
quiet_cmd_cc_symtypes_c = SYM $(quiet_modtag) $@
|
|
cmd_cc_symtypes_c = \
|
|
set -e; \
|
|
$(call cmd_gensymtypes_c,true,$@) >/dev/null; \
|
|
test -s $@ || rm -f $@
|
|
|
|
$(obj)/%.symtypes : $(src)/%.c FORCE
|
|
$(call cmd,cc_symtypes_c)
|
|
|
|
# LLVM assembly
|
|
# Generate .ll files from .c
|
|
quiet_cmd_cc_ll_c = CC $(quiet_modtag) $@
|
|
cmd_cc_ll_c = $(CC) $(c_flags) -emit-llvm -S -o $@ $<
|
|
|
|
$(obj)/%.ll: $(src)/%.c FORCE
|
|
$(call if_changed_dep,cc_ll_c)
|
|
|
|
# C (.c) files
|
|
# The C file is compiled and updated dependency information is generated.
|
|
# (See cmd_cc_o_c + relevant part of rule_cc_o_c)
|
|
|
|
quiet_cmd_cc_o_c = CC $(quiet_modtag) $@
|
|
|
|
ifndef CONFIG_MODVERSIONS
|
|
cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
|
|
|
|
else
|
|
# When module versioning is enabled the following steps are executed:
|
|
# o compile a .tmp_<file>.o from <file>.c
|
|
# o if .tmp_<file>.o doesn't contain a __ksymtab version, i.e. does
|
|
# not export symbols, we just rename .tmp_<file>.o to <file>.o and
|
|
# are done.
|
|
# o otherwise, we calculate symbol versions using the good old
|
|
# genksyms on the preprocessed source and postprocess them in a way
|
|
# that they are usable as a linker script
|
|
# o generate <file>.o from .tmp_<file>.o using the linker to
|
|
# replace the unresolved symbols __crc_exported_symbol with
|
|
# the actual value of the checksum generated by genksyms
|
|
|
|
cmd_cc_o_c = $(CC) $(c_flags) -c -o $(@D)/.tmp_$(@F) $<
|
|
|
|
ifdef CONFIG_LTO_CLANG
|
|
# Generate .o.symversions files for each .o with exported symbols, and link these
|
|
# to the kernel and/or modules at the end.
|
|
cmd_modversions_c = \
|
|
if $(OBJDUMP) -h $(@D)/.tmp_$(@F) >/dev/null 2>/dev/null; then \
|
|
if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then \
|
|
$(call cmd_gensymtypes_c,$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \
|
|
> $(@D)/$(@F).symversions; \
|
|
fi; \
|
|
else \
|
|
if $(LLVM_DIS) -o=- $(@D)/.tmp_$(@F) | grep -q __ksymtab; then \
|
|
$(call cmd_gensymtypes_c,$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \
|
|
> $(@D)/$(@F).symversions; \
|
|
fi; \
|
|
fi; \
|
|
mv -f $(@D)/.tmp_$(@F) $@;
|
|
else
|
|
cmd_modversions_c = \
|
|
if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then \
|
|
$(call cmd_gensymtypes_c,$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \
|
|
> $(@D)/.tmp_$(@F:.o=.ver); \
|
|
\
|
|
$(LD) $(LDFLAGS) -r -o $@ $(@D)/.tmp_$(@F) \
|
|
-T $(@D)/.tmp_$(@F:.o=.ver); \
|
|
rm -f $(@D)/.tmp_$(@F) $(@D)/.tmp_$(@F:.o=.ver); \
|
|
else \
|
|
mv -f $(@D)/.tmp_$(@F) $@; \
|
|
fi;
|
|
endif
|
|
endif
|
|
|
|
ifdef CONFIG_FTRACE_MCOUNT_RECORD
|
|
ifndef CC_USING_RECORD_MCOUNT
|
|
# compiler will not generate __mcount_loc use recordmcount or recordmcount.pl
|
|
ifdef BUILD_C_RECORDMCOUNT
|
|
ifeq ("$(origin RECORDMCOUNT_WARN)", "command line")
|
|
RECORDMCOUNT_FLAGS = -w
|
|
endif
|
|
|
|
ifdef CONFIG_LTO_CLANG
|
|
# With LTO, we postpone running recordmcount until after the LTO link step, so
|
|
# let's export the parameters for the link script.
|
|
export RECORDMCOUNT_FLAGS
|
|
else
|
|
# Due to recursion, we must skip empty.o.
|
|
# The empty.o file is created in the make process in order to determine
|
|
# the target endianness and word size. It is made before all other C
|
|
# files, including recordmcount.
|
|
sub_cmd_record_mcount = \
|
|
if [ $(@) != "scripts/mod/empty.o" ]; then \
|
|
$(objtree)/scripts/recordmcount $(RECORDMCOUNT_FLAGS) "$(@)"; \
|
|
fi;
|
|
endif
|
|
|
|
recordmcount_source := $(srctree)/scripts/recordmcount.c \
|
|
$(srctree)/scripts/recordmcount.h
|
|
else # !BUILD_C_RECORDMCOUNT
|
|
sub_cmd_record_mcount = set -e ; perl $(srctree)/scripts/recordmcount.pl "$(ARCH)" \
|
|
"$(if $(CONFIG_CPU_BIG_ENDIAN),big,little)" \
|
|
"$(if $(CONFIG_64BIT),64,32)" \
|
|
"$(OBJDUMP)" "$(OBJCOPY)" "$(CC) $(KBUILD_CFLAGS)" \
|
|
"$(LD)" "$(NM)" "$(RM)" "$(MV)" \
|
|
"$(if $(part-of-module),1,0)" "$(@)";
|
|
|
|
recordmcount_source := $(srctree)/scripts/recordmcount.pl
|
|
endif # BUILD_C_RECORDMCOUNT
|
|
|
|
ifndef CONFIG_LTO_CLANG
|
|
cmd_record_mcount = \
|
|
if [ "$(findstring $(CC_FLAGS_FTRACE),$(_c_flags))" = \
|
|
"$(CC_FLAGS_FTRACE)" ]; then \
|
|
$(sub_cmd_record_mcount) \
|
|
fi;
|
|
endif # CC_USING_RECORD_MCOUNT
|
|
endif
|
|
endif # CONFIG_FTRACE_MCOUNT_RECORD
|
|
|
|
ifdef CONFIG_STACK_VALIDATION
|
|
ifneq ($(SKIP_STACK_VALIDATION),1)
|
|
|
|
__objtool_obj := $(objtree)/tools/objtool/objtool
|
|
|
|
objtool_args = check
|
|
ifndef CONFIG_FRAME_POINTER
|
|
objtool_args += --no-fp
|
|
endif
|
|
ifdef CONFIG_GCOV_KERNEL
|
|
objtool_args += --no-unreachable
|
|
endif
|
|
|
|
# 'OBJECT_FILES_NON_STANDARD := y': skip objtool checking for a directory
|
|
# 'OBJECT_FILES_NON_STANDARD_foo.o := 'y': skip objtool checking for a file
|
|
# 'OBJECT_FILES_NON_STANDARD_foo.o := 'n': override directory skip for a file
|
|
cmd_objtool = $(if $(patsubst y%,, \
|
|
$(OBJECT_FILES_NON_STANDARD_$(basetarget).o)$(OBJECT_FILES_NON_STANDARD)n), \
|
|
$(__objtool_obj) $(objtool_args) "$(@)";)
|
|
objtool_obj = $(if $(patsubst y%,, \
|
|
$(OBJECT_FILES_NON_STANDARD_$(basetarget).o)$(OBJECT_FILES_NON_STANDARD)n), \
|
|
$(__objtool_obj))
|
|
|
|
endif # SKIP_STACK_VALIDATION
|
|
endif # CONFIG_STACK_VALIDATION
|
|
|
|
define rule_cc_o_c
|
|
$(call echo-cmd,checksrc) $(cmd_checksrc) \
|
|
$(call cmd_and_fixdep,cc_o_c) \
|
|
$(cmd_modversions_c) \
|
|
$(cmd_objtool) \
|
|
$(call echo-cmd,record_mcount) $(cmd_record_mcount)
|
|
endef
|
|
|
|
define rule_as_o_S
|
|
$(call cmd_and_fixdep,as_o_S) \
|
|
$(cmd_modversions_S) \
|
|
$(cmd_objtool)
|
|
endef
|
|
|
|
# List module undefined symbols (or empty line if not enabled)
|
|
ifdef CONFIG_TRIM_UNUSED_KSYMS
|
|
cmd_undef_syms = $(NM) $@ | sed -n 's/^ \+U //p' | xargs echo
|
|
else
|
|
cmd_undef_syms = echo
|
|
endif
|
|
|
|
# Built-in and composite module parts
|
|
$(obj)/%.o: $(src)/%.c $(recordmcount_source) $(objtool_obj) FORCE
|
|
$(call cmd,force_checksrc)
|
|
$(call if_changed_rule,cc_o_c)
|
|
|
|
# Single-part modules are special since we need to mark them in $(MODVERDIR)
|
|
|
|
$(single-used-m): $(obj)/%.o: $(src)/%.c $(recordmcount_source) $(objtool_obj) FORCE
|
|
$(call cmd,force_checksrc)
|
|
$(call if_changed_rule,cc_o_c)
|
|
@{ echo $(@:.o=.ko); echo $@; \
|
|
$(cmd_undef_syms); } > $(MODVERDIR)/$(@F:.o=.mod)
|
|
|
|
quiet_cmd_cc_lst_c = MKLST $@
|
|
cmd_cc_lst_c = $(CC) $(c_flags) -g -c -o $*.o $< && \
|
|
$(CONFIG_SHELL) $(srctree)/scripts/makelst $*.o \
|
|
System.map $(OBJDUMP) > $@
|
|
|
|
$(obj)/%.lst: $(src)/%.c FORCE
|
|
$(call if_changed_dep,cc_lst_c)
|
|
|
|
# Compile assembler sources (.S)
|
|
# ---------------------------------------------------------------------------
|
|
|
|
modkern_aflags := $(KBUILD_AFLAGS_KERNEL) $(AFLAGS_KERNEL)
|
|
|
|
$(real-objs-m) : modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE)
|
|
$(real-objs-m:.o=.s): modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE)
|
|
|
|
# .S file exports must have their C prototypes defined in asm/asm-prototypes.h
|
|
# or a file that it includes, in order to get versioned symbols. We build a
|
|
# dummy C file that includes asm-prototypes and the EXPORT_SYMBOL lines from
|
|
# the .S file (with trailing ';'), and run genksyms on that, to extract vers.
|
|
#
|
|
# This is convoluted. The .S file must first be preprocessed to run guards and
|
|
# expand names, then the resulting exports must be constructed into plain
|
|
# EXPORT_SYMBOL(symbol); to build our dummy C file, and that gets preprocessed
|
|
# to make the genksyms input.
|
|
#
|
|
# These mirror gensymtypes_c and co above, keep them in synch.
|
|
cmd_gensymtypes_S = \
|
|
(echo "\#include <linux/kernel.h>" ; \
|
|
echo "\#include <asm/asm-prototypes.h>" ; \
|
|
$(CPP) $(a_flags) $< | \
|
|
grep "\<___EXPORT_SYMBOL\>" | \
|
|
sed 's/.*___EXPORT_SYMBOL[[:space:]]*\([a-zA-Z0-9_]*\)[[:space:]]*,.*/EXPORT_SYMBOL(\1);/' ) | \
|
|
$(CPP) -D__GENKSYMS__ $(c_flags) -xc - | \
|
|
$(GENKSYMS) $(if $(1), -T $(2)) \
|
|
$(patsubst y,-s _,$(CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX)) \
|
|
$(if $(KBUILD_PRESERVE),-p) \
|
|
-r $(firstword $(wildcard $(2:.symtypes=.symref) /dev/null))
|
|
|
|
quiet_cmd_cc_symtypes_S = SYM $(quiet_modtag) $@
|
|
cmd_cc_symtypes_S = \
|
|
set -e; \
|
|
$(call cmd_gensymtypes_S,true,$@) >/dev/null; \
|
|
test -s $@ || rm -f $@
|
|
|
|
$(obj)/%.symtypes : $(src)/%.S FORCE
|
|
$(call cmd,cc_symtypes_S)
|
|
|
|
|
|
quiet_cmd_cpp_s_S = CPP $(quiet_modtag) $@
|
|
cmd_cpp_s_S = $(CPP) $(a_flags) -o $@ $<
|
|
|
|
$(obj)/%.s: $(src)/%.S FORCE
|
|
$(call if_changed_dep,cpp_s_S)
|
|
|
|
quiet_cmd_as_o_S = AS $(quiet_modtag) $@
|
|
|
|
ifndef CONFIG_MODVERSIONS
|
|
cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $<
|
|
|
|
else
|
|
|
|
ASM_PROTOTYPES := $(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/asm-prototypes.h)
|
|
|
|
ifeq ($(ASM_PROTOTYPES),)
|
|
cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $<
|
|
|
|
else
|
|
|
|
# versioning matches the C process described above, with difference that
|
|
# we parse asm-prototypes.h C header to get function definitions.
|
|
|
|
cmd_as_o_S = $(CC) $(a_flags) -c -o $(@D)/.tmp_$(@F) $<
|
|
|
|
cmd_modversions_S = \
|
|
if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then \
|
|
$(call cmd_gensymtypes_S,$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \
|
|
> $(@D)/.tmp_$(@F:.o=.ver); \
|
|
\
|
|
$(LD) $(LDFLAGS) -r -o $@ $(@D)/.tmp_$(@F) \
|
|
-T $(@D)/.tmp_$(@F:.o=.ver); \
|
|
rm -f $(@D)/.tmp_$(@F) $(@D)/.tmp_$(@F:.o=.ver); \
|
|
else \
|
|
mv -f $(@D)/.tmp_$(@F) $@; \
|
|
fi;
|
|
endif
|
|
endif
|
|
|
|
$(obj)/%.o: $(src)/%.S $(objtool_obj) FORCE
|
|
$(call if_changed_rule,as_o_S)
|
|
|
|
targets += $(real-objs-y) $(real-objs-m) $(lib-y)
|
|
targets += $(extra-y) $(MAKECMDGOALS) $(always)
|
|
|
|
# Linker scripts preprocessor (.lds.S -> .lds)
|
|
# ---------------------------------------------------------------------------
|
|
quiet_cmd_cpp_lds_S = LDS $@
|
|
cmd_cpp_lds_S = $(CPP) $(cpp_flags) -P -C -U$(ARCH) \
|
|
-D__ASSEMBLY__ -DLINKER_SCRIPT -o $@ $<
|
|
|
|
$(obj)/%.lds: $(src)/%.lds.S FORCE
|
|
$(call if_changed_dep,cpp_lds_S)
|
|
|
|
# ASN.1 grammar
|
|
# ---------------------------------------------------------------------------
|
|
quiet_cmd_asn1_compiler = ASN.1 $@
|
|
cmd_asn1_compiler = $(objtree)/scripts/asn1_compiler $< \
|
|
$(subst .h,.c,$@) $(subst .c,.h,$@)
|
|
|
|
.PRECIOUS: $(objtree)/$(obj)/%-asn1.c $(objtree)/$(obj)/%-asn1.h
|
|
|
|
$(obj)/%-asn1.c $(obj)/%-asn1.h: $(src)/%.asn1 $(objtree)/scripts/asn1_compiler
|
|
$(call cmd,asn1_compiler)
|
|
|
|
# Build the compiled-in targets
|
|
# ---------------------------------------------------------------------------
|
|
|
|
# To build objects in subdirs, we need to descend into the directories
|
|
$(sort $(subdir-obj-y)): $(subdir-ym) ;
|
|
|
|
#
|
|
# Rule to compile a set of .o files into one .o file
|
|
#
|
|
ifdef builtin-target
|
|
|
|
ifdef CONFIG_LTO_CLANG
|
|
ifdef CONFIG_MODVERSIONS
|
|
# combine symversions for later processing
|
|
update_lto_symversions = \
|
|
rm -f $@.symversions; \
|
|
for i in $(filter-out FORCE,$^); do \
|
|
if [ -f $$i.symversions ]; then \
|
|
cat $$i.symversions \
|
|
>> $@.symversions; \
|
|
fi; \
|
|
done;
|
|
endif
|
|
# rebuild the symbol table with llvm-ar to include IR files
|
|
update_lto_symtable = ; \
|
|
mv -f $@ $@.tmp; \
|
|
$(LLVM_AR) rcsT$(KBUILD_ARFLAGS) $@ \
|
|
$$($(AR) t $@.tmp); \
|
|
rm -f $@.tmp
|
|
endif
|
|
|
|
ifdef CONFIG_THIN_ARCHIVES
|
|
cmd_make_builtin = $(update_lto_symversions) \
|
|
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
|
|
cmd_make_empty_builtin = rm -f $@; $(AR) rcs$(KBUILD_ARFLAGS)
|
|
quiet_cmd_link_o_target = LD $@
|
|
endif
|
|
|
|
# If the list of objects to link is empty, just create an empty built-in.o
|
|
cmd_link_o_target = $(if $(strip $(obj-y)),\
|
|
$(cmd_make_builtin) $@ $(filter $(obj-y), $^) \
|
|
$(cmd_secanalysis),\
|
|
$(cmd_make_empty_builtin) $@)
|
|
|
|
$(builtin-target): $(obj-y) FORCE
|
|
$(call if_changed,link_o_target)
|
|
|
|
targets += $(builtin-target)
|
|
endif # builtin-target
|
|
|
|
#
|
|
# Rule to create modules.order file
|
|
#
|
|
# Create commands to either record .ko file or cat modules.order from
|
|
# a subdirectory
|
|
modorder-cmds = \
|
|
$(foreach m, $(modorder), \
|
|
$(if $(filter %/modules.order, $m), \
|
|
cat $m;, echo kernel/$m;))
|
|
|
|
$(modorder-target): $(subdir-ym) FORCE
|
|
$(Q)(cat /dev/null; $(modorder-cmds)) > $@
|
|
|
|
#
|
|
# Rule to compile a set of .o files into one .a file
|
|
#
|
|
ifdef lib-target
|
|
quiet_cmd_link_l_target = AR $@
|
|
|
|
ifdef CONFIG_THIN_ARCHIVES
|
|
cmd_link_l_target = \
|
|
$(update_lto_symversions) \
|
|
rm -f $@; \
|
|
$(AR) rcsTP$(KBUILD_ARFLAGS) $@ $(lib-y) \
|
|
$(update_lto_symtable)
|
|
else
|
|
cmd_link_l_target = rm -f $@; $(AR) rcs$(KBUILD_ARFLAGS) $@ $(lib-y)
|
|
endif
|
|
|
|
$(lib-target): $(lib-y) FORCE
|
|
$(call if_changed,link_l_target)
|
|
|
|
targets += $(lib-target)
|
|
|
|
dummy-object = $(obj)/.lib_exports.o
|
|
ksyms-lds = $(dot-target).lds
|
|
ifdef CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX
|
|
ref_prefix = EXTERN(_
|
|
else
|
|
ref_prefix = EXTERN(
|
|
endif
|
|
|
|
filter_export_list = sed -ne '/___ksymtab/s/.*+\([^ "]*\).*/$(ref_prefix)\1)/p'
|
|
link_export_list = rm -f $(dummy-object);\
|
|
echo | $(CC) $(a_flags) -c -o $(dummy-object) -x assembler -;\
|
|
$(LD) $(ld_flags) -r -o $@ -T $(ksyms-lds) $(dummy-object);\
|
|
rm $(dummy-object) $(ksyms-lds)
|
|
|
|
quiet_cmd_export_list = EXPORTS $@
|
|
|
|
ifdef CONFIG_LTO_CLANG
|
|
# objdump doesn't understand IR files and llvm-dis doesn't support archives,
|
|
# so we'll walk through each file in the archive separately
|
|
cmd_export_list = \
|
|
rm -f $(ksyms-lds); \
|
|
for o in $$($(AR) t $<); do \
|
|
if $(OBJDUMP) -h $$o >/dev/null 2>/dev/null; then \
|
|
$(OBJDUMP) -h $$o | \
|
|
$(filter_export_list) \
|
|
>>$(ksyms-lds); \
|
|
else \
|
|
$(LLVM_DIS) -o=- $$o | \
|
|
$(filter_export_list) \
|
|
>>$(ksyms-lds); \
|
|
fi; \
|
|
done; \
|
|
$(link_export_list)
|
|
else
|
|
cmd_export_list = $(OBJDUMP) -h $< | $(filter_export_list) >$(ksyms-lds); \
|
|
$(link_export_list)
|
|
endif
|
|
|
|
$(obj)/lib-ksyms.o: $(lib-target) FORCE
|
|
$(call if_changed,export_list)
|
|
|
|
targets += $(obj)/lib-ksyms.o
|
|
|
|
endif
|
|
|
|
#
|
|
# Rule to link composite objects
|
|
#
|
|
# Composite objects are specified in kbuild makefile as follows:
|
|
# <composite-object>-objs := <list of .o files>
|
|
# or
|
|
# <composite-object>-y := <list of .o files>
|
|
# or
|
|
# <composite-object>-m := <list of .o files>
|
|
# The -m syntax only works if <composite object> is a module
|
|
link_multi_deps = \
|
|
$(filter $(addprefix $(obj)/, \
|
|
$($(subst $(obj)/,,$(@:.o=-objs))) \
|
|
$($(subst $(obj)/,,$(@:.o=-y))) \
|
|
$($(subst $(obj)/,,$(@:.o=-m)))), $^)
|
|
|
|
cmd_link_multi-link = $(LD) $(ld_flags) -r -o $@ $(link_multi_deps) $(cmd_secanalysis)
|
|
|
|
ifdef CONFIG_THIN_ARCHIVES
|
|
quiet_cmd_link_multi-y = AR $@
|
|
cmd_link_multi-y = $(update_lto_symversions) \
|
|
rm -f $@; $(AR) rcSTP$(KBUILD_ARFLAGS) $@ $(link_multi_deps) \
|
|
$(update_lto_symtable)
|
|
else
|
|
quiet_cmd_link_multi-y = LD $@
|
|
cmd_link_multi-y = $(cmd_link_multi-link)
|
|
endif
|
|
|
|
quiet_cmd_link_multi-m = LD [M] $@
|
|
|
|
ifdef CONFIG_LTO_CLANG
|
|
# don't compile IR until needed
|
|
cmd_link_multi-m = $(cmd_link_multi-y)
|
|
else
|
|
cmd_link_multi-m = $(cmd_link_multi-link)
|
|
endif
|
|
|
|
$(multi-used-y): FORCE
|
|
$(call if_changed,link_multi-y)
|
|
|
|
$(multi-used-m): FORCE
|
|
$(call if_changed,link_multi-m)
|
|
@{ echo $(@:.o=.ko); echo $(link_multi_deps); \
|
|
$(cmd_undef_syms); } > $(MODVERDIR)/$(@F:.o=.mod)
|
|
|
|
$(call multi_depend, $(multi-used-y), .o, -objs -y)
|
|
$(call multi_depend, $(multi-used-m), .o, -objs -y -m)
|
|
|
|
targets += $(multi-used-y) $(multi-used-m)
|
|
|
|
|
|
# Descending
|
|
# ---------------------------------------------------------------------------
|
|
|
|
PHONY += $(subdir-ym)
|
|
$(subdir-ym):
|
|
$(Q)$(MAKE) $(build)=$@
|
|
|
|
# Add FORCE to the prequisites of a target to force it to be always rebuilt.
|
|
# ---------------------------------------------------------------------------
|
|
|
|
PHONY += FORCE
|
|
|
|
FORCE:
|
|
|
|
# Read all saved command lines and dependencies for the $(targets) we
|
|
# may be building above, using $(if_changed{,_dep}). As an
|
|
# optimization, we don't need to read them if the target does not
|
|
# exist, we will rebuild anyway in that case.
|
|
|
|
targets := $(wildcard $(sort $(targets)))
|
|
cmd_files := $(wildcard $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
|
|
|
|
ifneq ($(cmd_files),)
|
|
include $(cmd_files)
|
|
endif
|
|
|
|
# Declare the contents of the .PHONY variable as phony. We keep that
|
|
# information in a variable se we can use it in if_changed and friends.
|
|
|
|
.PHONY: $(PHONY)
|