arch/nios2/kernel/module.c
Source file repositories/reference/linux-study-clean/arch/nios2/kernel/module.c
File Facts
- System
- Linux kernel
- Corpus path
arch/nios2/kernel/module.c- Extension
.c- Size
- 2945 bytes
- Lines
- 118
- Domain
- Architecture Layer
- Bucket
- arch/nios2
- Inferred role
- Architecture Layer: implementation source
- Status
- source implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/moduleloader.hlinux/elf.hlinux/mm.hlinux/slab.hlinux/fs.hlinux/string.hlinux/kernel.hasm/cacheflush.h
Detected Declarations
function Copyrightfunction module_finalize
Annotated Snippet
switch (ELF32_R_TYPE(rela[i].r_info)) {
case R_NIOS2_NONE:
break;
case R_NIOS2_BFD_RELOC_32:
*loc += v;
break;
case R_NIOS2_PCREL16:
v -= (uint32_t)loc + 4;
if ((int32_t)v > 0x7fff ||
(int32_t)v < -(int32_t)0x8000) {
pr_err("module %s: relocation overflow\n",
mod->name);
return -ENOEXEC;
}
word = *loc;
*loc = ((((word >> 22) << 16) | (v & 0xffff)) << 6) |
(word & 0x3f);
break;
case R_NIOS2_CALL26:
if (v & 3) {
pr_err("module %s: dangerous relocation\n",
mod->name);
return -ENOEXEC;
}
if ((v >> 28) != ((uint32_t)loc >> 28)) {
pr_err("module %s: relocation overflow\n",
mod->name);
return -ENOEXEC;
}
*loc = (*loc & 0x3f) | ((v >> 2) << 6);
break;
case R_NIOS2_HI16:
word = *loc;
*loc = ((((word >> 22) << 16) |
((v >> 16) & 0xffff)) << 6) | (word & 0x3f);
break;
case R_NIOS2_LO16:
word = *loc;
*loc = ((((word >> 22) << 16) | (v & 0xffff)) << 6) |
(word & 0x3f);
break;
case R_NIOS2_HIADJ16:
{
Elf32_Addr word2;
word = *loc;
word2 = ((v >> 16) + ((v >> 15) & 1)) & 0xffff;
*loc = ((((word >> 22) << 16) | word2) << 6) |
(word & 0x3f);
}
break;
default:
pr_err("module %s: Unknown reloc: %u\n",
mod->name, ELF32_R_TYPE(rela[i].r_info));
return -ENOEXEC;
}
}
return 0;
}
int module_finalize(const Elf_Ehdr *hdr, const Elf_Shdr *sechdrs,
struct module *me)
{
flush_cache_all();
return 0;
}
Annotation
- Immediate include surface: `linux/moduleloader.h`, `linux/elf.h`, `linux/mm.h`, `linux/slab.h`, `linux/fs.h`, `linux/string.h`, `linux/kernel.h`, `asm/cacheflush.h`.
- Detected declarations: `function Copyright`, `function module_finalize`.
- Atlas domain: Architecture Layer / arch/nios2.
- Implementation status: source implementation candidate.
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.