Module

Supports loading of binary blobs which are the result of a extraction of the text section of a shared libraries.

Certain restrictions apply to what you can do and what not in a sahred library to allow it to be converted into a module.

Summary
ModuleSupports loading of binary blobs which are the result of a extraction of the text section of a shared libraries.
CopyrightThis program is free software.
Files
C-kern/api/context/module.hHeader file Module.
C-kern/context/module.cImplementation file Module impl.
Types
struct module_tExport module_t into global namespace.
Functions
test
unittest_context_moduleTest module_t functionality.
module_tDescribes the meory page where the program code is stored.
lifetime
module_FREEStatic initializer.
init_moduleMaps a file as binary executable into memory whose filename is modulename.
free_moduleUnmaps a binary blob from memory.
query
codeaddr_moduleReturns the start address of the mapped program code.
codesize_moduleReturns the size of the mapped program code.
inline implementation
Macros
codeaddr_moduleImplements module_t.codeaddr_module.
codesize_moduleImplements module_t.codesize_module.

Copyright

This program is free software.  You can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.

Author

© 2013 Jörg Seebohn

Files

C-kern/api/context/module.h

Header file Module.

C-kern/context/module.c

Implementation file Module impl.

Types

struct module_t

typedef struct module_t module_t

Export module_t into global namespace.

Functions

Summary

test

unittest_context_module

int unittest_context_module(void)

Test module_t functionality.

module_t

struct module_t

Describes the meory page where the program code is stored.  TODO: Support interface/version export

Summary
lifetime
module_FREEStatic initializer.
init_moduleMaps a file as binary executable into memory whose filename is modulename.
free_moduleUnmaps a binary blob from memory.
query
codeaddr_moduleReturns the start address of the mapped program code.
codesize_moduleReturns the size of the mapped program code.

lifetime

module_FREE

#define module_FREE { 0, 0 }

Static initializer.

init_module

int init_module(/*out*/module_t *mod,
const char *modulename)

Maps a file as binary executable into memory whose filename is modulename.  The binary must be stored in a directory whose name is configured in resource/config/modulevalues with module=”module_t” and name=”DIRECTORY*.  The binary is mapped as is.  No relocation is done and no data segments are supproted.

free_module

int free_module(module_t *mod)

Unmaps a binary blob from memory.

query

codeaddr_module

uint8_t * codeaddr_module(const module_t *mod)

Returns the start address of the mapped program code.

codesize_module

size_t codesize_module(const module_t *mod)

Returns the size of the mapped program code.

Macros

codeaddr_module

#define codeaddr_module(mod) ((mod)->code_addr)

Implements module_t.codeaddr_module.

codesize_module

#define codesize_module(mod) ((mod)->code_size)

Implements module_t.codesize_module.

Supports loading of binary blobs which are the result of a extraction of the text section of a shared libraries.
Implements Module.
typedef struct module_t module_t
Export module_t into global namespace.
struct module_t
Describes the meory page where the program code is stored.
int unittest_context_module(void)
Test module_t functionality.
#define module_FREE { 0, 0 }
Static initializer.
int init_module(/*out*/module_t *mod,
const char *modulename)
Maps a file as binary executable into memory whose filename is modulename.
int free_module(module_t *mod)
Unmaps a binary blob from memory.
uint8_t * codeaddr_module(const module_t *mod)
Returns the start address of the mapped program code.
size_t codesize_module(const module_t *mod)
Returns the size of the mapped program code.
#define codeaddr_module(mod) ((mod)->code_addr)
Implements module_t.codeaddr_module.
#define codesize_module(mod) ((mod)->code_size)
Implements module_t.codesize_module.
Close