RTEMS  5.0.0
Data Structures | Macros | Typedefs | Functions | Variables
rtl.h File Reference

RTEMS Run-Time Linker. More...

#include <link.h>
#include <rtems/chain.h>
#include <rtems/thread.h>
#include <rtems/rtl/rtl-allocator.h>
#include <rtems/rtl/rtl-archive.h>
#include <rtems/rtl/rtl-fwd.h>
#include <rtems/rtl/rtl-obj.h>
#include <rtems/rtl/rtl-obj-cache.h>
#include <rtems/rtl/rtl-obj-comp.h>
#include <rtems/rtl/rtl-sym.h>
#include <rtems/rtl/rtl-unresolved.h>

Go to the source code of this file.

Data Structures

struct  rtems_rtl_data
 

Macros

#define RTL_XGLUE(a, b)   ab
 
#define RTL_GLUE(a, b)   RTL_XGLUE(a,b)
 
#define RTEMS_RTL_SYMS_GLOBAL_BUCKETS   (32)
 
#define RTEMS_RTL_UNRESOLVED_BLOCK_SIZE   (64)
 
#define RTEMS_RTL_DEPENDENCY_BLOCK_SIZE   (16)
 

Typedefs

typedef void(* rtems_rtl_cdtor) (void)
 

Functions

void _rtld_debug_state (void)
 
rtems_rtl_datartems_rtl_data_unprotected (void)
 
rtems_rtl_symbolsrtems_rtl_global_symbols (void)
 
const char * rtems_rtl_last_error_unprotected (void)
 
rtems_chain_controlrtems_rtl_objects_unprotected (void)
 
rtems_chain_controlrtems_rtl_pending_unprotected (void)
 
rtems_rtl_unresolvedrtems_rtl_unresolved_unprotected (void)
 
rtems_rtl_archivesrtems_rtl_archives_unprotected (void)
 
void rtems_rtl_obj_caches (rtems_rtl_obj_cache **symbols, rtems_rtl_obj_cache **strings, rtems_rtl_obj_cache **relocs)
 
void rtems_rtl_obj_caches_flush (void)
 
void rtems_rtl_obj_decompress (rtems_rtl_obj_comp **decomp, rtems_rtl_obj_cache *cache, int fd, int compression, off_t offset)
 
void rtems_rtl_obj_update_flags (uint32_t clear, uint32_t set)
 
rtems_rtl_datartems_rtl_lock (void)
 
void rtems_rtl_unlock (void)
 
rtems_rtl_objrtems_rtl_check_handle (void *handle)
 
rtems_rtl_objrtems_rtl_find_obj (const char *name)
 
rtems_rtl_objrtems_rtl_find_obj_with_symbol (const rtems_rtl_obj_sym *sym)
 
rtems_rtl_objrtems_rtl_load_object (const char *name, int mode)
 
bool rtems_rtl_unload_object (rtems_rtl_obj *obj)
 
rtems_rtl_objrtems_rtl_load (const char *name, int mode)
 
bool rtems_rtl_unload (rtems_rtl_obj *obj)
 
int rtems_rtl_get_error (char *message, size_t max_message)
 
bool rtems_rtl_path_append (const char *path)
 
bool rtems_rtl_path_prepend (const char *path)
 
void rtems_rtl_base_sym_global_add (const unsigned char *esyms, unsigned int count)
 
rtems_rtl_objrtems_rtl_baseimage (void)
 

Variables

struct r_debug _rtld_debug
 

Detailed Description

RTEMS Run-Time Linker.

This is the POSIX interface to run-time loading of code into RTEMS.

Macro Definition Documentation

◆ RTEMS_RTL_DEPENDENCY_BLOCK_SIZE

#define RTEMS_RTL_DEPENDENCY_BLOCK_SIZE   (16)

The number of dependency record per block in the dependency table.

◆ RTEMS_RTL_SYMS_GLOBAL_BUCKETS

#define RTEMS_RTL_SYMS_GLOBAL_BUCKETS   (32)

The number of buckets in the global symbol table.

◆ RTEMS_RTL_UNRESOLVED_BLOCK_SIZE

#define RTEMS_RTL_UNRESOLVED_BLOCK_SIZE   (64)

The number of relocation record per block in the unresolved table.

◆ RTL_XGLUE

#define RTL_XGLUE (   a,
 
)    ab

Macros to glue two tokens.

Typedef Documentation

◆ rtems_rtl_cdtor

typedef void(* rtems_rtl_cdtor) (void)

The type of constructor/destructor function.

Function Documentation

◆ _rtld_debug_state()

void _rtld_debug_state ( void  )

Debugger break function. Call when debugging to have it read the _rtld_debug variable.

