scripts/generate_builtin_ranges.awk
Source file repositories/reference/linux-study-clean/scripts/generate_builtin_ranges.awk
File Facts
- System
- Linux kernel
- Corpus path
scripts/generate_builtin_ranges.awk- Extension
.awk- Size
- 15663 bytes
- Lines
- 514
- Domain
- Support Tooling And Documentation
- Bucket
- scripts
- Inferred role
- Support Tooling And Documentation: scripts
- Status
- atlas-only
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
function get_module_infofunction update_entry
Annotated Snippet
function get_module_info(fn, mod, obj, s) {
if (fn in omod)
return omod[fn];
if (match(fn, /\/[^/]+$/) == 0)
return "";
obj = fn;
mod = "";
fn = substr(fn, 1, RSTART) "." substr(fn, RSTART + 1) ".cmd";
if (getline s <fn == 1) {
if (match(s, /DKBUILD_MODFILE=['"]+[^'"]+/) > 0) {
mod = substr(s, RSTART + 16, RLENGTH - 16);
gsub(/['"]/, "", mod);
} else if (match(s, /RUST_MODFILE=[^ ]+/) > 0)
mod = substr(s, RSTART + 13, RLENGTH - 13);
}
close(fn);
# A single module (common case) also reflects objects that are not part
# of a module. Some of those objects have names that are also a module
# name (e.g. core). We check the associated module file name, and if
# they do not match, the object is not part of a module.
if (mod !~ / /) {
if (!(mod in mods))
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;
return mod;
}
# Update the ranges entry for the given module 'mod' in section 'osect'.
#
# We use a modified absolute start address (soff + base) as index because we
# may need to insert an anchor record later that must be at the start of the
# section data, and the first module may very well start at the same address.
# So, we use (addr << 1) + 1 to allow a possible anchor record to be placed at
# (addr << 1). This is safe because the index is only used to sort the entries
# before writing them out.
#
function update_entry(osect, mod, soff, eoff, sect, idx) {
sect = sect_in[osect];
idx = sprintf("%016x", (soff + sect_base[osect]) * 2 + 1);
entries[idx] = sprintf("%s %08x-%08x %s", sect, soff, eoff, mod);
count[sect]++;
}
# (1) Build a lookup map of built-in module names.
#
# The first file argument is used as input (modules.builtin).
#
# Lines will be like:
# kernel/crypto/lzo-rle.ko
# and we record the object name "crypto/lzo-rle".
#
ARGIND == 1 {
sub(/kernel\//, ""); # strip off "kernel/" prefix
sub(/\.ko$/, ""); # strip off .ko suffix
mods[$1] = 1;
next;
}
Annotation
- Detected declarations: `function get_module_info`, `function update_entry`.
- Atlas domain: Support Tooling And Documentation / scripts.
- Implementation status: atlas-only.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.