Transferring Data

Now that section distribution in memory is clear, the required memory space is reserved and initialized with null bytes:


ptr = module_alloc(mod->core_size);

memset(ptr, 0, mod->core_size); mod->module_core = ptr;

ptr = module_alloc(mod->init_size);

memset(ptr, 0, mod->init_size); mod->module_init = ptr;

module_alloc is an architecture-specific function for allocating module memory. In most cases, it is implemented by directly calling vmalloc or one of its variants as described in Chapter 3. In other words, the module resides in the memory area of the kernel that is mapped via page tables and not directly.

The data of all sections of the shf_alloc type are then copied to their final memory area using the information obtained by layout_sections; the sh_addr elements of each section are also set to the final position of the section (previously they pointed to the section position in the temporary module area).

Continue reading here: Querying the Module License

Was this article helpful?

0 0