◆ rtems_rtl_archives_unprotected()

rtems_rtl_archives* rtems_rtl_archives_unprotected ( void  )

Get the RTL archives with out locking. This call assumes the RTL is locked.

Returns
rtems_rtl_archives* The RTL acrhives.
Return values
NULLThe RTL data is not initialised.

◆ rtems_rtl_base_sym_global_add()

void rtems_rtl_base_sym_global_add ( const unsigned char *  esyms,
unsigned int  count 
)

Add an exported symbol table to the global symbol table. This call is normally used by an object file when loaded that contains a global symbol table.

Parameters
esymsThe exported symbol table.
countThe size of the exported symbol table.

◆ rtems_rtl_baseimage()

rtems_rtl_obj* rtems_rtl_baseimage ( void  )

Return the object file descriptor for the base image. The object file descriptor returned is created when the run time linker is initialised.

Assumes the RTL has been locked.

Returns
rtl_obj* The object file descriptor for the base image. NULL is returned if the load fails.

◆ rtems_rtl_check_handle()

rtems_rtl_obj* rtems_rtl_check_handle ( void *  handle)

Check a pointer is a valid object file descriptor returning the pointer as that type.

Assumes the RTL has been locked.

Parameters
handlePointer to the object file to be validated.
Returns
rtl_obj* The object file descriptor. NULL is returned if invalid.

◆ rtems_rtl_data_unprotected()

rtems_rtl_data* rtems_rtl_data_unprotected ( void  )

Get the RTL data with out locking. This call assumes the RTL is locked.

Returns
rtems_rtl_data* The RTL data after being locked.
Return values
NULLThe RTL data is not initialised.

◆ rtems_rtl_find_obj()

rtems_rtl_obj* rtems_rtl_find_obj ( const char *  name)

Find the object given a file name.

Parameters
nameThe name of the object file.
Return values
NULLNo object file with that name found.
Returns
rtems_rtl_obj* The object file descriptor.

◆ rtems_rtl_find_obj_with_symbol()

rtems_rtl_obj* rtems_rtl_find_obj_with_symbol ( const rtems_rtl_obj_sym sym)

Find the object file a symbol is exported from.

Parameters
symThe symbol to search with.
Return values
NULLNo object file found.
Returns
rtems_rtl_obj* Reference to the symbol.

◆ rtems_rtl_get_error()

int rtems_rtl_get_error ( char *  message,
size_t  max_message 
)

Get the last error message clearing it. This operation locks the run time linker and therefore keeps the RTL thread safe but this call is not thread safe is multiple threads are loading object files at the same time. This call is provided to map to the dlopen family of calls.

Parameters
messagePointer to a buffer to copy the message into.
max_messageThe maximum message that can be copied.
Returns
int The last error number.

◆ rtems_rtl_global_symbols()

rtems_rtl_symbols* rtems_rtl_global_symbols ( void  )

Get the RTL global symbol table with out locking. This call assumes the RTL is locked.

Returns
rtems_rtl_symbols* The RTL global symbols after being locked.
Return values
NULLThe RTL data is not initialised.

◆ rtems_rtl_last_error_unprotected()

const char* rtems_rtl_last_error_unprotected ( void  )

Get the RTL last error string with out locking. This call assumes the RTL is locked.

Returns
const char* The RTL's laste error.
Return values
NULLThe RTL data is not initialised.

◆ rtems_rtl_load()

rtems_rtl_obj* rtems_rtl_load ( const char *  name,
int  mode 
)

Load an object file. This is the user accessable interface to unloading an object file. See .

Parameters
nameThe name of the object file.
modeThe mode of the load as defined by the dlopen call.
Returns
rtl_obj* The object file descriptor. NULL is returned if the load fails.

◆ rtems_rtl_load_object()

rtems_rtl_obj* rtems_rtl_load_object ( const char *  name,
int  mode 
)

Load an object file into memory relocating it. It will not be resolved against other symbols in other object files or the base image.

The name can be a file name for an object file or it can be encoded to reference an archive of object modules (static library). This encoding is specific to RTEMS and allows dependences to specify an archive without the searching overhead normally incurred by linkers locating object files in an archive. The file name format rules are:

  1. Absolute file references a specific object file in the architecture specific location on the file system.
  2. Relative file references an object format file in the search path.
  3. Absolute archive and file reference to a specific location in the file system. The archive and file are encoded as 'archive:file [@offset]' where 'archive' is a valid file at the absolute path in the file system, and 'file' is a contained in the archive, and optionally an offset to the 'file' in the 'archive'. If no offset is provided the archive is searched.
  4. Relative archive and file in the search path. The encoding is the same as described in item 3 of this list.

