LibKMod may parse binary ELF files to simplify the work done in (hostile) kernel-space. There's a layer integrating a runtime-choice of decompression libraries, in case the kernel doesn't support these formats. There's abstractions around files, including memory-mapped BTree lookups.
Perhaps one of the 2 most central sourcecode files models & parses a ref-counted kernel-module object, abstracting those support routines & certain device files, & e.g. the init_module syscall.