UM1237 Relocatable loader library
rl_load_stream
Load a relocatable module into memory from a byte stream
Definition:
typedef int rl_stream_func_t (
void *cookie,
char *buffer,
int length); int rl_load_stream(
rl_handle_t *handle,
rl_stream_func_t *stream_func,
void *stream_cookie);
Arguments:
Returns:
Description:
handle stream_func stream_cookie
The handle for the module.
The user specified callback function.
The user specified state.
Returns 0 for success, -1 for failure.
The rl_load_stream() function loads a relocatable module into memory from a byte stream provided through a user specified callback function stream_func and the user specified state stream_cookie.
The callback function must be of type rl_stream_func_t. It is called multiple times by the loader to retrieve the load module data in the buffer buffer of length length until the module is loaded into memory. The loader always calls the callback function with a buffer length strictly greater than 0. The stream_cookie argument passed to rl_load_stream
is passed to the callback function in its cookie parameter. The cookie
parameter is intended to be used by the callback function to update a private state.
The callback function must return the number of bytes transferred. If the returned value is less than the given buffer length or is -1, rl_load_stream() will in turn return an error and the error code returned by rl_errno() is set accordingly.
The rl_load_stream() function allocates the space for the loaded module from the heap, loads the segments by calling the callback function, links the module to the parent module of the handle, relocates and initializes the loaded module. This function calls the action callback functions for RL_ACTION_LOAD after loading and before executing any code in the loaded module.
0
is returned if the load was successful, -1 is returned on failure and the error code returned by rl_errno() is set accordingly.
This function can be used as an alternative to rl_load_buffer() or rl_load_file()
to allow any loading method to be implemented.
8027948 Rev 15 149/166