From fcdc459ce4c7eb84549e45cf06a3a44f90aa3cf9 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 16 Aug 2024 23:55:51 +0900 Subject: [PATCH] fixup modules.builtin.ranges Signed-off-by: Masahiro Yamada --- lib/Kconfig.debug | 2 +- scripts/Makefile.vmlinux | 12 +++++++----- scripts/generate_builtin_ranges.awk | 25 ++++++++----------------- 3 files changed, 16 insertions(+), 23 deletions(-) diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index dcdf14ffe031..f087dc3da321 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -575,7 +575,7 @@ config BUILTIN_MODULE_RANGES bool "Generate address range information for builtin modules" depends on !LTO_CLANG_FULL depends on !LTO_CLANG_THIN - select VMLINUX_MAP + depends on VMLINUX_MAP help When modules are built into the kernel, there will be no module name associated with its symbols in /proc/kallsyms. Tracers may want to diff --git a/scripts/Makefile.vmlinux b/scripts/Makefile.vmlinux index 7e21162e9de1..7e8b703799c8 100644 --- a/scripts/Makefile.vmlinux +++ b/scripts/Makefile.vmlinux @@ -39,14 +39,16 @@ ifdef CONFIG_BUILTIN_MODULE_RANGES __default: modules.builtin.ranges quiet_cmd_modules_builtin_ranges = GEN $@ - cmd_modules_builtin_ranges = \ - $(srctree)/scripts/generate_builtin_ranges.awk $(real-prereqs) > $@ - -vmlinux.map: vmlinux + cmd_modules_builtin_ranges = $(real-prereqs) > $@ targets += modules.builtin.ranges -modules.builtin.ranges: modules.builtin vmlinux.map vmlinux.o.map FORCE +modules.builtin.ranges: $(srctree)/scripts/generate_builtin_ranges.awk \ + modules.builtin vmlinux.map vmlinux.o.map FORCE $(call if_changed,modules_builtin_ranges) + +vmlinux.map: vmlinux + @: + endif # Add FORCE to the prequisites of a target to force it to be always rebuilt. diff --git a/scripts/generate_builtin_ranges.awk b/scripts/generate_builtin_ranges.awk index 9b647781d5fe..865cb7ac4970 100755 --- a/scripts/generate_builtin_ranges.awk +++ b/scripts/generate_builtin_ranges.awk @@ -12,7 +12,7 @@ # If we have seen this object before, return information from the cache. # Otherwise, retrieve it from the corresponding .cmd file. # -function get_module_info(fn, mod, obj, mfn, s) { +function get_module_info(fn, mod, obj, s) { if (fn in omod) return omod[fn]; @@ -21,16 +21,11 @@ function get_module_info(fn, mod, obj, mfn, s) { obj = fn; mod = ""; - mfn = ""; fn = substr(fn, 1, RSTART) "." substr(fn, RSTART + 1) ".cmd"; if (getline s 0) { - mfn = substr(s, RSTART + 16, RLENGTH - 16); - gsub(/['"]/, "", mfn); - - mod = mfn; - gsub(/([^/ ]*\/)+/, "", mod); - gsub(/-/, "_", mod); + mod = substr(s, RSTART + 16, RLENGTH - 16); + gsub(/['"]/, "", mod); } } close(fn); @@ -42,10 +37,11 @@ function get_module_info(fn, mod, obj, mfn, s) { if (mod !~ / /) { if (!(mod in mods)) mod = ""; - if (mods[mod] != mfn) - mod = ""; } + gsub(/([^/ ]*\/)+/, "", mod); + gsub(/-/, "_", mod); + # At this point, mod is a single (valid) module name, or a list of # module names (that do not need validation). omod[obj] = mod; @@ -76,18 +72,13 @@ function update_entry(osect, mod, soff, eoff, sect, idx) { # # Lines will be like: # kernel/crypto/lzo-rle.ko -# and we derive the built-in module name from this as "lzo_rle" and associate -# it with object name "crypto/lzo-rle". +# and we record the object name "crypto/lzo-rle". # ARGIND == 1 { sub(/kernel\//, ""); # strip off "kernel/" prefix sub(/\.ko$/, ""); # strip off .ko suffix - mod = $1; - sub(/([^/]*\/)+/, "", mod); # mod = basename($1) - gsub(/-/, "_", mod); # Convert - to _ - - mods[mod] = $1; + mods[$1] = 1; next; } -- 2.43.0