Lines Matching +full:sub +full:- +full:modules

1 #!/usr/bin/gawk -f
2 # SPDX-License-Identifier: GPL-2.0
3 # generate_builtin_ranges.awk: Generate address range data for builtin modules
6 # Usage: generate_builtin_ranges.awk modules.builtin vmlinux.map \
7 # vmlinux.o.map > modules.builtin.ranges
27 mod = substr(s, RSTART + 16, RLENGTH - 16);
30 mod = substr(s, RSTART + 13, RLENGTH - 13);
44 gsub(/-/, "_", mod);
65 entries[idx] = sprintf("%s %08x-%08x %s", sect, soff, eoff, mod);
69 # (1) Build a lookup map of built-in module names.
71 # The first file argument is used as input (modules.builtin).
74 # kernel/crypto/lzo-rle.ko
75 # and we record the object name "crypto/lzo-rle".
78 sub(/kernel\//, ""); # strip off "kernel/" prefix
79 sub(/\.ko$/, ""); # strip off .ko suffix
96 # We collect the start address of any sub-section (section included in the top
99 # section is to be obtained from vmlinux.o.map. The offset of the sub-section
120 # ->
123 ARGIND == 2 && map_is_lld && NF == 5 && /[0-9] [^ ]+$/ {
130 # ->
140 # ->
145 sub(/ vmlinux\.a\(/, " ");
146 sub(/:\(/, " ");
156 # ->
159 ARGIND == 2 && map_is_lld && sect && !anchor && NF == 5 && $5 ~ /^[_A-Za-z][_A-Za-z0-9]*$/ {
165 ARGIND == 2 && map_is_lld && /^[0-9a-f]{16} / {
195 # Beginning a new section - done with the previous one (if any).
201 # Process a loadable section (we only care about .-sections).
204 # We also record the raw (non-stripped) address of the section because it can
219 # Sections with a 0-address can be ignored as well.
226 sub(addr_prefix, "0x", base);
251 anchor = sprintf("%s %08x-%08x = %s", sect, 0, 0, $2);
265 sub(addr_prefix, "0x", addr);
266 addr = strtonum(addr) - base;
267 anchor = sprintf("%s %08x-%08x = %s", sect, addr, addr, $2);
293 sub(addr_prefix, "0x", addr);
295 sect_addend[$1] = addr - sect_base[$1];
299 printf "[%s] ADDEND %016x - %016x = %016x\n", $1, addr, base, sect_addend[$1] >"/dev/stderr";
307 # (3) Collect offset ranges (relative to the section base address) for built-in
308 # modules.
325 # - If the current object belongs to the same module(s), update the range data
327 # - Otherwise, ensure that the end offset of the range is valid.
329 # If the current object does not belong to a built-in module, ignore it.
331 # If it does, we add a new built-in module offset range record.
339 sub(addr_prefix, "0x", soff);
340 soff = strtonum(soff) - sect_base[sect];
343 # Determine which (if any) built-in modules the object belongs to.
346 # If we are processing a built-in module:
347 # - If the current object is within the same module, we update its
349 # - Otherwise:
374 # If we encountered an object that is not part of a built-in module, we
379 # At this point, we encountered the start of a new built-in module.
397 # (3) Collect offset ranges (relative to the section base address) for built-in
398 # modules.
405 sub(/:\(/, " ");
411 sub(/ vmlinux\.a\(/, " ");
420 # Determine the top-level section that the object's section was included in
437 sub(addr_prefix, "0x", soff);
441 # Determine which (if any) built-in modules the object belongs to.
444 # If we are processing a built-in module:
445 # - If the current object is within the same module, we update its
447 # - Otherwise:
472 # If we encountered an object that is not part of a built-in module, we
477 # At this point, we encountered the start of a new built-in module.