--- zzzz-none-000/linux-4.4.271/scripts/Makefile.build 2021-06-03 06:22:09.000000000 +0000 +++ dakota-7530ac-750/linux-4.4.271/scripts/Makefile.build 2023-01-11 09:25:44.000000000 +0000 @@ -60,7 +60,7 @@ endif # Do not include host rules unless needed -ifneq ($(hostprogs-y)$(hostprogs-m),) +ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),) include scripts/Makefile.host endif @@ -189,6 +189,85 @@ quiet_cmd_cc_o_c = CC $(quiet_modtag) $@ +ifdef CONFIG_DEBUG_MEM_USAGE +MLDFLAGS_WRAP := --wrap=__kmalloc \ + --wrap=kmalloc \ + --wrap=__kmalloc_node \ + --wrap=kmalloc_node \ + --wrap=kzalloc \ + --wrap=kzalloc_node \ + --wrap=kmalloc_array \ + --wrap=kmalloc_order \ + --wrap=kmalloc_order_trace \ + --wrap=kcalloc \ + --wrap=krealloc \ + --wrap=kmemdup \ + --wrap=memdup_user \ + --wrap=kfree \ + --wrap=kzfree \ + --wrap=__vmalloc \ + --wrap=vmalloc \ + --wrap=vzalloc \ + --wrap=vmalloc_user \ + --wrap=vmalloc_32 \ + --wrap=vmalloc_node \ + --wrap=vzalloc_node \ + --wrap=vfree \ + --wrap=kvfree \ + --wrap=alloc_pages \ + --wrap=alloc_pages_node \ + --wrap=__alloc_pages_nodemask \ + --wrap=__get_free_pages \ + --wrap=get_zeroed_page \ + --wrap=free_pages \ + --wrap=__free_pages \ + --wrap=dma_alloc_coherent \ + --wrap=dma_free_coherent \ + --wrap=dma_pool_alloc \ + --wrap=dma_pool_free \ + --wrap=kmem_cache_alloc \ + --wrap=kmem_cache_alloc_node \ + --wrap=kmem_cache_alloc_trace \ + --wrap=kmem_cache_alloc_node_trace \ + --wrap=kmem_cache_free \ + --wrap=mempool_alloc \ + --wrap=mempool_free \ + --wrap=devm_kmalloc \ + --wrap=devm_kmalloc_array \ + --wrap=devm_kzalloc \ + --wrap=devm_kcalloc \ + --wrap=devm_kmemdup \ + --wrap=devm_kfree \ + --wrap=devm_get_free_pages \ + --wrap=devm_free_pages + +MNEW_LD_FLAGS := $(MLDFLAGS_WRAP) + +cmd_export_mnew_ldflags = \ + $(if $(findstring kernel/, $@), $(filter-out $(MNEW_LD_FLAGS), $(MLDFLAGS_WRAP))) \ + $(if $(findstring arch/, $@), $(filter-out $(MNEW_LD_FLAGS), $(MLDFLAGS_WRAP))) \ + $(if $(findstring init/, $@), $(filter-out $(MNEW_LD_FLAGS), $(MLDFLAGS_WRAP))) \ + $(if $(findstring mm/, $@), $(filter-out $(MNEW_LD_FLAGS), $(MLDFLAGS_WRAP))) \ + $(if $(findstring block/, $@), $(filter-out $(MNEW_LD_FLAGS), $(MLDFLAGS_WRAP))) \ + $(if $(findstring kernel/, $@), $(filter-out $(MNEW_LD_FLAGS), $(MLDFLAGS_WRAP))) \ + $(if $(findstring block/, $@), $(filter-out $(MNEW_LD_FLAGS), $(MLDFLAGS_WRAP))) \ + $(if $(findstring usr/, $@), $(filter-out $(MNEW_LD_FLAGS), $(MLDFLAGS_WRAP))) \ + $(if $(findstring security/, $@), $(filter-out $(MNEW_LD_FLAGS), $(MLDFLAGS_WRAP))) \ + $(if $(findstring sound/, $@), $(filter-out $(MNEW_LD_FLAGS), $(MLDFLAGS_WRAP))) \ + $(if $(findstring crypto/, $@), $(filter-out $(MNEW_LD_FLAGS), $(MLDFLAGS_WRAP))) \ + $(if $(findstring firmware/, $@), $(filter-out $(MNEW_LD_FLAGS), $(MLDFLAGS_WRAP))) \ + $(if $(findstring samples/, $@), $(filter-out $(MNEW_LD_FLAGS), $(MLDFLAGS_WRAP))) \ + $(if $(findstring tools/, $@), $(filter-out $(MNEW_LD_FLAGS), $(MLDFLAGS_WRAP))) \ + $(if $(findstring lib/, $@), $(filter-out $(MNEW_LD_FLAGS), $(MLDFLAGS_WRAP))) \ + $(if $(findstring fs/, $@), $(filter-out $(MNEW_LD_FLAGS), $(MLDFLAGS_WRAP))) \ + $(if $(findstring ipc/, $@), $(filter-out $(MNEW_LD_FLAGS), $(MLDFLAGS_WRAP))) \ + $(if $(findstring drivers/, $@), $(filter-out $(MNEW_LD_FLAGS), $(MLDFLAGS_WRAP))) \ + $(if $(findstring drivers/net/, $@), $(MLDFLAGS_WRAP)) \ + $(if $(findstring net/, $@), $(MLDFLAGS_WRAP)) \ + $(if $(findstring /linux-ipq_, $@), $(MLDFLAGS_WRAP)) +endif + + ifndef CONFIG_MODVERSIONS cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< @@ -383,7 +462,7 @@ # Linker scripts preprocessor (.lds.S -> .lds) # --------------------------------------------------------------------------- quiet_cmd_cpp_lds_S = LDS $@ - cmd_cpp_lds_S = $(CPP) $(cpp_flags) -P -C -U$(ARCH) \ + cmd_cpp_lds_S = $(CPP) $(EXTRA_LDSFLAGS) $(cpp_flags) -P -C -U$(ARCH) \ -D__ASSEMBLY__ -DLINKER_SCRIPT -o $@ $< $(obj)/%.lds: $(src)/%.lds.S FORCE @@ -409,14 +488,101 @@ # # Rule to compile a set of .o files into one .o file # + +ifdef CONFIG_DEBUG_MEM_USAGE +LDFLAGS_WRAP := --wrap=__kmalloc \ + --wrap=kmalloc \ + --wrap=kzalloc \ + --wrap=kzalloc_node \ + --wrap=kmalloc_array \ + --wrap=__kmalloc_node \ + --wrap=kmalloc_node \ + --wrap=kmalloc_order \ + --wrap=kmalloc_order_trace \ + --wrap=kcalloc \ + --wrap=krealloc \ + --wrap=kmemdup \ + --wrap=memdup_user \ + --wrap=kfree \ + --wrap=kzfree \ + --wrap=__vmalloc \ + --wrap=vmalloc \ + --wrap=vzalloc \ + --wrap=vmalloc_user \ + --wrap=vmalloc_32 \ + --wrap=vmalloc_node \ + --wrap=vzalloc_node \ + --wrap=vfree \ + --wrap=kvfree \ + --wrap=alloc_pages \ + --wrap=alloc_pages_node \ + --wrap=__alloc_pages_nodemask \ + --wrap=__get_free_pages \ + --wrap=get_zeroed_page \ + --wrap=free_pages \ + --wrap=__free_pages \ + --wrap=dma_alloc_coherent \ + --wrap=dma_free_coherent \ + --wrap=dma_pool_alloc \ + --wrap=dma_pool_free \ + --wrap=kmem_cache_alloc \ + --wrap=kmem_cache_alloc_node \ + --wrap=kmem_cache_alloc_trace \ + --wrap=kmem_cache_alloc_node_trace \ + --wrap=kmem_cache_free \ + --wrap=mempool_alloc \ + --wrap=mempool_free \ + --wrap=devm_kmalloc \ + --wrap=devm_kmalloc_array \ + --wrap=devm_kzalloc \ + --wrap=devm_kcalloc \ + --wrap=devm_kmemdup \ + --wrap=devm_kfree \ + --wrap=devm_get_free_pages \ + --wrap=devm_free_pages + +NEW_LD_FLAGS := $(LDFLAGS_WRAP) + +cmd_export_new_ldflags = \ + $(if $(findstring kernel/, $@), $(filter-out $(NEW_LD_FLAGS), $(LDFLAGS_WRAP))) \ + $(if $(findstring arch/, $@), $(filter-out $(NEW_LD_FLAGS), $(LDFLAGS_WRAP))) \ + $(if $(findstring init/, $@), $(filter-out $(NEW_LD_FLAGS), $(LDFLAGS_WRAP))) \ + $(if $(findstring mm/, $@), $(filter-out $(NEW_LD_FLAGS), $(LDFLAGS_WRAP))) \ + $(if $(findstring block/, $@), $(filter-out $(NEW_LD_FLAGS), $(LDFLAGS_WRAP))) \ + $(if $(findstring kernel/, $@), $(filter-out $(NEW_LD_FLAGS), $(LDFLAGS_WRAP))) \ + $(if $(findstring block/, $@), $(filter-out $(NEW_LD_FLAGS), $(LDFLAGS_WRAP))) \ + $(if $(findstring usr/, $@), $(filter-out $(NEW_LD_FLAGS), $(LDFLAGS_WRAP))) \ + $(if $(findstring security/, $@), $(filter-out $(NEW_LD_FLAGS), $(LDFLAGS_WRAP))) \ + $(if $(findstring sound/, $@), $(filter-out $(NEW_LD_FLAGS), $(LDFLAGS_WRAP))) \ + $(if $(findstring crypto/, $@), $(filter-out $(NEW_LD_FLAGS), $(LDFLAGS_WRAP))) \ + $(if $(findstring firmware/, $@), $(filter-out $(NEW_LD_FLAGS), $(LDFLAGS_WRAP))) \ + $(if $(findstring samples/, $@), $(filter-out $(NEW_LD_FLAGS), $(LDFLAGS_WRAP))) \ + $(if $(findstring tools/, $@), $(filter-out $(NEW_LD_FLAGS), $(LDFLAGS_WRAP))) \ + $(if $(findstring lib/, $@), $(filter-out $(NEW_LD_FLAGS), $(LDFLAGS_WRAP))) \ + $(if $(findstring fs/, $@), $(filter-out $(NEW_LD_FLAGS), $(LDFLAGS_WRAP))) \ + $(if $(findstring ipc/, $@), $(filter-out $(NEW_LD_FLAGS), $(LDFLAGS_WRAP))) \ + $(if $(findstring drivers/, $@), $(filter-out $(NEW_LD_FLAGS), $(LDFLAGS_WRAP))) \ + $(if $(findstring drivers/net/, $@), $(LDFLAGS_WRAP)) \ + $(if $(findstring net/, $@), $(LDFLAGS_WRAP)) + +endif + ifdef builtin-target quiet_cmd_link_o_target = LD $@ # If the list of objects to link is empty, just create an empty built-in.o +ifdef CONFIG_DEBUG_MEM_USAGE +cmd_link_o_target = $(if $(strip $(obj-y)),\ + $(LD) $(ld_flags) $(cmd_export_new_ldflags) -r -o $@ $(filter $(obj-y), $^) \ + $(cmd_secanalysis),\ + rm -f $@; $(AR) rcs$(KBUILD_ARFLAGS) $@) +else cmd_link_o_target = $(if $(strip $(obj-y)),\ $(LD) $(ld_flags) -r -o $@ $(filter $(obj-y), $^) \ $(cmd_secanalysis),\ rm -f $@; $(AR) rcs$(KBUILD_ARFLAGS) $@) +endif + $(builtin-target): $(obj-y) FORCE $(call if_changed,link_o_target) @@ -462,7 +628,11 @@ $($(subst $(obj)/,,$(@:.o=-y)))), $^) quiet_cmd_link_multi-y = LD $@ +ifdef CONFIG_DEBUG_MEM_USAGE +cmd_link_multi-y = $(LD) $(ld_flags) $(cmd_export_mnew_ldflags) -r -o $@ $(link_multi_deps) $(cmd_secanalysis) +else cmd_link_multi-y = $(LD) $(ld_flags) -r -o $@ $(link_multi_deps) $(cmd_secanalysis) +endif quiet_cmd_link_multi-m = LD [M] $@ cmd_link_multi-m = $(cmd_link_multi-y)