RTEMS  5.0.0
Data Structures | Macros | Typedefs | Functions
rtl-archive.c File Reference

RTEMS Run-Time Linker Archive. More...

#include <ctype.h>
#include <dirent.h>
#include <errno.h>
#include <fnmatch.h>
#include <inttypes.h>
#include <stdio.h>
#include <string.h>
#include <rtems/libio_.h>
#include <rtems/rtl/rtl.h>
#include "rtl-chain-iterator.h"
#include <rtems/rtl/rtl-trace.h>
#include "rtl-string.h"
#include "rtl-error.h"

Data Structures

struct  rtems_rtl_archive_chain_data
 
struct  rtems_rtl_archive_find_data
 
struct  rtems_rtl_archive_obj_data
 

Macros

#define RTEMS_RTL_AR_IDENT   "!<arch>\n"
 
#define RTEMS_RTL_AR_IDENT_SIZE   (sizeof (RTEMS_RTL_AR_IDENT) - 1)
 
#define RTEMS_RTL_AR_FHDR_BASE   RTEMS_RTL_AR_IDENT_SIZE
 
#define RTEMS_RTL_AR_FNAME   (0)
 
#define RTEMS_RTL_AR_FNAME_SIZE   (16)
 
#define RTEMS_RTL_AR_SIZE   (48)
 
#define RTEMS_RTL_AR_SIZE_SIZE   (10)
 
#define RTEMS_RTL_AR_MAGIC   (58)
 
#define RTEMS_RTL_AR_MAGIC_SIZE   (2)
 
#define RTEMS_RTL_AR_FHDR_SIZE   (60)
 
#define RTEMS_RTL_MAX_FILE_SIZE   (256)
 

Typedefs

typedef bool(* rtems_rtl_archive_iterator) (rtems_rtl_archive *archive, void *data)
 
typedef struct rtems_rtl_archive_chain_data rtems_rtl_archive_chain_data
 
typedef struct rtems_rtl_archive_find_data rtems_rtl_archive_find_data
 
typedef struct rtems_rtl_archive_obj_data rtems_rtl_archive_obj_data
 

Functions

void rtems_rtl_archives_open (rtems_rtl_archives *archives, const char *config)
 
void rtems_rtl_archives_close (rtems_rtl_archives *archives)
 
bool rtems_rtl_archives_refresh (rtems_rtl_archives *archives)
 
bool rtems_rtl_archive_load (rtems_rtl_archives *archives, const char *name)
 
rtems_rtl_archive_search rtems_rtl_archive_obj_load (rtems_rtl_archives *archives, const char *symbol, bool load)
 
bool rtems_rtl_obj_archive_find_obj (int fd, size_t fsize, const char **name, off_t *ooffset, size_t *osize, off_t *extended_file_names, rtems_rtl_archive_error error)
 

Detailed Description

RTEMS Run-Time Linker Archive.

Macro Definition Documentation

◆ RTEMS_RTL_AR_IDENT

#define RTEMS_RTL_AR_IDENT   "!<arch>\n"

Archive headers.

Typedef Documentation

◆ rtems_rtl_archive_chain_data

Chain iterator data.

◆ rtems_rtl_archive_iterator

typedef bool(* rtems_rtl_archive_iterator) (rtems_rtl_archive *archive, void *data)

Archive iterator.

Function Documentation

◆ rtems_rtl_archive_load()

bool rtems_rtl_archive_load ( rtems_rtl_archives archives,
const char *  name 
)

Load an archive.

Parameters
archivesThe archives data to search.
nameThe archive to load.
Return values
trueThe archive is loaded.

◆ rtems_rtl_archive_obj_load()

rtems_rtl_archive_search rtems_rtl_archive_obj_load ( rtems_rtl_archives archives,
const char *  symbol,
bool  load 
)

Search for a symbol and load the first object file that has the symbol.

Parameters
archivesThe archives data to search.
symbolThe symbol name to search for.
loadIf load the object file the symbol is found in else return the found not found status.

◆ rtems_rtl_archives_close()

void rtems_rtl_archives_close ( rtems_rtl_archives archives)

Close the RTL archives support.

Parameters
archivesThe archives data to close.

◆ rtems_rtl_archives_open()

void rtems_rtl_archives_open ( rtems_rtl_archives archives,
const char *  config 
)

Open the RTL archives support with the specified configration file.

Parameters
archivesThe archives data to open.
configThe path to the configuration file.
Returns
bool Returns is the archives are open.

◆ rtems_rtl_archives_refresh()

bool rtems_rtl_archives_refresh ( rtems_rtl_archives archives)

Refresh the archives data. Check if the configuration has changes and if it has reload it. Check each path in the configuration and creates archive instances for new archives and remove archives not present any more.

Refreshing is a development aid so reboots can be avoided as users trial configurations that work.

Parameters
archivesThe archives data to refresh.
Return values
falseThe refresh failed, an error will have been set.

◆ rtems_rtl_obj_archive_find_obj()

bool rtems_rtl_obj_archive_find_obj ( int  fd,
size_t  fsize,
const char **  name,
off_t *  offset,
size_t *  size,
off_t *  extended_names,
rtems_rtl_archive_error  error 
)

Find a module in an archive returning the offset in the archive and the size. If the name field is pointing to a string pointer and that poniter is NULL and the offset is valid the name is extracted from the archive and filled in. This is used when loading a file from the archive after a symbol is found. The file name is not know and could be extended which requires searching the extended string table in the archive.

Parameters
fdOpen file handle for the archive.
fsizeSize of the archive. name Pointer to the name string.
offsetThe offset of the file in the archive.
sizeThe size of the file in the archive.
extended_namesThe offset in the archive for the extended names.
errorThe error handler called on an error.
Return values
trueThe file was found in the archive.
falseThe file was not found.