Assumes the RTL has been locked.

Parameters
nameThe name of the object file.
modeThe mode of the load as defined by the dlopen call.
Returns
rtl_obj* The object file descriptor. NULL is returned if the load fails.

◆ rtems_rtl_lock()

rtems_rtl_data* rtems_rtl_lock ( void  )

Lock the Run-time Linker.

Returns
rtems_rtl_data* The RTL data after being locked.
Return values
NULLThe RTL data could not be initialised or locked. Typically this means the lock could not be created.

◆ rtems_rtl_obj_caches()

void rtems_rtl_obj_caches ( rtems_rtl_obj_cache **  symbols,
rtems_rtl_obj_cache **  strings,
rtems_rtl_obj_cache **  relocs 
)

Get the RTL symbols, strings, or relocations object file caches. This call assmes the RTL is locked.

Parameters
symbolsPointer to the location to set the cache into. Returns NULL is rtl is not initialised. If NULL is passed in no value set.
stringsPointer to the location to set the cache into. Returns NULL is rtl is not initialised. If NULL is passed in no value set.
relocsPointer to the location to set the cache into. Returns NULL is rtl is not initialised. If NULL is passed in no value set.

◆ rtems_rtl_obj_caches_flush()

void rtems_rtl_obj_caches_flush ( void  )

Flush all the object file caches.

◆ rtems_rtl_obj_decompress()

void rtems_rtl_obj_decompress ( rtems_rtl_obj_comp **  decomp,
rtems_rtl_obj_cache cache,
int  fd,
int  compression,
off_t  offset 
)

Get the RTL decompressor setting for the cache and the offset in the file the compressed stream starts. This call assumes the RTL is locked.

Parameters
decompPointer to the location to set the compressor into. Returns NULL is rtl is not initialised.
cacheThe cache to read the file with. Saves needing an extrs buffer.
offsetThe offset in the file the compressed stream starts.

◆ rtems_rtl_obj_update_flags()

void rtems_rtl_obj_update_flags ( uint32_t  clear,
uint32_t  set 
)

Update the mask in the object files. You can clear flags and then set flags. A zero (0) does not clear or set the flags. This is global to all object files that are laoded.

Parameters
clearThe flag's clear mask, a 0 does not clear any flags.
setThe flag's set mask, a 0 does not set any flags.

◆ rtems_rtl_objects_unprotected()

rtems_chain_control* rtems_rtl_objects_unprotected ( void  )

Get the RTL objects table with out locking. This call assumes the RTL is locked.

Returns
rtems_chain_control* The RTL objects chain.
Return values
NULLThe RTL data is not initialised.

◆ rtems_rtl_path_append()

bool rtems_rtl_path_append ( const char *  path)

Append the path to the search path.

Parameters
pathThe path to append.
Return values
falseThe path could not be appended.
trueThe path was appended.

◆ rtems_rtl_path_prepend()

bool rtems_rtl_path_prepend ( const char *  path)

Prepend the path to the search path.

Parameters
pathThe path to prepend.
Return values
falseThe path could not be prepended.
trueThe path was prepended.

◆ rtems_rtl_pending_unprotected()

rtems_chain_control* rtems_rtl_pending_unprotected ( void  )

Get the RTL pending with out locking. This call assumes the RTL is locked.

Returns
rtems_chain_control* The RTL pending list control.
Return values
NULLThe RTL data is not initialised.

◆ rtems_rtl_unload()

bool rtems_rtl_unload ( rtems_rtl_obj obj)

Unload an object file. This is the user accessable interface to unloading an object file. See .

Assumes the RTL has been locked.

Parameters
objThe object file descriptor.
Return values
trueThe object file has been unloaded.
falseThe object file could not be unloaded.

◆ rtems_rtl_unload_object()

bool rtems_rtl_unload_object ( rtems_rtl_obj obj)

Unload an object file. This only happens when the user count is 0.

Assumes the RTL has been locked.

Parameters
objThe object file descriptor.
Return values
trueThe object file has been unloaded.
falseThe object file could not be unloaded.

◆ rtems_rtl_unlock()

void rtems_rtl_unlock ( void  )

Unlock the Run-time Linker.

◆ rtems_rtl_unresolved_unprotected()

rtems_rtl_unresolved* rtems_rtl_unresolved_unprotected ( void  )

Get the RTL unresolved table with out locking. This call assumes the RTL is locked.

Returns
rtems_rtl_unresolv* The RTL unresolved symbols and reloc records.
Return values
NULLThe RTL data is not initialised.

Variable Documentation

◆ _rtld_debug

struct r_debug _rtld_debug

The global debugger interface variable.