libdl: Remove _t from all structures as this is reserved for the standards

This commit is contained in:
Chris Johns
2018-04-12 17:46:49 +10:00
parent 86e79d7955
commit f59d435d16
46 changed files with 1123 additions and 1124 deletions

View File

@@ -70,10 +70,10 @@ void _rtld_debug_state (void);
/* /*
* add link map to the list. * add link map to the list.
*/ */
int _rtld_linkmap_add (rtems_rtl_obj_t* obj); int _rtld_linkmap_add (rtems_rtl_obj* obj);
/* /*
* Remove link map from the list. * Remove link map from the list.
*/ */
void _rtld_linkmap_delete (rtems_rtl_obj_t* obj); void _rtld_linkmap_delete (rtems_rtl_obj* obj);
#endif /* _LINK_ELF_H_ */ #endif /* _LINK_ELF_H_ */

View File

@@ -1,5 +1,5 @@
/* /*
* COPYRIGHT (c) 2013 Chris Johns <chrisj@rtems.org> * COPYRIGHT (c) 2013, 2018 Chris Johns <chrisj@rtems.org>
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at
@@ -42,7 +42,7 @@ extern "C" {
/** /**
* The module iterator handle. * The module iterator handle.
*/ */
typedef bool (*rtems_rap_iterator_t) (void* handle); typedef bool (*rtems_rap_iterator) (void* handle);
/** /**
* Load an application. * Load an application.
@@ -78,7 +78,7 @@ void* rtems_rap_find (const char* name);
* @retval true The iterator function returned did not return false. * @retval true The iterator function returned did not return false.
* @retval false The iterator function returned false.. * @retval false The iterator function returned false..
*/ */
bool rtems_rap_iterate (rtems_rap_iterator_t iterator); bool rtems_rap_iterate (rtems_rap_iterator iterator);
/** /**
* Return the name of the module given a handle. * Return the name of the module given a handle.

View File

@@ -1,5 +1,5 @@
/* /*
* COPYRIGHT (c) 2012 Chris Johns <chrisj@rtems.org> * COPYRIGHT (c) 2012, 2018 Chris Johns <chrisj@rtems.org>
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at
@@ -30,7 +30,7 @@ extern "C" {
* @note It is best to use the object tag for general memory allocation and to * @note It is best to use the object tag for general memory allocation and to
* leave the tags with specific access properties to the module data * leave the tags with specific access properties to the module data
*/ */
enum rtems_rtl_alloc_tags_e { enum rtems_rtl_alloc_tags {
RTEMS_RTL_ALLOC_OBJECT, /**< A generic memory object. */ RTEMS_RTL_ALLOC_OBJECT, /**< A generic memory object. */
RTEMS_RTL_ALLOC_SYMBOL, /**< Memory used for symbols. */ RTEMS_RTL_ALLOC_SYMBOL, /**< Memory used for symbols. */
RTEMS_RTL_ALLOC_EXTERNAL, /**< Memory used for external symbols. */ RTEMS_RTL_ALLOC_EXTERNAL, /**< Memory used for external symbols. */
@@ -42,7 +42,7 @@ enum rtems_rtl_alloc_tags_e {
/** /**
* The allocator tag type. * The allocator tag type.
*/ */
typedef enum rtems_rtl_alloc_tags_e rtems_rtl_alloc_tag_t; typedef enum rtems_rtl_alloc_tags rtems_rtl_alloc_tag;
/** /**
* The number of tags. * The number of tags.
@@ -63,29 +63,29 @@ typedef enum rtems_rtl_alloc_tags_e rtems_rtl_alloc_tag_t;
* @param size The size of the allocation if an allocation request and * @param size The size of the allocation if an allocation request and
* not used if deleting or freeing a previous allocation. * not used if deleting or freeing a previous allocation.
*/ */
typedef void (*rtems_rtl_allocator_t)(bool allocate, typedef void (*rtems_rtl_allocator)(bool allocate,
rtems_rtl_alloc_tag_t tag, rtems_rtl_alloc_tag tag,
void** address, void** address,
size_t size); size_t size);
/** /**
* The allocator data. * The allocator data.
*/ */
struct rtems_rtl_alloc_data_s { struct rtems_rtl_alloc_data {
/**< The memory allocator handler. */ /**< The memory allocator handler. */
rtems_rtl_allocator_t allocator; rtems_rtl_allocator allocator;
/**< The indirect pointer chains. */ /**< The indirect pointer chains. */
rtems_chain_control indirects[RTEMS_RTL_ALLOC_TAGS]; rtems_chain_control indirects[RTEMS_RTL_ALLOC_TAGS];
}; };
typedef struct rtems_rtl_alloc_data_s rtems_rtl_alloc_data_t; typedef struct rtems_rtl_alloc_data rtems_rtl_alloc_data;
/** /**
* Initialise the allocate data. * Initialise the allocate data.
* *
* @param data The data to initialise. * @param data The data to initialise.
*/ */
void rtems_rtl_alloc_initialise (rtems_rtl_alloc_data_t* data); void rtems_rtl_alloc_initialise (rtems_rtl_alloc_data* data);
/** /**
* The Runtime Loader allocator new allocates new memory and optionally clear * The Runtime Loader allocator new allocates new memory and optionally clear
@@ -96,7 +96,7 @@ void rtems_rtl_alloc_initialise (rtems_rtl_alloc_data_t* data);
* @param zero If true the memory is cleared. * @param zero If true the memory is cleared.
* @return void* The memory address or NULL is not memory available. * @return void* The memory address or NULL is not memory available.
*/ */
void* rtems_rtl_alloc_new (rtems_rtl_alloc_tag_t tag, size_t size, bool zero); void* rtems_rtl_alloc_new (rtems_rtl_alloc_tag tag, size_t size, bool zero);
/** /**
* The Runtime Loader allocator delete deletes allocated memory. * The Runtime Loader allocator delete deletes allocated memory.
@@ -104,7 +104,7 @@ void* rtems_rtl_alloc_new (rtems_rtl_alloc_tag_t tag, size_t size, bool zero);
* @param tag The type of allocation request. * @param tag The type of allocation request.
* @param address The memory address to delete. A NULL is ignored. * @param address The memory address to delete. A NULL is ignored.
*/ */
void rtems_rtl_alloc_del (rtems_rtl_alloc_tag_t tag, void* address); void rtems_rtl_alloc_del (rtems_rtl_alloc_tag tag, void* address);
/** /**
* Hook the Runtime Loader allocatior. A handler can call the previous handler * Hook the Runtime Loader allocatior. A handler can call the previous handler
@@ -113,9 +113,9 @@ void rtems_rtl_alloc_del (rtems_rtl_alloc_tag_t tag, void* address);
* returned. * returned.
* *
* @param handler The handler to use as the allocator. * @param handler The handler to use as the allocator.
* @return rtems_rtl_alloc_handler_t The previous handler. * @return rtems_rtl_alloc_handler The previous handler.
*/ */
rtems_rtl_allocator_t rtems_rtl_alloc_hook (rtems_rtl_allocator_t handler); rtems_rtl_allocator rtems_rtl_alloc_hook (rtems_rtl_allocator handler);
/** /**
* Allocate memory to an indirect handle. * Allocate memory to an indirect handle.
@@ -124,9 +124,9 @@ rtems_rtl_allocator_t rtems_rtl_alloc_hook (rtems_rtl_allocator_t handler);
* @param handle The handle to allocate the memory to. * @param handle The handle to allocate the memory to.
* @param size The size of the allocation. * @param size The size of the allocation.
*/ */
void rtems_rtl_alloc_indirect_new (rtems_rtl_alloc_tag_t tag, void rtems_rtl_alloc_indirect_new (rtems_rtl_alloc_tag tag,
rtems_rtl_ptr_t* handle, rtems_rtl_ptr* handle,
size_t size); size_t size);
/** /**
* Free memory from an indirect handle. * Free memory from an indirect handle.
@@ -134,8 +134,8 @@ void rtems_rtl_alloc_indirect_new (rtems_rtl_alloc_tag_t tag,
* @param tag The type of allocation request. * @param tag The type of allocation request.
* @param handle The handle to free the memory from. * @param handle The handle to free the memory from.
*/ */
void rtems_rtl_alloc_indirect_del (rtems_rtl_alloc_tag_t tag, void rtems_rtl_alloc_indirect_del (rtems_rtl_alloc_tag tag,
rtems_rtl_ptr_t* handle); rtems_rtl_ptr* handle);
/** /**
* Allocate the memory for a module given the size of the text, const, data and * Allocate the memory for a module given the size of the text, const, data and

View File

@@ -1,5 +1,5 @@
/* /*
* COPYRIGHT (c) 2012 Chris Johns <chrisj@rtems.org> * COPYRIGHT (c) 2012, 2018 Chris Johns <chrisj@rtems.org>
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at
@@ -23,8 +23,8 @@ extern "C" {
/** /**
* The forward declaration of the obj structure. * The forward declaration of the obj structure.
*/ */
struct rtems_rtl_data_s; struct rtems_rtl_data;
typedef struct rtems_rtl_data_s rtems_rtl_data_t; typedef struct rtems_rtl_data rtems_rtl_data;
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@@ -1,5 +1,5 @@
/* /*
* COPYRIGHT (c) 2012 Chris Johns <chrisj@rtems.org> * COPYRIGHT (c) 2012, 2018 Chris Johns <chrisj@rtems.org>
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at
@@ -26,22 +26,22 @@ extern "C" {
/** /**
* The RTL Indirect pointer. * The RTL Indirect pointer.
*/ */
struct rtems_rtl_ptr_s { struct rtems_rtl_ptr {
rtems_chain_node node; /**< Indirect pointers are held on lists. */ rtems_chain_node node; /**< Indirect pointers are held on lists. */
void* pointer; /**< The actual pointer. */ void* pointer; /**< The actual pointer. */
}; };
typedef struct rtems_rtl_ptr_s rtems_rtl_ptr_t; typedef struct rtems_rtl_ptr rtems_rtl_ptr;
/** /**
* The RTL Indirect size and pointer. * The RTL Indirect size and pointer.
*/ */
struct rtems_rtl_sptr_s { struct rtems_rtl_sptr {
rtems_rtl_ptr_t ptr; /**< The indirect pointer. */ rtems_rtl_ptr ptr; /**< The indirect pointer. */
size_t size; /**< The size of the memory block. */ size_t size; /**< The size of the memory block. */
}; };
typedef struct rtems_rtl_sptr_s rtems_rtl_sptr_t; typedef struct rtems_rtl_sptr rtems_rtl_sptr;
/** /**
* A chain of indirect pointers for users to chain in applications. * A chain of indirect pointers for users to chain in applications.
@@ -49,12 +49,12 @@ typedef struct rtems_rtl_sptr_s rtems_rtl_sptr_t;
* @note The chain the pointer is on is internal to the allocator and cannot be * @note The chain the pointer is on is internal to the allocator and cannot be
* used by applications. * used by applications.
*/ */
struct rtems_rtl_ptr_chain_s { struct rtems_rtl_ptr_chain {
rtems_chain_node node; /**< Chain of indirect pointers. */ rtems_chain_node node; /**< Chain of indirect pointers. */
rtems_rtl_ptr_t ptr; /**< The indirect pointer. */ rtems_rtl_ptr ptr; /**< The indirect pointer. */
}; };
typedef struct rtems_rtl_ptr_chain_s rtems_rtl_ptr_chain_t; typedef struct rtems_rtl_ptr_chain rtems_rtl_ptr_chain;
/** /**
* A chain of indirect sized pointers for users to chain in applications. * A chain of indirect sized pointers for users to chain in applications.
@@ -62,12 +62,12 @@ typedef struct rtems_rtl_ptr_chain_s rtems_rtl_ptr_chain_t;
* @note The chain the pointer is on is internal to the allocator and cannot be * @note The chain the pointer is on is internal to the allocator and cannot be
* used by applications. * used by applications.
*/ */
struct rtems_rtl_sptr_chain_s { struct rtems_rtl_sptr_chain {
rtems_chain_node node; /**< Chain of indirect pointers. */ rtems_chain_node node; /**< Chain of indirect pointers. */
rtems_rtl_sptr_t ptr; /**< The indirect pointer. */ rtems_rtl_sptr ptr; /**< The indirect pointer. */
}; };
typedef struct rtems_rtl_sptr_chain_s rtems_rtl_sptr_chain_t; typedef struct rtems_rtl_sptr_chain rtems_rtl_sptr_chain;
/** /**
* Get the pointer given an indirect handle. * Get the pointer given an indirect handle.
@@ -75,7 +75,7 @@ typedef struct rtems_rtl_sptr_chain_s rtems_rtl_sptr_chain_t;
* @param handle The handle the pointer is returned from. * @param handle The handle the pointer is returned from.
* @return void* The pointer held in the handle. * @return void* The pointer held in the handle.
*/ */
static inline void* rtems_rtl_ptr_get (rtems_rtl_ptr_t* handle) static inline void* rtems_rtl_ptr_get (rtems_rtl_ptr* handle)
{ {
return handle->pointer; return handle->pointer;
} }
@@ -86,7 +86,7 @@ static inline void* rtems_rtl_ptr_get (rtems_rtl_ptr_t* handle)
* @param handle The handle the pointer is returned from. * @param handle The handle the pointer is returned from.
* @param pointer The pointer to set in the handle. * @param pointer The pointer to set in the handle.
*/ */
static inline void rtems_rtl_ptr_set (rtems_rtl_ptr_t* handle, void* pointer) static inline void rtems_rtl_ptr_set (rtems_rtl_ptr* handle, void* pointer)
{ {
handle->pointer = pointer; handle->pointer = pointer;
} }
@@ -96,7 +96,7 @@ static inline void rtems_rtl_ptr_set (rtems_rtl_ptr_t* handle, void* pointer)
* *
* @param handle The handle to initialise. * @param handle The handle to initialise.
*/ */
static inline void rtems_rtl_ptr_init (rtems_rtl_ptr_t* handle) static inline void rtems_rtl_ptr_init (rtems_rtl_ptr* handle)
{ {
rtems_chain_set_off_chain (&handle->node); rtems_chain_set_off_chain (&handle->node);
handle->pointer = NULL; handle->pointer = NULL;
@@ -108,7 +108,7 @@ static inline void rtems_rtl_ptr_init (rtems_rtl_ptr_t* handle)
* @param handle The handle to test. * @param handle The handle to test.
* @return bool True if the pointer is NULL. * @return bool True if the pointer is NULL.
*/ */
static inline bool rtems_rtl_ptr_null (rtems_rtl_ptr_t* handle) static inline bool rtems_rtl_ptr_null (rtems_rtl_ptr* handle)
{ {
return handle->pointer == NULL; return handle->pointer == NULL;
} }
@@ -120,7 +120,7 @@ static inline bool rtems_rtl_ptr_null (rtems_rtl_ptr_t* handle)
* @param src The source handle to move the pointer from. * @param src The source handle to move the pointer from.
* @param dst The destination handle to receive the pointer. * @param dst The destination handle to receive the pointer.
*/ */
static inline void rtems_rtl_ptr_move (rtems_rtl_ptr_t* dst, rtems_rtl_ptr_t* src) static inline void rtems_rtl_ptr_move (rtems_rtl_ptr* dst, rtems_rtl_ptr* src)
{ {
/* /*
* We do not know which chain the src handle resides on so insert the dst * We do not know which chain the src handle resides on so insert the dst
@@ -146,7 +146,7 @@ static inline void rtems_rtl_ptr_move (rtems_rtl_ptr_t* dst, rtems_rtl_ptr_t* sr
* @param handle The handle the pointer is returned from. * @param handle The handle the pointer is returned from.
* @return void* The pointer held in the handle. * @return void* The pointer held in the handle.
*/ */
static inline void* rtems_rtl_sptr_get (rtems_rtl_sptr_t* handle) static inline void* rtems_rtl_sptr_get (rtems_rtl_sptr* handle)
{ {
return rtems_rtl_ptr_get (&handle->ptr); return rtems_rtl_ptr_get (&handle->ptr);
} }
@@ -157,7 +157,7 @@ static inline void* rtems_rtl_sptr_get (rtems_rtl_sptr_t* handle)
* @param handle The handle the pointer is returned from. * @param handle The handle the pointer is returned from.
* @param pointer The pointer to set in the handle. * @param pointer The pointer to set in the handle.
*/ */
static inline void rtems_rtl_sptr_set (rtems_rtl_sptr_t* handle, void* pointer) static inline void rtems_rtl_sptr_set (rtems_rtl_sptr* handle, void* pointer)
{ {
rtems_rtl_ptr_set (&handle->ptr, pointer); rtems_rtl_ptr_set (&handle->ptr, pointer);
} }
@@ -167,7 +167,7 @@ static inline void rtems_rtl_sptr_set (rtems_rtl_sptr_t* handle, void* pointer)
* *
* @param handle The handle to initialise. * @param handle The handle to initialise.
*/ */
static inline void rtems_rtl_sptr_init (rtems_rtl_sptr_t* handle) static inline void rtems_rtl_sptr_init (rtems_rtl_sptr* handle)
{ {
rtems_rtl_ptr_init (&handle->ptr); rtems_rtl_ptr_init (&handle->ptr);
handle->size = 0; handle->size = 0;
@@ -179,7 +179,7 @@ static inline void rtems_rtl_sptr_init (rtems_rtl_sptr_t* handle)
* @param handle The handle to test. * @param handle The handle to test.
* @return bool True if the pointer is NULL. * @return bool True if the pointer is NULL.
*/ */
static inline bool rtems_rtl_sptr_null (rtems_rtl_sptr_t* handle) static inline bool rtems_rtl_sptr_null (rtems_rtl_sptr* handle)
{ {
return rtems_rtl_ptr_null (&handle->ptr); return rtems_rtl_ptr_null (&handle->ptr);
} }
@@ -191,7 +191,7 @@ static inline bool rtems_rtl_sptr_null (rtems_rtl_sptr_t* handle)
* @param src The source handle to move the pointer from. * @param src The source handle to move the pointer from.
* @param dst The destination handle to receive the pointer. * @param dst The destination handle to receive the pointer.
*/ */
static inline void rtems_rtl_sptr_move (rtems_rtl_sptr_t* dst, rtems_rtl_sptr_t* src) static inline void rtems_rtl_sptr_move (rtems_rtl_sptr* dst, rtems_rtl_sptr* src)
{ {
rtems_rtl_ptr_move (&dst->ptr, &src->ptr); rtems_rtl_ptr_move (&dst->ptr, &src->ptr);
dst->size = src->size; dst->size = src->size;
@@ -204,7 +204,7 @@ static inline void rtems_rtl_sptr_move (rtems_rtl_sptr_t* dst, rtems_rtl_sptr_t*
* @param handle The handle to get the size from. * @param handle The handle to get the size from.
* @return size_t The size_t. * @return size_t The size_t.
*/ */
static inline size_t rtems_rtl_sptr_get_size (rtems_rtl_sptr_t* handle) static inline size_t rtems_rtl_sptr_get_size (rtems_rtl_sptr* handle)
{ {
return handle->size; return handle->size;
} }
@@ -215,7 +215,7 @@ static inline size_t rtems_rtl_sptr_get_size (rtems_rtl_sptr_t* handle)
* @param handle The handle to set the size. * @param handle The handle to set the size.
* @param size The size to set.. * @param size The size to set..
*/ */
static inline void rtems_rtl_sptr_set_size (rtems_rtl_sptr_t* handle, size_t size) static inline void rtems_rtl_sptr_set_size (rtems_rtl_sptr* handle, size_t size)
{ {
handle->size = size; handle->size = size;
} }

View File

@@ -1,5 +1,5 @@
/* /*
* COPYRIGHT (c) 2012 Chris Johns <chrisj@rtems.org> * COPYRIGHT (c) 2012, 2018 Chris Johns <chrisj@rtems.org>
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at
@@ -50,7 +50,7 @@ extern "C" {
/** /**
* The buffer cache. * The buffer cache.
*/ */
typedef struct rtems_rtl_obj_cache_s typedef struct rtems_rtl_obj_cache
{ {
int fd; /**< The file descriptor of the data in the cache. */ int fd; /**< The file descriptor of the data in the cache. */
size_t file_size; /**< The size of the file. */ size_t file_size; /**< The size of the file. */
@@ -59,7 +59,7 @@ typedef struct rtems_rtl_obj_cache_s
size_t level; /**< The amount of data in the cache. A file can be size_t level; /**< The amount of data in the cache. A file can be
* smaller than the cache file. */ * smaller than the cache file. */
uint8_t* buffer; /**< The buffer */ uint8_t* buffer; /**< The buffer */
} rtems_rtl_obj_cache_t; } rtems_rtl_obj_cache;
/** /**
* Open a cache allocating a single buffer of the size passed. The default * Open a cache allocating a single buffer of the size passed. The default
@@ -70,21 +70,21 @@ typedef struct rtems_rtl_obj_cache_s
* @retval true The cache is open. * @retval true The cache is open.
* @retval false The cache is not open. The RTL error is set. * @retval false The cache is not open. The RTL error is set.
*/ */
bool rtems_rtl_obj_cache_open (rtems_rtl_obj_cache_t* cache, size_t size); bool rtems_rtl_obj_cache_open (rtems_rtl_obj_cache* cache, size_t size);
/** /**
* Close a cache. * Close a cache.
* *
* @param cache The cache to close. * @param cache The cache to close.
*/ */
void rtems_rtl_obj_cache_close (rtems_rtl_obj_cache_t* cache); void rtems_rtl_obj_cache_close (rtems_rtl_obj_cache* cache);
/** /**
* Flush the cache. Any further read will read the data from the file. * Flush the cache. Any further read will read the data from the file.
* *
* @param cache The cache to flush. * @param cache The cache to flush.
*/ */
void rtems_rtl_obj_cache_flush (rtems_rtl_obj_cache_t* cache); void rtems_rtl_obj_cache_flush (rtems_rtl_obj_cache* cache);
/** /**
* Read data by reference. The length contains the amount of data that should * Read data by reference. The length contains the amount of data that should
@@ -102,11 +102,11 @@ void rtems_rtl_obj_cache_flush (rtems_rtl_obj_cache_t* cache);
* @retval true The data referenced is in the cache. * @retval true The data referenced is in the cache.
* @retval false The read failed and the RTL error has been set. * @retval false The read failed and the RTL error has been set.
*/ */
bool rtems_rtl_obj_cache_read (rtems_rtl_obj_cache_t* cache, bool rtems_rtl_obj_cache_read (rtems_rtl_obj_cache* cache,
int fd, int fd,
off_t offset, off_t offset,
void** buffer, void** buffer,
size_t* length); size_t* length);
/** /**
* Read data by value. The data is copied to the user supplied buffer. * Read data by value. The data is copied to the user supplied buffer.
@@ -119,11 +119,11 @@ bool rtems_rtl_obj_cache_read (rtems_rtl_obj_cache_t* cache,
* @retval true The data has been read from the cache. * @retval true The data has been read from the cache.
* @retval false The read failed and the RTL error has been set. * @retval false The read failed and the RTL error has been set.
*/ */
bool rtems_rtl_obj_cache_read_byval (rtems_rtl_obj_cache_t* cache, bool rtems_rtl_obj_cache_read_byval (rtems_rtl_obj_cache* cache,
int fd, int fd,
off_t offset, off_t offset,
void* buffer, void* buffer,
size_t length); size_t length);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@@ -1,5 +1,5 @@
/* /*
* COPYRIGHT (c) 2012 Chris Johns <chrisj@rtems.org> * COPYRIGHT (c) 2012, 2018 Chris Johns <chrisj@rtems.org>
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at
@@ -43,23 +43,23 @@ extern "C" {
/** /**
* The compressed file. * The compressed file.
*/ */
typedef struct rtems_rtl_obj_cpmp_s typedef struct rtems_rtl_obj_cpmp
{ {
rtems_rtl_obj_cache_t* cache; /**< The cache provides the input rtems_rtl_obj_cache* cache; /**< The cache provides the input
* buffer. */ * buffer. */
int fd; /**< The file descriptor. */ int fd; /**< The file descriptor. */
int compression; /**< The type of compression. */ int compression; /**< The type of compression. */
off_t offset; /**< The base offset of the buffer. */ off_t offset; /**< The base offset of the buffer. */
size_t size; /**< The size of the output buffer. */ size_t size; /**< The size of the output buffer. */
size_t level; /**< The amount of data in the buffer. */ size_t level; /**< The amount of data in the buffer. */
uint8_t* buffer; /**< The buffer */ uint8_t* buffer; /**< The buffer */
uint32_t read; /**< The amount of data read. */ uint32_t read; /**< The amount of data read. */
} rtems_rtl_obj_comp_t; } rtems_rtl_obj_comp;
/** /**
* Return the input level. * Return the input level.
*/ */
static inline uint32_t rtems_rtl_obj_comp_input (rtems_rtl_obj_comp_t* comp) static inline uint32_t rtems_rtl_obj_comp_input (rtems_rtl_obj_comp* comp)
{ {
return comp->read; return comp->read;
} }
@@ -72,15 +72,15 @@ static inline uint32_t rtems_rtl_obj_comp_input (rtems_rtl_obj_comp_t* comp)
* @retval true The compressor is open. * @retval true The compressor is open.
* @retval false The compressor is not open. The RTL error is set. * @retval false The compressor is not open. The RTL error is set.
*/ */
bool rtems_rtl_obj_comp_open (rtems_rtl_obj_comp_t* comp, bool rtems_rtl_obj_comp_open (rtems_rtl_obj_comp* comp,
size_t size); size_t size);
/** /**
* Close a compressor. * Close a compressor.
* *
* @param comp The compressor to close. * @param comp The compressor to close.
*/ */
void rtems_rtl_obj_comp_close (rtems_rtl_obj_comp_t* comp); void rtems_rtl_obj_comp_close (rtems_rtl_obj_comp* comp);
/** /**
* Set the cache and offset in the file the compressed stream starts. * Set the cache and offset in the file the compressed stream starts.
@@ -91,11 +91,11 @@ void rtems_rtl_obj_comp_close (rtems_rtl_obj_comp_t* comp);
* @param compression The type of compression being streamed. * @param compression The type of compression being streamed.
* @param offset The offset in the file the compressed stream starts. * @param offset The offset in the file the compressed stream starts.
*/ */
void rtems_rtl_obj_comp_set (rtems_rtl_obj_comp_t* comp, void rtems_rtl_obj_comp_set (rtems_rtl_obj_comp* comp,
rtems_rtl_obj_cache_t* cache, rtems_rtl_obj_cache* cache,
int fd, int fd,
int compression, int compression,
off_t offset); off_t offset);
/** /**
* Read decompressed data. The length contains the amount of data that should * Read decompressed data. The length contains the amount of data that should
@@ -111,9 +111,9 @@ void rtems_rtl_obj_comp_set (rtems_rtl_obj_comp_t* comp,
* @retval true The data referenced is in the cache. * @retval true The data referenced is in the cache.
* @retval false The read failed and the RTL error has been set. * @retval false The read failed and the RTL error has been set.
*/ */
bool rtems_rtl_obj_comp_read (rtems_rtl_obj_comp_t* comp, bool rtems_rtl_obj_comp_read (rtems_rtl_obj_comp* comp,
void* buffer, void* buffer,
size_t length); size_t length);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@@ -23,14 +23,14 @@ extern "C" {
/** /**
* The forward declaration of the obj section structure. * The forward declaration of the obj section structure.
*/ */
struct rtems_rtl_obj_sect_s; struct rtems_rtl_obj_sect;
typedef struct rtems_rtl_obj_sect_s rtems_rtl_obj_sect_t; typedef struct rtems_rtl_obj_sect rtems_rtl_obj_sect;
/** /**
* The forward declaration of the obj structure. * The forward declaration of the obj structure.
*/ */
struct rtems_rtl_obj_s; struct rtems_rtl_obj;
typedef struct rtems_rtl_obj_s rtems_rtl_obj_t; typedef struct rtems_rtl_obj rtems_rtl_obj;
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@@ -35,7 +35,7 @@ extern "C" {
/** /**
* Loader format definition. * Loader format definition.
*/ */
typedef struct rtems_rtl_loader_format_s typedef struct rtems_rtl_loader_format
{ {
/** /**
* The format label. This can be used to determine and manage * The format label. This can be used to determine and manage
@@ -47,42 +47,42 @@ typedef struct rtems_rtl_loader_format_s
* The format flags. * The format flags.
*/ */
uint32_t flags; uint32_t flags;
} rtems_rtl_loader_format_t; } rtems_rtl_loader_format;
/** /**
* The type of the format loader check handler. This handler checks the format * The type of the format loader check handler. This handler checks the format
* and if it is detected as suitable it returns true. * and if it is detected as suitable it returns true.
*/ */
typedef bool (*rtems_rtl_loader_check) (rtems_rtl_obj_t* obj, int fd); typedef bool (*rtems_rtl_loader_check) (rtems_rtl_obj* obj, int fd);
/** /**
* The type of the format loader load handler. This handler loads the specific * The type of the format loader load handler. This handler loads the specific
* format. * format.
*/ */
typedef bool (*rtems_rtl_loader_load) (rtems_rtl_obj_t* obj, int fd); typedef bool (*rtems_rtl_loader_load) (rtems_rtl_obj* obj, int fd);
/** /**
* The type of the format loader unload handler. This handler unloads the * The type of the format loader unload handler. This handler unloads the
* specific format. * specific format.
*/ */
typedef bool (*rtems_rtl_loader_unload) (rtems_rtl_obj_t* obj); typedef bool (*rtems_rtl_loader_unload) (rtems_rtl_obj* obj);
/** /**
* The type of the format loader signature handler. This handler checks the * The type of the format loader signature handler. This handler checks the
* format signature. * format signature.
*/ */
typedef rtems_rtl_loader_format_t* (*rtems_rtl_loader_sig) (void); typedef rtems_rtl_loader_format* (*rtems_rtl_loader_sig) (void);
/** /**
* Table for supported loadable formats. * Table for supported loadable formats.
*/ */
typedef struct rtems_rtl_loader_table_s typedef struct rtems_rtl_loader_table
{ {
rtems_rtl_loader_check check; /**< The check handler. */ rtems_rtl_loader_check check; /**< The check handler. */
rtems_rtl_loader_load load; /**< The loader. */ rtems_rtl_loader_load load; /**< The loader. */
rtems_rtl_loader_unload unload; /**< The unloader. */ rtems_rtl_loader_unload unload; /**< The unloader. */
rtems_rtl_loader_sig signature; /**< The loader's signature. */ rtems_rtl_loader_sig signature; /**< The loader's signature. */
} rtems_rtl_loader_table_t; } rtems_rtl_loader_table;
/** /**
* Flags for the various section types. * Flags for the various section types.
@@ -121,7 +121,7 @@ typedef struct rtems_rtl_loader_table_s
* one of a specific type of sections. All sections and grouped * one of a specific type of sections. All sections and grouped
* together in memory. * together in memory.
*/ */
struct rtems_rtl_obj_sect_s struct rtems_rtl_obj_sect
{ {
rtems_chain_node node; /**< The node's link in the chain. */ rtems_chain_node node; /**< The node's link in the chain. */
int section; /**< The section number. */ int section; /**< The section number. */
@@ -150,51 +150,51 @@ struct rtems_rtl_obj_sect_s
* RTL Object. There is one for each object module loaded plus one for the base * RTL Object. There is one for each object module loaded plus one for the base
* kernel image. * kernel image.
*/ */
struct rtems_rtl_obj_s struct rtems_rtl_obj
{ {
rtems_chain_node link; /**< The node's link in the chain. */ rtems_chain_node link; /**< The node's link in the chain. */
uint32_t flags; /**< The status of the object file. */ uint32_t flags; /**< The status of the object file. */
uint32_t users; /**< References to the object file. */ uint32_t users; /**< References to the object file. */
int format; /**< The format of the object file. */ int format; /**< The format of the object file. */
const char* fname; /**< The file name for the object. */ const char* fname; /**< The file name for the object. */
const char* oname; /**< The object file name. Can be const char* oname; /**< The object file name. Can be
* relative. */ * relative. */
const char* aname; /**< The archive name containing the const char* aname; /**< The archive name containing the
* object. NULL means the object is not * object. NULL means the object is not
* in a lib */ * in a lib */
off_t ooffset; /**< The object offset in the archive. */ off_t ooffset; /**< The object offset in the archive. */
size_t fsize; /**< Size of the object file. */ size_t fsize; /**< Size of the object file. */
rtems_chain_control sections; /**< The sections of interest in the rtems_chain_control sections; /**< The sections of interest in the
* object file. */ * object file. */
rtems_rtl_obj_sym_t* local_table; /**< Local symbol table. */ rtems_rtl_obj_sym* local_table; /**< Local symbol table. */
size_t local_syms; /**< Local symbol count. */ size_t local_syms; /**< Local symbol count. */
size_t local_size; /**< Local symbol memory usage. */ size_t local_size; /**< Local symbol memory usage. */
rtems_rtl_obj_sym_t* global_table; /**< Global symbol table. */ rtems_rtl_obj_sym* global_table; /**< Global symbol table. */
size_t global_syms; /**< Global symbol count. */ size_t global_syms; /**< Global symbol count. */
size_t global_size; /**< Global symbol memory usage. */ size_t global_size; /**< Global symbol memory usage. */
uint32_t unresolved; /**< The number of unresolved relocations. */ uint32_t unresolved; /**< The number of unresolved relocations. */
void* text_base; /**< The base address of the text section void* text_base; /**< The base address of the text section
* in memory. */ * in memory. */
size_t text_size; /**< The size of the text section. */ size_t text_size; /**< The size of the text section. */
void* const_base; /**< The base address of the const section void* const_base; /**< The base address of the const section
* in memory. */ * in memory. */
void* eh_base; /**< The base address of the eh section void* eh_base; /**< The base address of the eh section
* in memory. */ * in memory. */
size_t eh_size; /**< The size of the eh section. */ size_t eh_size; /**< The size of the eh section. */
void* data_base; /**< The base address of the data section void* data_base; /**< The base address of the data section
* in memory. */ * in memory. */
void* bss_base; /**< The base address of the bss section void* bss_base; /**< The base address of the bss section
* in memory. */ * in memory. */
size_t bss_size; /**< The size of the bss section. */ size_t bss_size; /**< The size of the bss section. */
size_t exec_size; /**< The amount of executable memory size_t exec_size; /**< The amount of executable memory
* allocated */ * allocated */
void* entry; /**< The entry point of the module. */ void* entry; /**< The entry point of the module. */
uint32_t checksum; /**< The checksum of the text sections. A uint32_t checksum; /**< The checksum of the text sections. A
* zero means do not checksum. */ * zero means do not checksum. */
uint32_t* sec_num; /**< The sec nums of each obj. */ uint32_t* sec_num; /**< The sec nums of each obj. */
uint32_t obj_num; /**< The count of elf files in an rtl obj. */ uint32_t obj_num; /**< The count of elf files in an rtl obj. */
struct link_map* linkmap; /**< For GDB. */ struct link_map* linkmap; /**< For GDB. */
void* loader; /**< The file details specific to a loader. */ void* loader; /**< The file details specific to a loader. */
}; };
/** /**
@@ -208,10 +208,10 @@ struct rtems_rtl_obj_s
* @retval true The operation was successful. * @retval true The operation was successful.
* @retval false The operation failed and the RTL has been set. * @retval false The operation failed and the RTL has been set.
*/ */
typedef bool (*rtems_rtl_obj_sect_handler_t)(rtems_rtl_obj_t* obj, typedef bool (*rtems_rtl_obj_sect_handler)(rtems_rtl_obj* obj,
int fd, int fd,
rtems_rtl_obj_sect_t* sect, rtems_rtl_obj_sect* sect,
void* data); void* data);
/** /**
* Get the file name. * Get the file name.
@@ -219,7 +219,7 @@ typedef bool (*rtems_rtl_obj_sect_handler_t)(rtems_rtl_obj_t* obj,
* @param obj The object file. * @param obj The object file.
* @return const char* The string. * @return const char* The string.
*/ */
static inline const char* rtems_rtl_obj_fname (const rtems_rtl_obj_t* obj) static inline const char* rtems_rtl_obj_fname (const rtems_rtl_obj* obj)
{ {
return obj->fname; return obj->fname;
} }
@@ -230,7 +230,7 @@ static inline const char* rtems_rtl_obj_fname (const rtems_rtl_obj_t* obj)
* @param obj The object file. * @param obj The object file.
* @return bool There is a file name * @return bool There is a file name
*/ */
static inline bool rtems_rtl_obj_fname_valid (const rtems_rtl_obj_t* obj) static inline bool rtems_rtl_obj_fname_valid (const rtems_rtl_obj* obj)
{ {
return obj->fname; return obj->fname;
} }
@@ -241,7 +241,7 @@ static inline bool rtems_rtl_obj_fname_valid (const rtems_rtl_obj_t* obj)
* @param obj The object file. * @param obj The object file.
* @return const char* The string. * @return const char* The string.
*/ */
static inline const char* rtems_rtl_obj_oname (const rtems_rtl_obj_t* obj) static inline const char* rtems_rtl_obj_oname (const rtems_rtl_obj* obj)
{ {
return obj->oname; return obj->oname;
} }
@@ -252,7 +252,7 @@ static inline const char* rtems_rtl_obj_oname (const rtems_rtl_obj_t* obj)
* @param obj The object file. * @param obj The object file.
* @return bool There is an object name * @return bool There is an object name
*/ */
static inline bool rtems_rtl_obj_oname_valid (const rtems_rtl_obj_t* obj) static inline bool rtems_rtl_obj_oname_valid (const rtems_rtl_obj* obj)
{ {
return obj->oname; return obj->oname;
} }
@@ -263,7 +263,7 @@ static inline bool rtems_rtl_obj_oname_valid (const rtems_rtl_obj_t* obj)
* @param obj The object file. * @param obj The object file.
* @return const char* The string. * @return const char* The string.
*/ */
static inline const char* rtems_rtl_obj_aname (const rtems_rtl_obj_t* obj) static inline const char* rtems_rtl_obj_aname (const rtems_rtl_obj* obj)
{ {
return obj->aname; return obj->aname;
} }
@@ -274,7 +274,7 @@ static inline const char* rtems_rtl_obj_aname (const rtems_rtl_obj_t* obj)
* @param obj The object file. * @param obj The object file.
* @return bool There is an archive name * @return bool There is an archive name
*/ */
static inline bool rtems_rtl_obj_aname_valid (const rtems_rtl_obj_t* obj) static inline bool rtems_rtl_obj_aname_valid (const rtems_rtl_obj* obj)
{ {
return obj->aname; return obj->aname;
} }
@@ -285,8 +285,8 @@ static inline bool rtems_rtl_obj_aname_valid (const rtems_rtl_obj_t* obj)
* @param obj The object file. * @param obj The object file.
* @return bool There is an archive name * @return bool There is an archive name
*/ */
static inline bool rtems_rtl_obj_text_inside (const rtems_rtl_obj_t* obj, static inline bool rtems_rtl_obj_text_inside (const rtems_rtl_obj* obj,
const void* address) const void* address)
{ {
return return
(address >= obj->text_base) && (address >= obj->text_base) &&
@@ -298,7 +298,7 @@ static inline bool rtems_rtl_obj_text_inside (const rtems_rtl_obj_t* obj,
* *
* @retval NULL No memory for the object. * @retval NULL No memory for the object.
*/ */
rtems_rtl_obj_t* rtems_rtl_obj_alloc (void); rtems_rtl_obj* rtems_rtl_obj_alloc (void);
/** /**
* Free the object structure and related resources. * Free the object structure and related resources.
@@ -307,7 +307,7 @@ rtems_rtl_obj_t* rtems_rtl_obj_alloc (void);
* @retval false The object has dependences. * @retval false The object has dependences.
* @retval true The object has been freed. * @retval true The object has been freed.
*/ */
bool rtems_rtl_obj_free (rtems_rtl_obj_t* obj); bool rtems_rtl_obj_free (rtems_rtl_obj* obj);
/** /**
* Does the object file have unresolved external references ? If it does the * Does the object file have unresolved external references ? If it does the
@@ -317,7 +317,7 @@ bool rtems_rtl_obj_free (rtems_rtl_obj_t* obj);
* @retval true The object file has unresolved externals. * @retval true The object file has unresolved externals.
* @retval false The object file has all external references resolved. * @retval false The object file has all external references resolved.
*/ */
bool rtems_rtl_obj_unresolved (rtems_rtl_obj_t* obj); bool rtems_rtl_obj_unresolved (rtems_rtl_obj* obj);
/** /**
* Parses a filename and returns newly allocated strings with the archive name, * Parses a filename and returns newly allocated strings with the archive name,
@@ -341,7 +341,7 @@ bool rtems_rtl_parse_name (const char* name,
* @param obj The object file's descriptor. * @param obj The object file's descriptor.
* @param name The name to match. * @param name The name to match.
*/ */
bool rtems_rtl_match_name (rtems_rtl_obj_t* obj, const char* name); bool rtems_rtl_match_name (rtems_rtl_obj* obj, const char* name);
/** /**
* Find an object file on disk that matches the name. The object descriptor is * Find an object file on disk that matches the name. The object descriptor is
@@ -353,7 +353,7 @@ bool rtems_rtl_match_name (rtems_rtl_obj_t* obj, const char* name);
* @retval true The file has been found. * @retval true The file has been found.
* @retval false The file could not be located. The RTL error has been set. * @retval false The file could not be located. The RTL error has been set.
*/ */
bool rtems_rtl_obj_find_file (rtems_rtl_obj_t* obj, const char* name); bool rtems_rtl_obj_find_file (rtems_rtl_obj* obj, const char* name);
/** /**
* Add a section to the object descriptor. * Add a section to the object descriptor.
@@ -370,22 +370,22 @@ bool rtems_rtl_obj_find_file (rtems_rtl_obj_t* obj, const char* name);
* @retval true The section has been added. * @retval true The section has been added.
* @retval false The section has not been added. See the RTL error. * @retval false The section has not been added. See the RTL error.
*/ */
bool rtems_rtl_obj_add_section (rtems_rtl_obj_t* obj, bool rtems_rtl_obj_add_section (rtems_rtl_obj* obj,
int section, int section,
const char* name, const char* name,
size_t size, size_t size,
off_t offset, off_t offset,
uint32_t alignment, uint32_t alignment,
int link, int link,
int info, int info,
uint32_t flags); uint32_t flags);
/** /**
* Erase the object file descriptor's sections. * Erase the object file descriptor's sections.
* *
* @param obj The object file's descriptor. * @param obj The object file's descriptor.
*/ */
void rtems_rtl_obj_erase_sections (rtems_rtl_obj_t* obj); void rtems_rtl_obj_erase_sections (rtems_rtl_obj* obj);
/** /**
* Find the section given a name. * Find the section given a name.
@@ -395,8 +395,8 @@ void rtems_rtl_obj_erase_sections (rtems_rtl_obj_t* obj);
* @retval NULL The section was not found. * @retval NULL The section was not found.
* @return rtems_rtl_obj_sect_t* The named section. * @return rtems_rtl_obj_sect_t* The named section.
*/ */
rtems_rtl_obj_sect_t* rtems_rtl_obj_find_section (const rtems_rtl_obj_t* obj, rtems_rtl_obj_sect* rtems_rtl_obj_find_section (const rtems_rtl_obj* obj,
const char* name); const char* name);
/** /**
* Find a section given a section's index number. * Find a section given a section's index number.
@@ -406,8 +406,8 @@ rtems_rtl_obj_sect_t* rtems_rtl_obj_find_section (const rtems_rtl_obj_t* obj,
* @retval NULL The section was not found. * @retval NULL The section was not found.
* @return rtems_rtl_obj_sect_t* The found section. * @return rtems_rtl_obj_sect_t* The found section.
*/ */
rtems_rtl_obj_sect_t* rtems_rtl_obj_find_section_by_index (const rtems_rtl_obj_t* obj, rtems_rtl_obj_sect* rtems_rtl_obj_find_section_by_index (const rtems_rtl_obj* obj,
int index); int index);
/** /**
* The text section size. Only use once all the sections has been added. It * The text section size. Only use once all the sections has been added. It
@@ -417,7 +417,7 @@ rtems_rtl_obj_sect_t* rtems_rtl_obj_find_section_by_index (const rtems_rtl_obj_t
* @param obj The object file's descriptor. * @param obj The object file's descriptor.
* @return size_t The size of the text area of the object file. * @return size_t The size of the text area of the object file.
*/ */
size_t rtems_rtl_obj_text_size (const rtems_rtl_obj_t* obj); size_t rtems_rtl_obj_text_size (const rtems_rtl_obj* obj);
/** /**
* The text section alignment for the object file. Only use once all the * The text section alignment for the object file. Only use once all the
@@ -430,7 +430,7 @@ size_t rtems_rtl_obj_text_size (const rtems_rtl_obj_t* obj);
* @param obj The object file's descriptor. * @param obj The object file's descriptor.
* @return uint32_t The alignment. Can be 0 or 1 for not aligned or the alignment. * @return uint32_t The alignment. Can be 0 or 1 for not aligned or the alignment.
*/ */
uint32_t rtems_rtl_obj_text_alignment (const rtems_rtl_obj_t* obj); uint32_t rtems_rtl_obj_text_alignment (const rtems_rtl_obj* obj);
/** /**
* The const section size. Only use once all the sections has been added. It * The const section size. Only use once all the sections has been added. It
@@ -440,7 +440,7 @@ uint32_t rtems_rtl_obj_text_alignment (const rtems_rtl_obj_t* obj);
* @param obj The object file's descriptor. * @param obj The object file's descriptor.
* @return size_t The size of the const area of the object file. * @return size_t The size of the const area of the object file.
*/ */
size_t rtems_rtl_obj_const_size (const rtems_rtl_obj_t* obj); size_t rtems_rtl_obj_const_size (const rtems_rtl_obj* obj);
/** /**
* The const section alignment for the object file. Only use once all the * The const section alignment for the object file. Only use once all the
@@ -453,7 +453,7 @@ size_t rtems_rtl_obj_const_size (const rtems_rtl_obj_t* obj);
* @param obj The object file's descriptor. * @param obj The object file's descriptor.
* @return uint32_t The alignment. Can be 0 or 1 for not aligned or the alignment. * @return uint32_t The alignment. Can be 0 or 1 for not aligned or the alignment.
*/ */
uint32_t rtems_rtl_obj_const_alignment (const rtems_rtl_obj_t* obj); uint32_t rtems_rtl_obj_const_alignment (const rtems_rtl_obj* obj);
/** /**
* The eh section size. Only use once all the sections has been added. It * The eh section size. Only use once all the sections has been added. It
@@ -462,7 +462,7 @@ uint32_t rtems_rtl_obj_const_alignment (const rtems_rtl_obj_t* obj);
* @param obj The object file's descriptor. * @param obj The object file's descriptor.
* @return size_t The size of the bss area of the object file. * @return size_t The size of the bss area of the object file.
*/ */
size_t rtems_rtl_obj_eh_size (const rtems_rtl_obj_t* obj); size_t rtems_rtl_obj_eh_size (const rtems_rtl_obj* obj);
/** /**
* The eh section alignment for the object file. Only use once all the sections * The eh section alignment for the object file. Only use once all the sections
@@ -475,7 +475,7 @@ size_t rtems_rtl_obj_eh_size (const rtems_rtl_obj_t* obj);
* @param obj The object file's descriptor. * @param obj The object file's descriptor.
* @return uint32_t The alignment. Can be 0 or 1 for not aligned or the alignment. * @return uint32_t The alignment. Can be 0 or 1 for not aligned or the alignment.
*/ */
uint32_t rtems_rtl_obj_eh_alignment (const rtems_rtl_obj_t* obj); uint32_t rtems_rtl_obj_eh_alignment (const rtems_rtl_obj* obj);
/** /**
* The data section size. Only use once all the sections has been added. It * The data section size. Only use once all the sections has been added. It
@@ -485,7 +485,7 @@ uint32_t rtems_rtl_obj_eh_alignment (const rtems_rtl_obj_t* obj);
* @param obj The object file's descriptor. * @param obj The object file's descriptor.
* @return size_t The size of the data area of the object file. * @return size_t The size of the data area of the object file.
*/ */
size_t rtems_rtl_obj_data_size (const rtems_rtl_obj_t* obj); size_t rtems_rtl_obj_data_size (const rtems_rtl_obj* obj);
/** /**
* The data section alignment for the object file. Only use once all the * The data section alignment for the object file. Only use once all the
@@ -498,7 +498,7 @@ size_t rtems_rtl_obj_data_size (const rtems_rtl_obj_t* obj);
* @param obj The object file's descriptor. * @param obj The object file's descriptor.
* @return uint32_t The alignment. Can be 0 or 1 for not aligned or the alignment. * @return uint32_t The alignment. Can be 0 or 1 for not aligned or the alignment.
*/ */
uint32_t rtems_rtl_obj_data_alignment (const rtems_rtl_obj_t* obj); uint32_t rtems_rtl_obj_data_alignment (const rtems_rtl_obj* obj);
/** /**
* The bss section size. Only use once all the sections has been added. It * The bss section size. Only use once all the sections has been added. It
@@ -507,7 +507,7 @@ uint32_t rtems_rtl_obj_data_alignment (const rtems_rtl_obj_t* obj);
* @param obj The object file's descriptor. * @param obj The object file's descriptor.
* @return size_t The size of the bss area of the object file. * @return size_t The size of the bss area of the object file.
*/ */
size_t rtems_rtl_obj_bss_size (const rtems_rtl_obj_t* obj); size_t rtems_rtl_obj_bss_size (const rtems_rtl_obj* obj);
/** /**
* The bss section alignment for the object file. Only use once all the * The bss section alignment for the object file. Only use once all the
@@ -520,7 +520,7 @@ size_t rtems_rtl_obj_bss_size (const rtems_rtl_obj_t* obj);
* @param obj The object file's descriptor. * @param obj The object file's descriptor.
* @return uint32_t The alignment. Can be 0 or 1 for not aligned or the alignment. * @return uint32_t The alignment. Can be 0 or 1 for not aligned or the alignment.
*/ */
uint32_t rtems_rtl_obj_bss_alignment (const rtems_rtl_obj_t* obj); uint32_t rtems_rtl_obj_bss_alignment (const rtems_rtl_obj* obj);
/** /**
* Relocate the object file. The object file's section are parsed for any * Relocate the object file. The object file's section are parsed for any
@@ -533,17 +533,17 @@ uint32_t rtems_rtl_obj_bss_alignment (const rtems_rtl_obj_t* obj);
* @retval true The object file was relocated. * @retval true The object file was relocated.
* @retval false The relocation failed. The RTL error is set. * @retval false The relocation failed. The RTL error is set.
*/ */
bool rtems_rtl_obj_relocate (rtems_rtl_obj_t* obj, bool rtems_rtl_obj_relocate (rtems_rtl_obj* obj,
int fd, int fd,
rtems_rtl_obj_sect_handler_t handler, rtems_rtl_obj_sect_handler handler,
void* data); void* data);
/** /**
* Synchronize caches to make code visible to CPU(s) * Synchronize caches to make code visible to CPU(s)
* *
* @param obj The object file's descriptor. * @param obj The object file's descriptor.
*/ */
void rtems_rtl_obj_synchronize_cache (rtems_rtl_obj_t* obj); void rtems_rtl_obj_synchronize_cache (rtems_rtl_obj* obj);
/** /**
* Relocate an object file's unresolved reference. * Relocate an object file's unresolved reference.
@@ -553,8 +553,8 @@ void rtems_rtl_obj_synchronize_cache (rtems_rtl_obj_t* obj);
* @retval true The object file record was relocated. * @retval true The object file record was relocated.
* @retval false The relocation failed. The RTL error is set. * @retval false The relocation failed. The RTL error is set.
*/ */
bool rtems_rtl_obj_relocate_unresolved (rtems_rtl_unresolv_reloc_t* reloc, bool rtems_rtl_obj_relocate_unresolved (rtems_rtl_unresolv_reloc* reloc,
rtems_rtl_obj_sym_t* sym); rtems_rtl_obj_sym* sym);
/** /**
* Load the symbols from the object file. Only the exported or public symbols * Load the symbols from the object file. Only the exported or public symbols
@@ -567,10 +567,10 @@ bool rtems_rtl_obj_relocate_unresolved (rtems_rtl_unresolv_reloc_t* reloc,
* @retval true The object file's symbol where loaded. * @retval true The object file's symbol where loaded.
* @retval false The symbol loading failed. The RTL error is set. * @retval false The symbol loading failed. The RTL error is set.
*/ */
bool rtems_rtl_obj_load_symbols (rtems_rtl_obj_t* obj, bool rtems_rtl_obj_load_symbols (rtems_rtl_obj* obj,
int fd, int fd,
rtems_rtl_obj_sect_handler_t handler, rtems_rtl_obj_sect_handler handler,
void* data); void* data);
/** /**
* Load the sections that have been allocated memory in the target. The bss * Load the sections that have been allocated memory in the target. The bss
@@ -584,10 +584,10 @@ bool rtems_rtl_obj_load_symbols (rtems_rtl_obj_t* obj,
* @retval true The object has been sucessfully loaded. * @retval true The object has been sucessfully loaded.
* @retval false The load failed. The RTL error has been set. * @retval false The load failed. The RTL error has been set.
*/ */
bool rtems_rtl_obj_load_sections (rtems_rtl_obj_t* obj, bool rtems_rtl_obj_load_sections (rtems_rtl_obj* obj,
int fd, int fd,
rtems_rtl_obj_sect_handler_t handler, rtems_rtl_obj_sect_handler handler,
void* data); void* data);
/** /**
* Invoke the constructors the object has. Constructors are a table of pointers * Invoke the constructors the object has. Constructors are a table of pointers
@@ -597,7 +597,7 @@ bool rtems_rtl_obj_load_sections (rtems_rtl_obj_t* obj,
* *
* @param obj The object file's descriptor. * @param obj The object file's descriptor.
*/ */
void rtems_rtl_obj_run_ctors (rtems_rtl_obj_t* obj); void rtems_rtl_obj_run_ctors (rtems_rtl_obj* obj);
/** /**
* Invoke the destructors the object has. Destructors are a table of pointers * Invoke the destructors the object has. Destructors are a table of pointers
@@ -607,7 +607,7 @@ void rtems_rtl_obj_run_ctors (rtems_rtl_obj_t* obj);
* *
* @param obj The object file's descriptor. * @param obj The object file's descriptor.
*/ */
void rtems_rtl_obj_run_dtors (rtems_rtl_obj_t* obj); void rtems_rtl_obj_run_dtors (rtems_rtl_obj* obj);
/** /**
* Load the object file, reading all sections into memory, symbols and * Load the object file, reading all sections into memory, symbols and
@@ -617,7 +617,7 @@ void rtems_rtl_obj_run_dtors (rtems_rtl_obj_t* obj);
* @retval true The object file has been loaded. * @retval true The object file has been loaded.
* @retval false The load failed. The RTL error has been set. * @retval false The load failed. The RTL error has been set.
*/ */
bool rtems_rtl_obj_load (rtems_rtl_obj_t* obj); bool rtems_rtl_obj_load (rtems_rtl_obj* obj);
/** /**
* Unload the object file, erasing all symbols and releasing all memory. * Unload the object file, erasing all symbols and releasing all memory.
@@ -626,7 +626,7 @@ bool rtems_rtl_obj_load (rtems_rtl_obj_t* obj);
* @retval true The object file has been unloaded. * @retval true The object file has been unloaded.
* @retval false The unload failed. The RTL error has been set. * @retval false The unload failed. The RTL error has been set.
*/ */
bool rtems_rtl_obj_unload (rtems_rtl_obj_t* obj); bool rtems_rtl_obj_unload (rtems_rtl_obj* obj);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@@ -1,5 +1,5 @@
/* /*
* COPYRIGHT (c) 2012-2014 Chris Johns <chrisj@rtems.org> * COPYRIGHT (c) 2012-2014, 2018 Chris Johns <chrisj@rtems.org>
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at
@@ -26,22 +26,22 @@ extern "C" {
/** /**
* An object file symbol. * An object file symbol.
*/ */
typedef struct rtems_rtl_obj_sym_s typedef struct rtems_rtl_obj_sym
{ {
rtems_chain_node node; /**< The node's link in the chain. */ rtems_chain_node node; /**< The node's link in the chain. */
const char* name; /**< The symbol's name. */ const char* name; /**< The symbol's name. */
void* value; /**< The value of the symbol. */ void* value; /**< The value of the symbol. */
uint32_t data; /**< Format specific data. */ uint32_t data; /**< Format specific data. */
} rtems_rtl_obj_sym_t; } rtems_rtl_obj_sym;
/** /**
* Table of symbols stored in a hash table. * Table of symbols stored in a hash table.
*/ */
typedef struct rtems_rtl_symbols_s typedef struct rtems_rtl_symbols
{ {
rtems_chain_control* buckets; rtems_chain_control* buckets;
size_t nbuckets; size_t nbuckets;
} rtems_rtl_symbols_t; } rtems_rtl_symbols;
/** /**
* Open a symbol table with the specified number of buckets. * Open a symbol table with the specified number of buckets.
@@ -52,15 +52,15 @@ typedef struct rtems_rtl_symbols_s
* @retval false The symbol table could not created. The RTL * @retval false The symbol table could not created. The RTL
* error has the error. * error has the error.
*/ */
bool rtems_rtl_symbol_table_open (rtems_rtl_symbols_t* symbols, bool rtems_rtl_symbol_table_open (rtems_rtl_symbols* symbols,
size_t buckets); size_t buckets);
/** /**
* Close the table and erase the hash table. * Close the table and erase the hash table.
* *
* @param symbols Close the symbol table. * @param symbols Close the symbol table.
*/ */
void rtems_rtl_symbol_table_close (rtems_rtl_symbols_t* symbols); void rtems_rtl_symbol_table_close (rtems_rtl_symbols* symbols);
/** /**
* Add a table of exported symbols to the symbol table. * Add a table of exported symbols to the symbol table.
@@ -83,7 +83,7 @@ void rtems_rtl_symbol_table_close (rtems_rtl_symbols_t* symbols);
* @param esyms The exported symbol table. * @param esyms The exported symbol table.
* @param size The size of the table in bytes. * @param size The size of the table in bytes.
*/ */
bool rtems_rtl_symbol_global_add (rtems_rtl_obj_t* obj, bool rtems_rtl_symbol_global_add (rtems_rtl_obj* obj,
const unsigned char* esyms, const unsigned char* esyms,
unsigned int size); unsigned int size);
@@ -94,7 +94,7 @@ bool rtems_rtl_symbol_global_add (rtems_rtl_obj_t* obj,
* @retval NULL No symbol found. * @retval NULL No symbol found.
* @return rtems_rtl_obj_sym_t* Reference to the symbol. * @return rtems_rtl_obj_sym_t* Reference to the symbol.
*/ */
rtems_rtl_obj_sym_t* rtems_rtl_symbol_global_find (const char* name); rtems_rtl_obj_sym* rtems_rtl_symbol_global_find (const char* name);
/** /**
* Find a symbol given the symbol label in the local object file. * Find a symbol given the symbol label in the local object file.
@@ -104,29 +104,29 @@ rtems_rtl_obj_sym_t* rtems_rtl_symbol_global_find (const char* name);
* @retval NULL No symbol found. * @retval NULL No symbol found.
* @return rtems_rtl_obj_sym_t* Reference to the symbol. * @return rtems_rtl_obj_sym_t* Reference to the symbol.
*/ */
rtems_rtl_obj_sym_t* rtems_rtl_symbol_obj_find (rtems_rtl_obj_t* obj, rtems_rtl_obj_sym* rtems_rtl_symbol_obj_find (rtems_rtl_obj* obj,
const char* name); const char* name);
/** /**
* Add the object file's symbols to the global table. * Add the object file's symbols to the global table.
* *
* @param obj The object file the symbols are to be added. * @param obj The object file the symbols are to be added.
*/ */
void rtems_rtl_symbol_obj_add (rtems_rtl_obj_t* obj); void rtems_rtl_symbol_obj_add (rtems_rtl_obj* obj);
/** /**
* Erase the object file's local symbols. * Erase the object file's local symbols.
* *
* @param obj The object file the local symbols are to be erased from. * @param obj The object file the local symbols are to be erased from.
*/ */
void rtems_rtl_symbol_obj_erase_local (rtems_rtl_obj_t* obj); void rtems_rtl_symbol_obj_erase_local (rtems_rtl_obj* obj);
/** /**
* Erase the object file's symbols. * Erase the object file's symbols.
* *
* @param obj The object file the symbols are to be erased from. * @param obj The object file the symbols are to be erased from.
*/ */
void rtems_rtl_symbol_obj_erase (rtems_rtl_obj_t* obj); void rtems_rtl_symbol_obj_erase (rtems_rtl_obj* obj);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@@ -1,5 +1,5 @@
/* /*
* COPYRIGHT (c) 2012 Chris Johns <chrisj@rtems.org> * COPYRIGHT (c) 2012, 2018 Chris Johns <chrisj@rtems.org>
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at
@@ -63,75 +63,75 @@ extern "C" {
* Hack to work around machine size. This needs to be cleaned up * Hack to work around machine size. This needs to be cleaned up
* to better support 64bit targets. * to better support 64bit targets.
*/ */
typedef uint32_t rtems_rtl_word_t; typedef uint32_t rtems_rtl_word;
/** /**
* The types of records in the blocks. * The types of records in the blocks.
*/ */
typedef enum rtems_rtl_unresolved_rtype_e typedef enum rtems_rtl_unresolved_rtype
{ {
rtems_rtl_unresolved_empty = 0, /**< The records is empty. Must always be 0 */ rtems_rtl_unresolved_empty = 0, /**< The records is empty. Must always be 0 */
rtems_rtl_unresolved_name = 1, /**< The record is a name. */ rtems_rtl_unresolved_name = 1, /**< The record is a name. */
rtems_rtl_unresolved_reloc = 2 /**< The record is a relocation record. */ rtems_rtl_unresolved_reloc = 2 /**< The record is a relocation record. */
} rtems_rtl_unresolved_rtype_t; } rtems_rtl_unresolved_rtype;
/** /**
* Unresolved externals symbol names. The names are reference counted and * Unresolved externals symbol names. The names are reference counted and
* separate from the relocation records because a number of records could * separate from the relocation records because a number of records could
* reference the same symbol name. * reference the same symbol name.
*/ */
typedef struct rtems_rtl_unresolv_name_s typedef struct rtems_rtl_unresolv_name
{ {
uint16_t refs; /**< The number of references to this name. */ uint16_t refs; /**< The number of references to this name. */
uint16_t length; /**< The length of this name. */ uint16_t length; /**< The length of this name. */
const char name[12]; /**< The symbol name. */ const char name[12]; /**< The symbol name. */
} rtems_rtl_unresolv_name_t; } rtems_rtl_unresolv_name;
/** /**
* Unresolved externals symbols require the relocation records to be held * Unresolved externals symbols require the relocation records to be held
* and references. * and references.
*/ */
typedef struct rtems_rtl_unresolv_reloc_s typedef struct rtems_rtl_unresolv_reloc
{ {
rtems_rtl_obj_t* obj; /**< The relocation's object file. */ rtems_rtl_obj* obj; /**< The relocation's object file. */
uint16_t flags; /**< Format specific flags. */ uint16_t flags; /**< Format specific flags. */
uint16_t name; /**< The symbol's name. */ uint16_t name; /**< The symbol's name. */
uint16_t sect; /**< The target section. */ uint16_t sect; /**< The target section. */
rtems_rtl_word_t rel[3]; /**< Relocation record. */ rtems_rtl_word rel[3]; /**< Relocation record. */
} rtems_rtl_unresolv_reloc_t; } rtems_rtl_unresolv_reloc;
/** /**
* Unresolved externals records. * Unresolved externals records.
*/ */
typedef struct rtems_rtl_unresolv_rec_s typedef struct rtems_rtl_unresolv_rec
{ {
rtems_rtl_unresolved_rtype_t type; rtems_rtl_unresolved_rtype type;
union union
{ {
rtems_rtl_unresolv_name_t name; /**< The name, or */ rtems_rtl_unresolv_name name; /**< The name, or */
rtems_rtl_unresolv_reloc_t reloc; /**< the relocation record. */ rtems_rtl_unresolv_reloc reloc; /**< the relocation record. */
} rec; } rec;
} rtems_rtl_unresolv_rec_t; } rtems_rtl_unresolv_rec;
/** /**
* Unresolved blocks. * Unresolved blocks.
*/ */
typedef struct rtems_rtl_unresolv_block_s typedef struct rtems_rtl_unresolv_block
{ {
rtems_chain_node link; /**< Blocks are chained. */ rtems_chain_node link; /**< Blocks are chained. */
uint32_t recs; /**< The number of records in the block. */ uint32_t recs; /**< The number of records in the block. */
rtems_rtl_unresolv_rec_t rec; /**< The records. More follow. */ rtems_rtl_unresolv_rec rec; /**< The records. More follow. */
} rtems_rtl_unresolv_block_t; } rtems_rtl_unresolv_block;
/** /**
* Unresolved table holds the names and relocations. * Unresolved table holds the names and relocations.
*/ */
typedef struct rtems_rtl_unresolved_s typedef struct rtems_rtl_unresolved
{ {
uint32_t marker; uint32_t marker;
size_t block_recs; /**< The records per blocks allocated. */ size_t block_recs; /**< The records per blocks allocated. */
rtems_chain_control blocks; /**< List of blocks. */ rtems_chain_control blocks; /**< List of blocks. */
} rtems_rtl_unresolved_t; } rtems_rtl_unresolved;
/** /**
* The iterator function used to iterate over the unresolved table. * The iterator function used to iterate over the unresolved table.
@@ -141,8 +141,8 @@ typedef struct rtems_rtl_unresolved_s
* @retval true The iterator has finished. * @retval true The iterator has finished.
* @retval false The iterator has not finished. Keep iterating. * @retval false The iterator has not finished. Keep iterating.
*/ */
typedef bool rtems_rtl_unresolved_iterator_t (rtems_rtl_unresolv_rec_t* rec, typedef bool rtems_rtl_unresolved_iterator (rtems_rtl_unresolv_rec* rec,
void* data); void* data);
/** /**
* Open an unresolved relocation table. * Open an unresolved relocation table.
@@ -153,21 +153,21 @@ typedef bool rtems_rtl_unresolved_iterator_t (rtems_rtl_unresolv_rec_t* rec,
* @retval false The unresolved relocation table could not created. The RTL * @retval false The unresolved relocation table could not created. The RTL
* error has the error. * error has the error.
*/ */
bool rtems_rtl_unresolved_table_open (rtems_rtl_unresolved_t* unresolved, bool rtems_rtl_unresolved_table_open (rtems_rtl_unresolved* unresolved,
size_t block_records); size_t block_records);
/** /**
* Close the table and erase the blocks. * Close the table and erase the blocks.
* *
* @param unreolved Close the unresolved table. * @param unreolved Close the unresolved table.
*/ */
void rtems_rtl_unresolved_table_close (rtems_rtl_unresolved_t* unresolved); void rtems_rtl_unresolved_table_close (rtems_rtl_unresolved* unresolved);
/** /**
* Iterate over the table of unresolved entries. * Iterate over the table of unresolved entries.
*/ */
bool rtems_rtl_unresolved_interate (rtems_rtl_unresolved_iterator_t iterator, bool rtems_rtl_unresolved_interate (rtems_rtl_unresolved_iterator iterator,
void* data); void* data);
/** /**
* Add a relocation to the list of unresolved relocations. * Add a relocation to the list of unresolved relocations.
@@ -181,11 +181,11 @@ bool rtems_rtl_unresolved_interate (rtems_rtl_unresolved_iterator_t iterator,
* @retval true The relocation has been added. * @retval true The relocation has been added.
* @retval false The relocation could not be added. * @retval false The relocation could not be added.
*/ */
bool rtems_rtl_unresolved_add (rtems_rtl_obj_t* obj, bool rtems_rtl_unresolved_add (rtems_rtl_obj* obj,
const uint16_t flags, const uint16_t flags,
const char* name, const char* name,
const uint16_t sect, const uint16_t sect,
const rtems_rtl_word_t* rel); const rtems_rtl_word* rel);
/** /**
* Resolve the unresolved symbols. * Resolve the unresolved symbols.
@@ -200,10 +200,10 @@ void rtems_rtl_unresolved_resolve (void);
* @param esyms The exported symbol table. * @param esyms The exported symbol table.
* @param size The size of the table in bytes. * @param size The size of the table in bytes.
*/ */
bool rtems_rtl_unresolved_remove (rtems_rtl_obj_t* obj, bool rtems_rtl_unresolved_remove (rtems_rtl_obj* obj,
const char* name, const char* name,
const uint16_t sect, const uint16_t sect,
const rtems_rtl_word_t* rel); const rtems_rtl_word* rel);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@@ -1,5 +1,5 @@
/* /*
* COPYRIGHT (c) 2012 Chris Johns <chrisj@rtems.org> * COPYRIGHT (c) 2012, 2018 Chris Johns <chrisj@rtems.org>
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at
@@ -84,7 +84,7 @@ extern void _rtld_debug_state (void);
/** /**
* The type of constructor/destructor function. * The type of constructor/destructor function.
*/ */
typedef void (*rtems_rtl_cdtor_t)(void); typedef void (*rtems_rtl_cdtor)(void);
/** /**
* The global RTL data. This structure is allocated on the heap when the first * The global RTL data. This structure is allocated on the heap when the first
@@ -94,48 +94,48 @@ typedef void (*rtems_rtl_cdtor_t)(void);
* actual symbols are part of the object's structure. If this is a problem we * actual symbols are part of the object's structure. If this is a problem we
* could look at a hash table per object file. * could look at a hash table per object file.
*/ */
struct rtems_rtl_data_s struct rtems_rtl_data
{ {
rtems_recursive_mutex lock; /**< The RTL lock */ rtems_recursive_mutex lock; /**< The RTL lock */
rtems_rtl_alloc_data_t allocator; /**< The allocator data. */ rtems_rtl_alloc_data allocator; /**< The allocator data. */
rtems_chain_control objects; /**< List if loaded object files. */ rtems_chain_control objects; /**< List if loaded object files. */
const char* paths; /**< Search paths for archives. */ const char* paths; /**< Search paths for archives. */
rtems_rtl_symbols_t globals; /**< Global symbol table. */ rtems_rtl_symbols globals; /**< Global symbol table. */
rtems_rtl_unresolved_t unresolved; /**< Unresolved symbols. */ rtems_rtl_unresolved unresolved; /**< Unresolved symbols. */
rtems_rtl_obj_t* base; /**< Base object file. */ rtems_rtl_obj* base; /**< Base object file. */
rtems_rtl_obj_cache_t symbols; /**< Symbols object file cache. */ rtems_rtl_obj_cache symbols; /**< Symbols object file cache. */
rtems_rtl_obj_cache_t strings; /**< Strings object file cache. */ rtems_rtl_obj_cache strings; /**< Strings object file cache. */
rtems_rtl_obj_cache_t relocs; /**< Relocations object file cache. */ rtems_rtl_obj_cache relocs; /**< Relocations object file cache. */
rtems_rtl_obj_comp_t decomp; /**< The decompression compressor. */ rtems_rtl_obj_comp decomp; /**< The decompression compressor. */
int last_errno; /**< Last error number. */ int last_errno; /**< Last error number. */
char last_error[64]; /**< Last error string. */ char last_error[64]; /**< Last error string. */
}; };
/** /**
* Get the RTL data with out locking. This call assumes the RTL is locked. * Get the RTL data with out locking. This call assumes the RTL is locked.
* *
* @return rtems_rtl_data_t* The RTL data after being locked. * @return rtems_rtl_data* The RTL data after being locked.
* @retval NULL The RTL data is not initialised. * @retval NULL The RTL data is not initialised.
*/ */
rtems_rtl_data_t* rtems_rtl_data (void); rtems_rtl_data* rtems_rtl_data_unprotected (void);
/** /**
* Get the RTL global symbol table with out locking. This call assmes the RTL * Get the RTL global symbol table with out locking. This call assmes the RTL
* is locked. * is locked.
* *
* @return rtems_rtl_symbols_t* The RTL global symbols after being locked. * @return rtems_rtl_symbols* The RTL global symbols after being locked.
* @retval NULL The RTL data is not initialised. * @retval NULL The RTL data is not initialised.
*/ */
rtems_rtl_symbols_t* rtems_rtl_global_symbols (void); rtems_rtl_symbols* rtems_rtl_global_symbols (void);
/** /**
* Get the RTL resolved table with out locking. This call assmes the RTL * Get the RTL resolved table with out locking. This call assmes the RTL
* is locked. * is locked.
* *
* @return rtems_rtl_unresolv_t* The RTL unresolved symbols and reloc records. * @return rtems_rtl_unresolv* The RTL unresolved symbols and reloc records.
* @retval NULL The RTL data is not initialised. * @retval NULL The RTL data is not initialised.
*/ */
rtems_rtl_unresolved_t* rtems_rtl_unresolved (void); rtems_rtl_unresolved* rtems_rtl_unresolved_unprotected (void);
/** /**
* Get the RTL symbols, strings, or relocations object file caches. This call * Get the RTL symbols, strings, or relocations object file caches. This call
@@ -148,9 +148,9 @@ rtems_rtl_unresolved_t* rtems_rtl_unresolved (void);
* @param relocs Pointer to the location to set the cache into. Returns NULL * @param relocs Pointer to the location to set the cache into. Returns NULL
* is rtl is not initialised. If NULL is passed in no value set. * is rtl is not initialised. If NULL is passed in no value set.
*/ */
void rtems_rtl_obj_caches (rtems_rtl_obj_cache_t** symbols, void rtems_rtl_obj_caches (rtems_rtl_obj_cache** symbols,
rtems_rtl_obj_cache_t** strings, rtems_rtl_obj_cache** strings,
rtems_rtl_obj_cache_t** relocs); rtems_rtl_obj_cache** relocs);
/** /**
* Flush all the object file caches. * Flush all the object file caches.
@@ -158,28 +158,28 @@ void rtems_rtl_obj_caches (rtems_rtl_obj_cache_t** symbols,
void rtems_rtl_obj_caches_flush (void); void rtems_rtl_obj_caches_flush (void);
/** /**
* Get the RTL decompressor setting the cache and the offset in the file the * Get the RTL decompressor setting for the cache and the offset in the file
* compressed stream starts. This call assmes the RTL is locked. * the compressed stream starts. This call assumes the RTL is locked.
* *
* @param decomp Pointer to the location to set the compressor into. Returns * @param decomp Pointer to the location to set the compressor into. Returns
* NULL is rtl is not initialised. * NULL is rtl is not initialised.
* @param cache The cache to read the file with. Saves needing an extrs buffer. * @param cache The cache to read the file with. Saves needing an extrs buffer.
* @param offset The offset in the file the compressed stream starts. * @param offset The offset in the file the compressed stream starts.
*/ */
void rtems_rtl_obj_comp (rtems_rtl_obj_comp_t** decomp, void rtems_rtl_obj_decompress (rtems_rtl_obj_comp** decomp,
rtems_rtl_obj_cache_t* cache, rtems_rtl_obj_cache* cache,
int fd, int fd,
int compression, int compression,
off_t offset); off_t offset);
/** /**
* Lock the Run-time Linker. * Lock the Run-time Linker.
* *
* @return rtems_rtl_data_t* The RTL data after being locked. * @return rtems_rtl_data* The RTL data after being locked.
* @retval NULL The RTL data could not be initialised or locked. Typically this * @retval NULL The RTL data could not be initialised or locked. Typically this
* means the lock could not be created. * means the lock could not be created.
*/ */
rtems_rtl_data_t* rtems_rtl_lock (void); rtems_rtl_data* rtems_rtl_lock (void);
/** /**
* Unlock the Run-time Linker. * Unlock the Run-time Linker.
@@ -195,16 +195,16 @@ void rtems_rtl_unlock (void);
* @param handle Pointer to the object file to be validated. * @param handle Pointer to the object file to be validated.
* @return rtl_obj* The object file descriptor. NULL is returned if invalid. * @return rtl_obj* The object file descriptor. NULL is returned if invalid.
*/ */
rtems_rtl_obj_t* rtems_rtl_check_handle (void* handle); rtems_rtl_obj* rtems_rtl_check_handle (void* handle);
/** /**
* Find the object given a file name. * Find the object given a file name.
* *
* @param name The name of the object file. * @param name The name of the object file.
* @retval NULL No object file with that name found. * @retval NULL No object file with that name found.
* @return rtems_rtl_obj_t* The object file descriptor. * @return rtems_rtl_obj* The object file descriptor.
*/ */
rtems_rtl_obj_t* rtems_rtl_find_obj (const char* name); rtems_rtl_obj* rtems_rtl_find_obj (const char* name);
/** /**
* Load an object file into memory relocating it. It will not be resolved * Load an object file into memory relocating it. It will not be resolved
@@ -237,7 +237,7 @@ rtems_rtl_obj_t* rtems_rtl_find_obj (const char* name);
* @param mode The mode of the load as defined by the dlopen call. * @param mode The mode of the load as defined by the dlopen call.
* @return rtl_obj* The object file descriptor. NULL is returned if the load fails. * @return rtl_obj* The object file descriptor. NULL is returned if the load fails.
*/ */
rtems_rtl_obj_t* rtems_rtl_load_object (const char* name, int mode); rtems_rtl_obj* rtems_rtl_load_object (const char* name, int mode);
/** /**
* Unload an object file. This only happens when the user count is 0. * Unload an object file. This only happens when the user count is 0.
@@ -248,7 +248,7 @@ rtems_rtl_obj_t* rtems_rtl_load_object (const char* name, int mode);
* @retval true The object file has been unloaded. * @retval true The object file has been unloaded.
* @retval false The object file could not be unloaded. * @retval false The object file could not be unloaded.
*/ */
bool rtems_rtl_unload_object (rtems_rtl_obj_t* obj); bool rtems_rtl_unload_object (rtems_rtl_obj* obj);
/** /**
* Run any constructor functions the object file may contain. This call * Run any constructor functions the object file may contain. This call
@@ -256,7 +256,7 @@ bool rtems_rtl_unload_object (rtems_rtl_obj_t* obj);
* *
* @param obj The object file. * @param obj The object file.
*/ */
void rtems_rtl_run_ctors (rtems_rtl_obj_t* obj); void rtems_rtl_run_ctors (rtems_rtl_obj* obj);
/** /**
* Get the last error message clearing it. This operation locks the run time * Get the last error message clearing it. This operation locks the run time
@@ -309,7 +309,7 @@ void rtems_rtl_base_sym_global_add (const unsigned char* esyms,
* @return rtl_obj* The object file descriptor for the base image. NULL is * @return rtl_obj* The object file descriptor for the base image. NULL is
* returned if the load fails. * returned if the load fails.
*/ */
rtems_rtl_obj_t* rtems_rtl_baseimage (void); rtems_rtl_obj* rtems_rtl_baseimage (void);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@@ -1,5 +1,5 @@
/* /*
* COPYRIGHT (c) 2012 Chris Johns <chrisj@rtems.org> * COPYRIGHT (c) 2012, 2018 Chris Johns <chrisj@rtems.org>
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at
@@ -98,7 +98,7 @@ shell_dlsym (int argc, char* argv[])
return -1; return -1;
} }
typedef int (*call_t)(int argc, char* argv[]); typedef int (*call_p)(int argc, char* argv[]);
int int
shell_dlcall (int argc, char* argv[]) shell_dlcall (int argc, char* argv[])
@@ -106,7 +106,7 @@ shell_dlcall (int argc, char* argv[])
void* value; void* value;
if (lookup_dlsym (&value, argc, argv)) if (lookup_dlsym (&value, argc, argv))
{ {
call_t call = value; call_p call = value;
int r; int r;
printf ("(*%p)(%d, ....)\n", value, argc - 3); printf ("(*%p)(%d, ....)\n", value, argc - 3);
r = call (argc - 3, argv + 3); r = call (argc - 3, argv + 3);

View File

@@ -1,5 +1,5 @@
/* /*
* COPYRIGHT (c) 2012 Chris Johns <chrisj@rtems.org> * COPYRIGHT (c) 2012, 2018 Chris Johns <chrisj@rtems.org>
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at
@@ -19,10 +19,10 @@
#include <dlfcn.h> #include <dlfcn.h>
#include <rtems/rtl/rtl.h> #include <rtems/rtl/rtl.h>
static rtems_rtl_obj_t* static rtems_rtl_obj*
dl_get_obj_from_handle (void* handle) dl_get_obj_from_handle (void* handle)
{ {
rtems_rtl_obj_t* obj; rtems_rtl_obj* obj;
/* /*
* Handle the special cases provided in NetBSD and Sun documentation. * Handle the special cases provided in NetBSD and Sun documentation.
@@ -43,7 +43,7 @@ dl_get_obj_from_handle (void* handle)
void* void*
dlopen (const char* name, int mode) dlopen (const char* name, int mode)
{ {
rtems_rtl_obj_t* obj = NULL; rtems_rtl_obj* obj = NULL;
if (!rtems_rtl_lock ()) if (!rtems_rtl_lock ())
return NULL; return NULL;
@@ -67,8 +67,8 @@ dlopen (const char* name, int mode)
int int
dlclose (void* handle) dlclose (void* handle)
{ {
rtems_rtl_obj_t* obj; rtems_rtl_obj* obj;
int r; int r;
if (!rtems_rtl_lock ()) if (!rtems_rtl_lock ())
return -1; return -1;
@@ -96,9 +96,9 @@ dlclose (void* handle)
void* void*
dlsym (void* handle, const char *symbol) dlsym (void* handle, const char *symbol)
{ {
rtems_rtl_obj_t* obj; rtems_rtl_obj* obj;
rtems_rtl_obj_sym_t* sym = NULL; rtems_rtl_obj_sym* sym = NULL;
void* symval = NULL; void* symval = NULL;
if (!rtems_rtl_lock ()) if (!rtems_rtl_lock ())
return NULL; return NULL;
@@ -136,8 +136,8 @@ dlerror (void)
int int
dlinfo (void* handle, int request, void* p) dlinfo (void* handle, int request, void* p)
{ {
rtems_rtl_obj_t* obj; rtems_rtl_obj* obj;
int rc = -1; int rc = -1;
if (!rtems_rtl_lock () || !p) if (!rtems_rtl_lock () || !p)
return -1; return -1;

View File

@@ -1,5 +1,5 @@
/* /*
* COPYRIGHT (c) 2012 Chris Johns <chrisj@rtems.org> * COPYRIGHT (c) 2012, 2018 Chris Johns <chrisj@rtems.org>
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at
@@ -44,18 +44,18 @@ typedef struct rtems_rap_data_s
rtems_chain_control apps; /**< List if loaded application. */ rtems_chain_control apps; /**< List if loaded application. */
int last_errno; /**< Last error number. */ int last_errno; /**< Last error number. */
char last_error[64]; /**< Last error string. */ char last_error[64]; /**< Last error string. */
} rtems_rap_data_t; } rtems_rap_data;
/** /**
* The RAP file data. This structure is allocated on the heap when a file is * The RAP file data. This structure is allocated on the heap when a file is
* loaded. * loaded.
*/ */
typedef struct rtems_rap_app_s typedef struct rtems_rap_app
{ {
rtems_chain_node node; /**< The node's link in the chain. */ rtems_chain_node node; /**< The node's link in the chain. */
const char* name; /**< The file name */ const char* name; /**< The file name */
void* handle; /**< The dlopen handle. */ void* handle; /**< The dlopen handle. */
} rtems_rap_app_t; } rtems_rap_app;
/** /**
* RTL entry. * RTL entry.
@@ -69,7 +69,7 @@ typedef struct rtems_rap_app_s
/** /**
* Static RAP data is returned to the user when the loader is locked. * Static RAP data is returned to the user when the loader is locked.
*/ */
static rtems_rap_data_t rap_ = { .once = PTHREAD_ONCE_INIT }; static rtems_rap_data rap_ = { .once = PTHREAD_ONCE_INIT };
/** /**
* Verbose level for the RAP loader. * Verbose level for the RAP loader.
@@ -79,7 +79,7 @@ static bool rap_verbose;
/** /**
* RAP entry call signature. * RAP entry call signature.
*/ */
typedef int (*rtems_rap_entry_t)(int argc, const char* argv[]); typedef int (*rtems_rap_entry)(int argc, const char* argv[]);
/** /**
* Forward decl. * Forward decl.
@@ -100,7 +100,7 @@ rtems_rap_data_init (void)
rtems_chain_initialize_empty (&rap_.apps); rtems_chain_initialize_empty (&rap_.apps);
} }
static rtems_rap_data_t* static rtems_rap_data*
rtems_rap_lock (void) rtems_rap_lock (void)
{ {
pthread_once (&rap_.once, rtems_rap_data_init); pthread_once (&rap_.once, rtems_rap_data_init);
@@ -115,10 +115,10 @@ rtems_rap_unlock (void)
rtems_mutex_unlock (&rap_.lock); rtems_mutex_unlock (&rap_.lock);
} }
static rtems_rap_app_t* static rtems_rap_app*
rtems_rap_check_handle (void* handle) rtems_rap_check_handle (void* handle)
{ {
rtems_rap_app_t* app; rtems_rap_app* app;
rtems_chain_node* node; rtems_chain_node* node;
app = handle; app = handle;
@@ -126,7 +126,7 @@ rtems_rap_check_handle (void* handle)
while (!rtems_chain_is_tail (&rap_.apps, node)) while (!rtems_chain_is_tail (&rap_.apps, node))
{ {
rtems_rap_app_t* check = (rtems_rap_app_t*) node; rtems_rap_app* check = (rtems_rap_app*) node;
if (check == app) if (check == app)
return app; return app;
node = rtems_chain_next (node); node = rtems_chain_next (node);
@@ -135,17 +135,17 @@ rtems_rap_check_handle (void* handle)
return NULL; return NULL;
} }
static rtems_rap_app_t* static rtems_rap_app*
rtems_rap_app_alloc (void) rtems_rap_app_alloc (void)
{ {
rtems_rap_app_t* app = malloc (sizeof (rtems_rap_app_t)); rtems_rap_app* app = malloc (sizeof (rtems_rap_app));
memset (app, 0, sizeof (rtems_rap_app_t)); memset (app, 0, sizeof (rtems_rap_app));
rtems_chain_append (&rap_.apps, &app->node); rtems_chain_append (&rap_.apps, &app->node);
return app; return app;
} }
static void static void
rtems_rap_app_free (rtems_rap_app_t* app) rtems_rap_app_free (rtems_rap_app* app)
{ {
if (app->handle) if (app->handle)
{ {
@@ -158,7 +158,7 @@ rtems_rap_app_free (rtems_rap_app_t* app)
} }
static bool static bool
rtems_rap_match_name (rtems_rap_app_t* app, const char* name) rtems_rap_match_name (rtems_rap_app* app, const char* name)
{ {
const char* a; const char* a;
@@ -211,8 +211,8 @@ rtems_rap_get_rtl_error (void)
static void static void
rtems_rap_set_error (int error, const char* format, ...) rtems_rap_set_error (int error, const char* format, ...)
{ {
rtems_rap_data_t* rap = rtems_rap_lock (); rtems_rap_data* rap = rtems_rap_lock ();
va_list ap; va_list ap;
va_start (ap, format); va_start (ap, format);
rap->last_errno = error; rap->last_errno = error;
vsnprintf (rap->last_error, sizeof (rap->last_error), format, ap); vsnprintf (rap->last_error, sizeof (rap->last_error), format, ap);
@@ -223,7 +223,7 @@ rtems_rap_set_error (int error, const char* format, ...)
bool bool
rtems_rap_load (const char* name, int mode, int argc, const char* argv[]) rtems_rap_load (const char* name, int mode, int argc, const char* argv[])
{ {
rtems_rap_data_t* rap = rtems_rap_lock (); rtems_rap_data* rap = rtems_rap_lock ();
if (!rap) if (!rap)
return false; return false;
@@ -236,11 +236,11 @@ rtems_rap_load (const char* name, int mode, int argc, const char* argv[])
*/ */
if (!rtems_rap_find (name)) if (!rtems_rap_find (name))
{ {
rtems_rap_app_t* app; rtems_rap_app* app;
rtems_rap_entry_t init; rtems_rap_entry init;
rtems_rap_entry_t fini; rtems_rap_entry fini;
size_t size = 0; size_t size = 0;
int r; int r;
/* /*
* Allocate a new application descriptor and attempt to load it. * Allocate a new application descriptor and attempt to load it.
@@ -309,9 +309,9 @@ rtems_rap_load (const char* name, int mode, int argc, const char* argv[])
bool bool
rtems_rap_unload (const char* name) rtems_rap_unload (const char* name)
{ {
rtems_rap_app_t* app; rtems_rap_app* app;
rtems_rap_entry_t fini; rtems_rap_entry fini;
int r; int r;
rtems_rap_lock (); rtems_rap_lock ();
@@ -352,14 +352,14 @@ rtems_rap_unload (const char* name)
void* void*
rtems_rap_find (const char* name) rtems_rap_find (const char* name)
{ {
rtems_rap_data_t* rap = rtems_rap_lock (); rtems_rap_data* rap = rtems_rap_lock ();
rtems_chain_node* node; rtems_chain_node* node;
node = rtems_chain_first (&rap->apps); node = rtems_chain_first (&rap->apps);
while (!rtems_chain_is_tail (&rap->apps, node)) while (!rtems_chain_is_tail (&rap->apps, node))
{ {
rtems_rap_app_t* app = (rtems_rap_app_t*) node; rtems_rap_app* app = (rtems_rap_app*) node;
if (rtems_rap_match_name (app, name)) if (rtems_rap_match_name (app, name))
{ {
rtems_rap_unlock (); rtems_rap_unlock ();
@@ -374,9 +374,9 @@ rtems_rap_find (const char* name)
} }
bool bool
rtems_rap_iterate (rtems_rap_iterator_t iterator) rtems_rap_iterate (rtems_rap_iterator iterator)
{ {
rtems_rap_data_t* rap = rtems_rap_lock (); rtems_rap_data* rap = rtems_rap_lock ();
rtems_chain_node* node; rtems_chain_node* node;
bool result = true; bool result = true;
@@ -384,7 +384,7 @@ rtems_rap_iterate (rtems_rap_iterator_t iterator)
while (!rtems_chain_is_tail (&rap->apps, node)) while (!rtems_chain_is_tail (&rap->apps, node))
{ {
rtems_rap_app_t* app = (rtems_rap_app_t*) node; rtems_rap_app* app = (rtems_rap_app*) node;
result = iterator (app); result = iterator (app);
if (!result) if (!result)
break; break;
@@ -399,7 +399,7 @@ rtems_rap_iterate (rtems_rap_iterator_t iterator)
const char* const char*
rtems_rap_name (void* handle) rtems_rap_name (void* handle)
{ {
rtems_rap_app_t* app = rtems_rap_check_handle (handle); rtems_rap_app* app = rtems_rap_check_handle (handle);
if (app) if (app)
return app->name; return app->name;
return NULL; return NULL;
@@ -408,7 +408,7 @@ rtems_rap_name (void* handle)
void* void*
rtems_rap_dl_handle (void* handle) rtems_rap_dl_handle (void* handle)
{ {
rtems_rap_app_t* app = rtems_rap_check_handle (handle); rtems_rap_app* app = rtems_rap_check_handle (handle);
if (app) if (app)
return app->handle; return app->handle;
return NULL; return NULL;
@@ -417,8 +417,8 @@ rtems_rap_dl_handle (void* handle)
int int
rtems_rap_get_error (char* message, size_t max_message) rtems_rap_get_error (char* message, size_t max_message)
{ {
rtems_rap_data_t* rap = rtems_rap_lock (); rtems_rap_data* rap = rtems_rap_lock ();
int last_errno = rap->last_errno; int last_errno = rap->last_errno;
strlcpy (message, rap->last_error, max_message); strlcpy (message, rap->last_error, max_message);
rtems_rap_unlock (); rtems_rap_unlock ();
return last_errno; return last_errno;

View File

@@ -18,10 +18,10 @@
#include "rtl-alloc-heap.h" #include "rtl-alloc-heap.h"
void void
rtems_rtl_alloc_heap (bool allocate, rtems_rtl_alloc_heap (bool allocate,
rtems_rtl_alloc_tag_t tag, rtems_rtl_alloc_tag tag,
void** address, void** address,
size_t size) size_t size)
{ {
if (allocate) if (allocate)
*address = malloc (size); *address = malloc (size);

View File

@@ -1,5 +1,5 @@
/* /*
* COPYRIGHT (c) 2012 Chris Johns <chrisj@rtems.org> * COPYRIGHT (c) 2012, 2018 Chris Johns <chrisj@rtems.org>
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at
@@ -35,10 +35,10 @@ extern "C" {
* @param size The size of the allocation if an allocation request and * @param size The size of the allocation if an allocation request and
* not used if deleting or freeing a previous allocation. * not used if deleting or freeing a previous allocation.
*/ */
void rtems_rtl_alloc_heap(bool allocate, void rtems_rtl_alloc_heap(bool allocate,
rtems_rtl_alloc_tag_t tag, rtems_rtl_alloc_tag tag,
void** address, void** address,
size_t size); size_t size);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@@ -1,5 +1,5 @@
/* /*
* COPYRIGHT (c) 2012 Chris Johns <chrisj@rtems.org> * COPYRIGHT (c) 2012, 2018 Chris Johns <chrisj@rtems.org>
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at
@@ -39,7 +39,7 @@ static const char* tag_labels[6] =
#endif #endif
void void
rtems_rtl_alloc_initialise (rtems_rtl_alloc_data_t* data) rtems_rtl_alloc_initialise (rtems_rtl_alloc_data* data)
{ {
int c; int c;
data->allocator = rtems_rtl_alloc_heap; data->allocator = rtems_rtl_alloc_heap;
@@ -48,10 +48,10 @@ rtems_rtl_alloc_initialise (rtems_rtl_alloc_data_t* data)
} }
void* void*
rtems_rtl_alloc_new (rtems_rtl_alloc_tag_t tag, size_t size, bool zero) rtems_rtl_alloc_new (rtems_rtl_alloc_tag tag, size_t size, bool zero)
{ {
rtems_rtl_data_t* rtl = rtems_rtl_lock (); rtems_rtl_data* rtl = rtems_rtl_lock ();
void* address = NULL; void* address = NULL;
/* /*
* Obtain memory from the allocator. The address field is set by the * Obtain memory from the allocator. The address field is set by the
@@ -76,9 +76,9 @@ rtems_rtl_alloc_new (rtems_rtl_alloc_tag_t tag, size_t size, bool zero)
} }
void void
rtems_rtl_alloc_del (rtems_rtl_alloc_tag_t tag, void* address) rtems_rtl_alloc_del (rtems_rtl_alloc_tag tag, void* address)
{ {
rtems_rtl_data_t* rtl = rtems_rtl_lock (); rtems_rtl_data* rtl = rtems_rtl_lock ();
if (rtems_rtl_trace (RTEMS_RTL_TRACE_ALLOCATOR)) if (rtems_rtl_trace (RTEMS_RTL_TRACE_ALLOCATOR))
printf ("rtl: alloc: del: %s addr=%p\n", printf ("rtl: alloc: del: %s addr=%p\n",
@@ -90,22 +90,22 @@ rtems_rtl_alloc_del (rtems_rtl_alloc_tag_t tag, void* address)
rtems_rtl_unlock (); rtems_rtl_unlock ();
} }
rtems_rtl_allocator_t rtems_rtl_allocator
rtems_rtl_alloc_hook (rtems_rtl_allocator_t handler) rtems_rtl_alloc_hook (rtems_rtl_allocator handler)
{ {
rtems_rtl_data_t* rtl = rtems_rtl_lock (); rtems_rtl_data* rtl = rtems_rtl_lock ();
rtems_rtl_allocator_t previous = rtl->allocator.allocator; rtems_rtl_allocator previous = rtl->allocator.allocator;
rtl->allocator.allocator = handler; rtl->allocator.allocator = handler;
rtems_rtl_unlock (); rtems_rtl_unlock ();
return previous; return previous;
} }
void void
rtems_rtl_alloc_indirect_new (rtems_rtl_alloc_tag_t tag, rtems_rtl_alloc_indirect_new (rtems_rtl_alloc_tag tag,
rtems_rtl_ptr_t* handle, rtems_rtl_ptr* handle,
size_t size) size_t size)
{ {
rtems_rtl_data_t* rtl = rtems_rtl_lock (); rtems_rtl_data* rtl = rtems_rtl_lock ();
if (rtems_rtl_trace (RTEMS_RTL_TRACE_ALLOCATOR)) if (rtems_rtl_trace (RTEMS_RTL_TRACE_ALLOCATOR))
{ {
@@ -118,7 +118,7 @@ rtems_rtl_alloc_indirect_new (rtems_rtl_alloc_tag_t tag,
if (rtl) if (rtl)
{ {
rtems_rtl_alloc_data_t* allocator = &rtl->allocator; rtems_rtl_alloc_data* allocator = &rtl->allocator;
handle->pointer = rtems_rtl_alloc_new (tag, size, false); handle->pointer = rtems_rtl_alloc_new (tag, size, false);
if (!rtems_rtl_ptr_null (handle)) if (!rtems_rtl_ptr_null (handle))
rtems_chain_append_unprotected (&allocator->indirects[tag], rtems_chain_append_unprotected (&allocator->indirects[tag],
@@ -129,10 +129,10 @@ rtems_rtl_alloc_indirect_new (rtems_rtl_alloc_tag_t tag,
} }
void void
rtems_rtl_alloc_indirect_del (rtems_rtl_alloc_tag_t tag, rtems_rtl_alloc_indirect_del (rtems_rtl_alloc_tag tag,
rtems_rtl_ptr_t* handle) rtems_rtl_ptr* handle)
{ {
rtems_rtl_data_t* rtl = rtems_rtl_lock (); rtems_rtl_data* rtl = rtems_rtl_lock ();
if (rtems_rtl_trace (RTEMS_RTL_TRACE_ALLOCATOR)) if (rtems_rtl_trace (RTEMS_RTL_TRACE_ALLOCATOR))
{ {

View File

@@ -1,5 +1,5 @@
/* /*
* COPYRIGHT (c) 2012 Chris Johns <chrisj@rtems.org> * COPYRIGHT (c) 2012, 2018 Chris Johns <chrisj@rtems.org>
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at
@@ -43,7 +43,7 @@ _rtld_debug_state (void)
} }
int int
_rtld_linkmap_add (rtems_rtl_obj_t* obj) _rtld_linkmap_add (rtems_rtl_obj* obj)
{ {
struct link_map* l = obj->linkmap; struct link_map* l = obj->linkmap;
struct link_map* prev; struct link_map* prev;
@@ -76,7 +76,7 @@ _rtld_linkmap_add (rtems_rtl_obj_t* obj)
} }
void void
_rtld_linkmap_delete (rtems_rtl_obj_t* obj) _rtld_linkmap_delete (rtems_rtl_obj* obj)
{ {
struct link_map* l = obj->linkmap; struct link_map* l = obj->linkmap;
/* /*

View File

@@ -1,5 +1,5 @@
/* /*
* COPYRIGHT (c) 2012-2014 Chris Johns <chrisj@rtems.org> * COPYRIGHT (c) 2012-2018 Chris Johns <chrisj@rtems.org>
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at
@@ -43,7 +43,7 @@
/** /**
* The ELF format signature. * The ELF format signature.
*/ */
static rtems_rtl_loader_format_t elf_sig = static rtems_rtl_loader_format elf_sig =
{ {
.label = "ELF", .label = "ELF",
.flags = RTEMS_RTL_FMT_ELF .flags = RTEMS_RTL_FMT_ELF
@@ -65,19 +65,19 @@ rtems_rtl_elf_machine_check (Elf_Ehdr* ehdr)
} }
bool bool
rtems_rtl_elf_find_symbol (rtems_rtl_obj_t* obj, rtems_rtl_elf_find_symbol (rtems_rtl_obj* obj,
const Elf_Sym* sym, const Elf_Sym* sym,
const char* symname, const char* symname,
Elf_Word* value) Elf_Word* value)
{ {
rtems_rtl_obj_sect_t* sect; rtems_rtl_obj_sect* sect;
if (ELF_ST_TYPE(sym->st_info) == STT_NOTYPE) if (ELF_ST_TYPE(sym->st_info) == STT_NOTYPE)
{ {
/* /*
* Search the object file then the global table for the symbol. * Search the object file then the global table for the symbol.
*/ */
rtems_rtl_obj_sym_t* symbol = rtems_rtl_symbol_obj_find (obj, symname); rtems_rtl_obj_sym* symbol = rtems_rtl_symbol_obj_find (obj, symname);
if (!symbol) if (!symbol)
{ {
rtems_rtl_set_error (EINVAL, "global symbol not found: %s", symname); rtems_rtl_set_error (EINVAL, "global symbol not found: %s", symname);
@@ -100,20 +100,20 @@ rtems_rtl_elf_find_symbol (rtems_rtl_obj_t* obj,
} }
static bool static bool
rtems_rtl_elf_relocator (rtems_rtl_obj_t* obj, rtems_rtl_elf_relocator (rtems_rtl_obj* obj,
int fd, int fd,
rtems_rtl_obj_sect_t* sect, rtems_rtl_obj_sect* sect,
void* data) void* data)
{ {
rtems_rtl_obj_cache_t* symbols; rtems_rtl_obj_cache* symbols;
rtems_rtl_obj_cache_t* strings; rtems_rtl_obj_cache* strings;
rtems_rtl_obj_cache_t* relocs; rtems_rtl_obj_cache* relocs;
rtems_rtl_obj_sect_t* targetsect; rtems_rtl_obj_sect* targetsect;
rtems_rtl_obj_sect_t* symsect; rtems_rtl_obj_sect* symsect;
rtems_rtl_obj_sect_t* strtab; rtems_rtl_obj_sect* strtab;
bool is_rela; bool is_rela;
size_t reloc_size; size_t reloc_size;
int reloc; int reloc;
/* /*
* First check if the section the relocations are for exists. If it does not * First check if the section the relocations are for exists. If it does not
@@ -215,8 +215,8 @@ rtems_rtl_elf_relocator (rtems_rtl_obj_t* obj,
{ {
if (!rtems_rtl_elf_find_symbol (obj, &sym, symname, &symvalue)) if (!rtems_rtl_elf_find_symbol (obj, &sym, symname, &symvalue))
{ {
uint16_t flags = 0; uint16_t flags = 0;
rtems_rtl_word_t rel_words[3]; rtems_rtl_word rel_words[3];
relocate = false; relocate = false;
@@ -282,12 +282,12 @@ rtems_rtl_elf_relocator (rtems_rtl_obj_t* obj,
} }
bool bool
rtems_rtl_obj_relocate_unresolved (rtems_rtl_unresolv_reloc_t* reloc, rtems_rtl_obj_relocate_unresolved (rtems_rtl_unresolv_reloc* reloc,
rtems_rtl_obj_sym_t* sym) rtems_rtl_obj_sym* sym)
{ {
rtems_rtl_obj_sect_t* sect; rtems_rtl_obj_sect* sect;
bool is_rela; bool is_rela;
Elf_Word symvalue; Elf_Word symvalue;
is_rela =reloc->flags & 1; is_rela =reloc->flags & 1;
@@ -338,23 +338,23 @@ rtems_rtl_obj_relocate_unresolved (rtems_rtl_unresolv_reloc_t* reloc,
} }
static bool static bool
rtems_rtl_elf_symbols (rtems_rtl_obj_t* obj, rtems_rtl_elf_symbols (rtems_rtl_obj* obj,
int fd, int fd,
rtems_rtl_obj_sect_t* sect, rtems_rtl_obj_sect* sect,
void* data) void* data)
{ {
rtems_rtl_obj_cache_t* symbols; rtems_rtl_obj_cache* symbols;
rtems_rtl_obj_cache_t* strings; rtems_rtl_obj_cache* strings;
rtems_rtl_obj_sect_t* strtab; rtems_rtl_obj_sect* strtab;
int locals; int locals;
int local_string_space; int local_string_space;
rtems_rtl_obj_sym_t* lsym; rtems_rtl_obj_sym* lsym;
char* lstring; char* lstring;
int globals; int globals;
int global_string_space; int global_string_space;
rtems_rtl_obj_sym_t* gsym; rtems_rtl_obj_sym* gsym;
char* gstring; char* gstring;
int sym; int sym;
strtab = rtems_rtl_obj_find_section (obj, ".strtab"); strtab = rtems_rtl_obj_find_section (obj, ".strtab");
if (!strtab) if (!strtab)
@@ -408,7 +408,7 @@ rtems_rtl_elf_symbols (rtems_rtl_obj_t* obj,
(ELF_ST_TYPE (symbol.st_info) == STT_FUNC) || (ELF_ST_TYPE (symbol.st_info) == STT_FUNC) ||
(ELF_ST_TYPE (symbol.st_info) == STT_NOTYPE))) (ELF_ST_TYPE (symbol.st_info) == STT_NOTYPE)))
{ {
rtems_rtl_obj_sect_t* symsect; rtems_rtl_obj_sect* symsect;
symsect = rtems_rtl_obj_find_section_by_index (obj, symbol.st_shndx); symsect = rtems_rtl_obj_find_section_by_index (obj, symbol.st_shndx);
if (symsect) if (symsect)
@@ -446,7 +446,7 @@ rtems_rtl_elf_symbols (rtems_rtl_obj_t* obj,
if (locals) if (locals)
{ {
obj->local_size = locals * sizeof (rtems_rtl_obj_sym_t) + local_string_space; obj->local_size = locals * sizeof (rtems_rtl_obj_sym) + local_string_space;
obj->local_table = rtems_rtl_alloc_new (RTEMS_RTL_ALLOC_SYMBOL, obj->local_table = rtems_rtl_alloc_new (RTEMS_RTL_ALLOC_SYMBOL,
obj->local_size, true); obj->local_size, true);
if (!obj->local_table) if (!obj->local_table)
@@ -461,7 +461,7 @@ rtems_rtl_elf_symbols (rtems_rtl_obj_t* obj,
if (globals) if (globals)
{ {
obj->global_size = globals * sizeof (rtems_rtl_obj_sym_t) + global_string_space; obj->global_size = globals * sizeof (rtems_rtl_obj_sym) + global_string_space;
obj->global_table = rtems_rtl_alloc_new (RTEMS_RTL_ALLOC_SYMBOL, obj->global_table = rtems_rtl_alloc_new (RTEMS_RTL_ALLOC_SYMBOL,
obj->global_size, true); obj->global_size, true);
if (!obj->global_table) if (!obj->global_table)
@@ -482,10 +482,10 @@ rtems_rtl_elf_symbols (rtems_rtl_obj_t* obj,
lsym = obj->local_table; lsym = obj->local_table;
lstring = lstring =
(((char*) obj->local_table) + (locals * sizeof (rtems_rtl_obj_sym_t))); (((char*) obj->local_table) + (locals * sizeof (rtems_rtl_obj_sym)));
gsym = obj->global_table; gsym = obj->global_table;
gstring = gstring =
(((char*) obj->global_table) + (globals * sizeof (rtems_rtl_obj_sym_t))); (((char*) obj->global_table) + (globals * sizeof (rtems_rtl_obj_sym)));
for (sym = 0; sym < (sect->size / sizeof (Elf_Sym)); ++sym) for (sym = 0; sym < (sect->size / sizeof (Elf_Sym)); ++sym)
{ {
@@ -530,9 +530,9 @@ rtems_rtl_elf_symbols (rtems_rtl_obj_t* obj,
(ELF_ST_BIND (symbol.st_info) == STB_WEAK) || (ELF_ST_BIND (symbol.st_info) == STB_WEAK) ||
(ELF_ST_BIND (symbol.st_info) == STB_LOCAL))) (ELF_ST_BIND (symbol.st_info) == STB_LOCAL)))
{ {
rtems_rtl_obj_sect_t* symsect; rtems_rtl_obj_sect* symsect;
rtems_rtl_obj_sym_t* osym; rtems_rtl_obj_sym* osym;
char* string; char* string;
symsect = rtems_rtl_obj_find_section_by_index (obj, symbol.st_shndx); symsect = rtems_rtl_obj_find_section_by_index (obj, symbol.st_shndx);
if (symsect) if (symsect)
@@ -578,10 +578,10 @@ rtems_rtl_elf_symbols (rtems_rtl_obj_t* obj,
} }
static bool static bool
rtems_rtl_elf_loader (rtems_rtl_obj_t* obj, rtems_rtl_elf_loader (rtems_rtl_obj* obj,
int fd, int fd,
rtems_rtl_obj_sect_t* sect, rtems_rtl_obj_sect* sect,
void* data) void* data)
{ {
uint8_t* base_offset; uint8_t* base_offset;
size_t len; size_t len;
@@ -611,14 +611,14 @@ rtems_rtl_elf_loader (rtems_rtl_obj_t* obj,
} }
static bool static bool
rtems_rtl_elf_parse_sections (rtems_rtl_obj_t* obj, int fd, Elf_Ehdr* ehdr) rtems_rtl_elf_parse_sections (rtems_rtl_obj* obj, int fd, Elf_Ehdr* ehdr)
{ {
rtems_rtl_obj_cache_t* sects; rtems_rtl_obj_cache* sects;
rtems_rtl_obj_cache_t* strings; rtems_rtl_obj_cache* strings;
int section; int section;
off_t sectstroff; off_t sectstroff;
off_t off; off_t off;
Elf_Shdr shdr; Elf_Shdr shdr;
rtems_rtl_obj_caches (&sects, &strings, NULL); rtems_rtl_obj_caches (&sects, &strings, NULL);
@@ -772,10 +772,10 @@ rtems_rtl_elf_parse_sections (rtems_rtl_obj_t* obj, int fd, Elf_Ehdr* ehdr)
} }
bool bool
rtems_rtl_elf_file_check (rtems_rtl_obj_t* obj, int fd) rtems_rtl_elf_file_check (rtems_rtl_obj* obj, int fd)
{ {
rtems_rtl_obj_cache_t* header; rtems_rtl_obj_cache* header;
Elf_Ehdr ehdr; Elf_Ehdr ehdr;
rtems_rtl_obj_caches (&header, NULL, NULL); rtems_rtl_obj_caches (&header, NULL, NULL);
@@ -803,7 +803,7 @@ rtems_rtl_elf_file_check (rtems_rtl_obj_t* obj, int fd)
} }
static bool static bool
rtems_rtl_elf_load_linkmap (rtems_rtl_obj_t* obj) rtems_rtl_elf_load_linkmap (rtems_rtl_obj* obj)
{ {
rtems_chain_control* sections = NULL; rtems_chain_control* sections = NULL;
rtems_chain_node* node = NULL; rtems_chain_node* node = NULL;
@@ -824,7 +824,7 @@ rtems_rtl_elf_load_linkmap (rtems_rtl_obj_t* obj)
node = rtems_chain_first (sections); node = rtems_chain_first (sections);
while (!rtems_chain_is_tail (sections, node)) while (!rtems_chain_is_tail (sections, node))
{ {
rtems_rtl_obj_sect_t* sect = (rtems_rtl_obj_sect_t*) node; rtems_rtl_obj_sect* sect = (rtems_rtl_obj_sect*) node;
if ((sect->size != 0) && ((sect->flags & mask) != 0)) if ((sect->size != 0) && ((sect->flags & mask) != 0))
{ {
++sec_num; ++sec_num;
@@ -867,7 +867,7 @@ rtems_rtl_elf_load_linkmap (rtems_rtl_obj_t* obj)
node = rtems_chain_first (sections); node = rtems_chain_first (sections);
while (!rtems_chain_is_tail (sections, node)) while (!rtems_chain_is_tail (sections, node))
{ {
rtems_rtl_obj_sect_t* sect = (rtems_rtl_obj_sect_t*) node; rtems_rtl_obj_sect* sect = (rtems_rtl_obj_sect*) node;
if ((sect->size != 0) && ((sect->flags & mask) != 0)) if ((sect->size != 0) && ((sect->flags & mask) != 0))
{ {
@@ -904,10 +904,10 @@ rtems_rtl_elf_load_linkmap (rtems_rtl_obj_t* obj)
} }
bool bool
rtems_rtl_elf_file_load (rtems_rtl_obj_t* obj, int fd) rtems_rtl_elf_file_load (rtems_rtl_obj* obj, int fd)
{ {
rtems_rtl_obj_cache_t* header; rtems_rtl_obj_cache* header;
Elf_Ehdr ehdr; Elf_Ehdr ehdr;
rtems_rtl_obj_caches (&header, NULL, NULL); rtems_rtl_obj_caches (&header, NULL, NULL);
@@ -994,13 +994,13 @@ rtems_rtl_elf_file_load (rtems_rtl_obj_t* obj, int fd)
} }
bool bool
rtems_rtl_elf_file_unload (rtems_rtl_obj_t* obj) rtems_rtl_elf_file_unload (rtems_rtl_obj* obj)
{ {
rtems_rtl_elf_unwind_deregister (obj); rtems_rtl_elf_unwind_deregister (obj);
return true; return true;
} }
rtems_rtl_loader_format_t* rtems_rtl_loader_format*
rtems_rtl_elf_file_sig (void) rtems_rtl_elf_file_sig (void)
{ {
return &elf_sig; return &elf_sig;

View File

@@ -1,5 +1,5 @@
/* /*
* COPYRIGHT (c) 2012 Chris Johns <chrisj@rtems.org> * COPYRIGHT (c) 2012-2018 Chris Johns <chrisj@rtems.org>
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at
@@ -67,8 +67,8 @@ extern "C" {
* @retval 0 Unknown or unsupported flags. * @retval 0 Unknown or unsupported flags.
* @retval uint32_t RTL object file flags. * @retval uint32_t RTL object file flags.
*/ */
uint32_t rtems_rtl_elf_section_flags (const rtems_rtl_obj_t* obj, uint32_t rtems_rtl_elf_section_flags (const rtems_rtl_obj* obj,
const Elf_Shdr* shdr); const Elf_Shdr* shdr);
/** /**
* Architecture specific handler to check is a relocation record's type is * Architecture specific handler to check is a relocation record's type is
@@ -94,12 +94,12 @@ bool rtems_rtl_elf_rel_resolve_sym (Elf_Word type);
* @retval bool The relocation has been applied. * @retval bool The relocation has been applied.
* @retval bool The relocation could not be applied. * @retval bool The relocation could not be applied.
*/ */
bool rtems_rtl_elf_relocate_rel (const rtems_rtl_obj_t* obj, bool rtems_rtl_elf_relocate_rel (const rtems_rtl_obj* obj,
const Elf_Rel* rel, const Elf_Rel* rel,
const rtems_rtl_obj_sect_t* sect, const rtems_rtl_obj_sect* sect,
const char* symname, const char* symname,
const Elf_Byte syminfo, const Elf_Byte syminfo,
const Elf_Word symvalue); const Elf_Word symvalue);
/** /**
* Architecture specific relocation handler compiled in for a specific * Architecture specific relocation handler compiled in for a specific
@@ -115,12 +115,12 @@ bool rtems_rtl_elf_relocate_rel (const rtems_rtl_obj_t* obj,
* @retval bool The relocation has been applied. * @retval bool The relocation has been applied.
* @retval bool The relocation could not be applied. * @retval bool The relocation could not be applied.
*/ */
bool rtems_rtl_elf_relocate_rela (const rtems_rtl_obj_t* obj, bool rtems_rtl_elf_relocate_rela (const rtems_rtl_obj* obj,
const Elf_Rela* rela, const Elf_Rela* rela,
const rtems_rtl_obj_sect_t* sect, const rtems_rtl_obj_sect* sect,
const char* symname, const char* symname,
const Elf_Byte syminfo, const Elf_Byte syminfo,
const Elf_Word symvalue); const Elf_Word symvalue);
/** /**
* Find the symbol. The symbol is passed as an ELF type symbol with the name * Find the symbol. The symbol is passed as an ELF type symbol with the name
@@ -139,10 +139,10 @@ bool rtems_rtl_elf_relocate_rela (const rtems_rtl_obj_t* obj,
* @retval true The symbol resolved. * @retval true The symbol resolved.
* @retval false The symbol could not be result. The RTL error is set. * @retval false The symbol could not be result. The RTL error is set.
*/ */
bool rtems_rtl_elf_find_symbol (rtems_rtl_obj_t* obj, bool rtems_rtl_elf_find_symbol (rtems_rtl_obj* obj,
const Elf_Sym* sym, const Elf_Sym* sym,
const char* symname, const char* symname,
Elf_Word* value); Elf_Word* value);
/** /**
* The ELF format check handler. * The ELF format check handler.
@@ -150,7 +150,7 @@ bool rtems_rtl_elf_find_symbol (rtems_rtl_obj_t* obj,
* @param obj The object being checked. * @param obj The object being checked.
* @param fd The file descriptor. * @param fd The file descriptor.
*/ */
bool rtems_rtl_elf_file_check (rtems_rtl_obj_t* obj, int fd); bool rtems_rtl_elf_file_check (rtems_rtl_obj* obj, int fd);
/** /**
* The ELF format load handler. * The ELF format load handler.
@@ -158,21 +158,21 @@ bool rtems_rtl_elf_file_check (rtems_rtl_obj_t* obj, int fd);
* @param obj The object to load. * @param obj The object to load.
* @param fd The file descriptor. * @param fd The file descriptor.
*/ */
bool rtems_rtl_elf_file_load (rtems_rtl_obj_t* obj, int fd); bool rtems_rtl_elf_file_load (rtems_rtl_obj* obj, int fd);
/** /**
* The ELF format unload handler. * The ELF format unload handler.
* *
* @param obj The object to unload. * @param obj The object to unload.
*/ */
bool rtems_rtl_elf_file_unload (rtems_rtl_obj_t* obj); bool rtems_rtl_elf_file_unload (rtems_rtl_obj* obj);
/** /**
* The ELF format signature handler. * The ELF format signature handler.
* *
* @return rtems_rtl_loader_format_t* The format's signature. * @return rtems_rtl_loader_format* The format's signature.
*/ */
rtems_rtl_loader_format_t* rtems_rtl_elf_file_sig (void); rtems_rtl_loader_format* rtems_rtl_elf_file_sig (void);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@@ -1,5 +1,5 @@
/* /*
* COPYRIGHT (c) 2012 Chris Johns <chrisj@rtems.org> * COPYRIGHT (c) 2012-2018 Chris Johns <chrisj@rtems.org>
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at
@@ -28,8 +28,8 @@
void void
rtems_rtl_set_error (int error, const char* format, ...) rtems_rtl_set_error (int error, const char* format, ...)
{ {
rtems_rtl_data_t* rtl = rtems_rtl_lock (); rtems_rtl_data* rtl = rtems_rtl_lock ();
va_list ap; va_list ap;
va_start (ap, format); va_start (ap, format);
rtl->last_errno = error; rtl->last_errno = error;
vsnprintf (rtl->last_error, sizeof (rtl->last_error), format, ap); vsnprintf (rtl->last_error, sizeof (rtl->last_error), format, ap);
@@ -40,7 +40,7 @@ rtems_rtl_set_error (int error, const char* format, ...)
int int
rtems_rtl_get_error (char* message, size_t max_message) rtems_rtl_get_error (char* message, size_t max_message)
{ {
rtems_rtl_data_t* rtl = rtems_rtl_lock (); rtems_rtl_data* rtl = rtems_rtl_lock ();
if (rtl != NULL) if (rtl != NULL)
{ {
int last_errno = rtl->last_errno; int last_errno = rtl->last_errno;

View File

@@ -67,8 +67,8 @@ sign_extend31(Elf_Addr val)
} }
uint32_t uint32_t
rtems_rtl_elf_section_flags (const rtems_rtl_obj_t* obj, rtems_rtl_elf_section_flags (const rtems_rtl_obj* obj,
const Elf_Shdr* shdr) const Elf_Shdr* shdr)
{ {
uint32_t flags = 0; uint32_t flags = 0;
if (shdr->sh_type == SHT_ARM_EXIDX) if (shdr->sh_type == SHT_ARM_EXIDX)
@@ -83,24 +83,24 @@ rtems_rtl_elf_rel_resolve_sym (Elf_Word type)
} }
bool bool
rtems_rtl_elf_relocate_rela (const rtems_rtl_obj_t* obj, rtems_rtl_elf_relocate_rela (const rtems_rtl_obj* obj,
const Elf_Rela* rela, const Elf_Rela* rela,
const rtems_rtl_obj_sect_t* sect, const rtems_rtl_obj_sect* sect,
const char* symname, const char* symname,
const Elf_Byte syminfo, const Elf_Byte syminfo,
const Elf_Word symvalue) const Elf_Word symvalue)
{ {
rtems_rtl_set_error (EINVAL, "rela type record not supported"); rtems_rtl_set_error (EINVAL, "rela type record not supported");
return false; return false;
} }
bool bool
rtems_rtl_elf_relocate_rel (const rtems_rtl_obj_t* obj, rtems_rtl_elf_relocate_rel (const rtems_rtl_obj* obj,
const Elf_Rel* rel, const Elf_Rel* rel,
const rtems_rtl_obj_sect_t* sect, const rtems_rtl_obj_sect* sect,
const char* symname, const char* symname,
const Elf_Byte syminfo, const Elf_Byte syminfo,
const Elf_Word symvalue) const Elf_Word symvalue)
{ {
Elf_Addr *where; Elf_Addr *where;
Elf_Addr tmp; Elf_Addr tmp;
@@ -357,9 +357,9 @@ rtems_rtl_elf_relocate_rel (const rtems_rtl_obj_t* obj,
} }
bool bool
rtems_rtl_elf_unwind_parse (const rtems_rtl_obj_t* obj, rtems_rtl_elf_unwind_parse (const rtems_rtl_obj* obj,
const char* name, const char* name,
uint32_t flags) uint32_t flags)
{ {
/* /*
* We location the EH sections in section flags. * We location the EH sections in section flags.
@@ -368,13 +368,13 @@ rtems_rtl_elf_unwind_parse (const rtems_rtl_obj_t* obj,
} }
bool bool
rtems_rtl_elf_unwind_register (rtems_rtl_obj_t* obj) rtems_rtl_elf_unwind_register (rtems_rtl_obj* obj)
{ {
return true; return true;
} }
bool bool
rtems_rtl_elf_unwind_deregister (rtems_rtl_obj_t* obj) rtems_rtl_elf_unwind_deregister (rtems_rtl_obj* obj)
{ {
obj->loader = NULL; obj->loader = NULL;
return true; return true;
@@ -406,7 +406,7 @@ _Unwind_Ptr __gnu_Unwind_Find_exidx (_Unwind_Ptr return_address,
_Unwind_Ptr __gnu_Unwind_Find_exidx (_Unwind_Ptr return_address, _Unwind_Ptr __gnu_Unwind_Find_exidx (_Unwind_Ptr return_address,
int* nrec) int* nrec)
{ {
rtems_rtl_data_t* rtl; rtems_rtl_data* rtl;
rtems_chain_node* node; rtems_chain_node* node;
__EIT_entry* exidx_start = &__exidx_start; __EIT_entry* exidx_start = &__exidx_start;
__EIT_entry* exidx_end = &__exidx_end; __EIT_entry* exidx_end = &__exidx_end;
@@ -415,7 +415,7 @@ _Unwind_Ptr __gnu_Unwind_Find_exidx (_Unwind_Ptr return_address,
node = rtems_chain_first (&rtl->objects); node = rtems_chain_first (&rtl->objects);
while (!rtems_chain_is_tail (&rtl->objects, node)) { while (!rtems_chain_is_tail (&rtl->objects, node)) {
rtems_rtl_obj_t* obj = (rtems_rtl_obj_t*) node; rtems_rtl_obj* obj = (rtems_rtl_obj*) node;
if (rtems_rtl_obj_text_inside (obj, (void*) return_address)) { if (rtems_rtl_obj_text_inside (obj, (void*) return_address)) {
exidx_start = (__EIT_entry*) obj->eh_base; exidx_start = (__EIT_entry*) obj->eh_base;
exidx_end = (__EIT_entry*) (obj->eh_base + obj->eh_size); exidx_end = (__EIT_entry*) (obj->eh_base + obj->eh_size);

View File

@@ -33,17 +33,17 @@ load_ptr(void *where)
} }
bool bool
rtems_rtl_elf_relocate_rela (const rtems_rtl_obj_t* obj, rtems_rtl_elf_relocate_rela (const rtems_rtl_obj* obj,
const Elf_Rela* rela, const Elf_Rela* rela,
const rtems_rtl_obj_sect_t* sect, const rtems_rtl_obj_sect* sect,
const char* symname, const char* symname,
const Elf_Byte syminfo, const Elf_Byte syminfo,
const Elf_Word symvalue) const Elf_Word symvalue)
{ {
Elf_Addr target = 0; Elf_Addr target = 0;
Elf_Addr *where; Elf_Addr *where;
Elf_Word tmp; Elf_Word tmp;
Elf_Word size; //byte Elf_Word size; //byte
where = (Elf_Addr *)(sect->base + rela->r_offset); where = (Elf_Addr *)(sect->base + rela->r_offset);
@@ -112,33 +112,33 @@ rtems_rtl_elf_relocate_rela (const rtems_rtl_obj_t* obj,
} }
bool bool
rtems_rtl_elf_relocate_rel (const rtems_rtl_obj_t* obj, rtems_rtl_elf_relocate_rel (const rtems_rtl_obj* obj,
const Elf_Rel* rel, const Elf_Rel* rel,
const rtems_rtl_obj_sect_t* sect, const rtems_rtl_obj_sect* sect,
const char* symname, const char* symname,
const Elf_Byte syminfo, const Elf_Byte syminfo,
const Elf_Word symvalue) const Elf_Word symvalue)
{ {
rtems_rtl_set_error (EINVAL, "rel type record not supported"); rtems_rtl_set_error (EINVAL, "rel type record not supported");
return false; return false;
} }
bool bool
rtems_rtl_elf_unwind_parse (const rtems_rtl_obj_t* obj, rtems_rtl_elf_unwind_parse (const rtems_rtl_obj* obj,
const char* name, const char* name,
uint32_t flags) uint32_t flags)
{ {
return rtems_rtl_elf_unwind_dw2_parse (obj, name, flags); return rtems_rtl_elf_unwind_dw2_parse (obj, name, flags);
} }
bool bool
rtems_rtl_elf_unwind_register (rtems_rtl_obj_t* obj) rtems_rtl_elf_unwind_register (rtems_rtl_obj* obj)
{ {
return rtems_rtl_elf_unwind_dw2_register (obj); return rtems_rtl_elf_unwind_dw2_register (obj);
} }
bool bool
rtems_rtl_elf_unwind_deregister (rtems_rtl_obj_t* obj) rtems_rtl_elf_unwind_deregister (rtems_rtl_obj* obj)
{ {
return rtems_rtl_elf_unwind_dw2_deregister (obj); return rtems_rtl_elf_unwind_dw2_deregister (obj);
} }

View File

@@ -13,8 +13,8 @@
#include "rtl-unwind-dw2.h" #include "rtl-unwind-dw2.h"
uint32_t uint32_t
rtems_rtl_elf_section_flags (const rtems_rtl_obj_t* obj, rtems_rtl_elf_section_flags (const rtems_rtl_obj* obj,
const Elf_Shdr* shdr) const Elf_Shdr* shdr)
{ {
return 0; return 0;
} }
@@ -26,15 +26,15 @@ rtems_rtl_elf_rel_resolve_sym (Elf_Word type)
} }
bool bool
rtems_rtl_elf_relocate_rela (const rtems_rtl_obj_t* obj, rtems_rtl_elf_relocate_rela (const rtems_rtl_obj* obj,
const Elf_Rela* rela, const Elf_Rela* rela,
const rtems_rtl_obj_sect_t* sect, const rtems_rtl_obj_sect* sect,
const char* symname, const char* symname,
const Elf_Byte syminfo, const Elf_Byte syminfo,
const Elf_Word symvalue) const Elf_Word symvalue)
{ {
Elf_Addr *where; Elf_Addr *where;
Elf_Word tmp; Elf_Word tmp;
where = (Elf_Addr *)(sect->base + rela->r_offset); where = (Elf_Addr *)(sect->base + rela->r_offset);
@@ -98,33 +98,33 @@ rtems_rtl_elf_relocate_rela (const rtems_rtl_obj_t* obj,
} }
bool bool
rtems_rtl_elf_relocate_rel (const rtems_rtl_obj_t* obj, rtems_rtl_elf_relocate_rel (const rtems_rtl_obj* obj,
const Elf_Rel* rel, const Elf_Rel* rel,
const rtems_rtl_obj_sect_t* sect, const rtems_rtl_obj_sect* sect,
const char* symname, const char* symname,
const Elf_Byte syminfo, const Elf_Byte syminfo,
const Elf_Word symvalue) const Elf_Word symvalue)
{ {
rtems_rtl_set_error (EINVAL, "rel type record not supported"); rtems_rtl_set_error (EINVAL, "rel type record not supported");
return false; return false;
} }
bool bool
rtems_rtl_elf_unwind_parse (const rtems_rtl_obj_t* obj, rtems_rtl_elf_unwind_parse (const rtems_rtl_obj* obj,
const char* name, const char* name,
uint32_t flags) uint32_t flags)
{ {
return rtems_rtl_elf_unwind_dw2_parse (obj, name, flags); return rtems_rtl_elf_unwind_dw2_parse (obj, name, flags);
} }
bool bool
rtems_rtl_elf_unwind_register (rtems_rtl_obj_t* obj) rtems_rtl_elf_unwind_register (rtems_rtl_obj* obj)
{ {
return rtems_rtl_elf_unwind_dw2_register (obj); return rtems_rtl_elf_unwind_dw2_register (obj);
} }
bool bool
rtems_rtl_elf_unwind_deregister (rtems_rtl_obj_t* obj) rtems_rtl_elf_unwind_deregister (rtems_rtl_obj* obj)
{ {
return rtems_rtl_elf_unwind_dw2_deregister (obj); return rtems_rtl_elf_unwind_dw2_deregister (obj);
} }

View File

@@ -19,8 +19,8 @@
#include "rtl-unwind-dw2.h" #include "rtl-unwind-dw2.h"
uint32_t uint32_t
rtems_rtl_elf_section_flags (const rtems_rtl_obj_t* obj, rtems_rtl_elf_section_flags (const rtems_rtl_obj* obj,
const Elf_Shdr* shdr) const Elf_Shdr* shdr)
{ {
return 0; return 0;
} }
@@ -32,26 +32,26 @@ rtems_rtl_elf_rel_resolve_sym (Elf_Word type)
} }
bool bool
rtems_rtl_elf_relocate_rela (const rtems_rtl_obj_t* obj, rtems_rtl_elf_relocate_rela (const rtems_rtl_obj* obj,
const Elf_Rela* rel, const Elf_Rela* rel,
const rtems_rtl_obj_sect_t* sect, const rtems_rtl_obj_sect* sect,
const char* symname, const char* symname,
const Elf_Byte syminfo, const Elf_Byte syminfo,
const Elf_Word symvalue) const Elf_Word symvalue)
{ {
rtems_rtl_set_error (EINVAL, "rela type record not supported"); rtems_rtl_set_error (EINVAL, "rela type record not supported");
return false; return false;
} }
bool bool
rtems_rtl_elf_relocate_rel (const rtems_rtl_obj_t* obj, rtems_rtl_elf_relocate_rel (const rtems_rtl_obj* obj,
const Elf_Rel* rel, const Elf_Rel* rel,
const rtems_rtl_obj_sect_t* sect, const rtems_rtl_obj_sect* sect,
const char* symname, const char* symname,
const Elf_Byte syminfo, const Elf_Byte syminfo,
const Elf_Word symvalue) const Elf_Word symvalue)
{ {
Elf_Addr target = 0; Elf_Addr target = 0;
Elf_Addr* where; Elf_Addr* where;
Elf_Addr tmp; Elf_Addr tmp;
@@ -112,21 +112,21 @@ rtems_rtl_elf_relocate_rel (const rtems_rtl_obj_t* obj,
} }
bool bool
rtems_rtl_elf_unwind_parse (const rtems_rtl_obj_t* obj, rtems_rtl_elf_unwind_parse (const rtems_rtl_obj* obj,
const char* name, const char* name,
uint32_t flags) uint32_t flags)
{ {
return rtems_rtl_elf_unwind_dw2_parse (obj, name, flags); return rtems_rtl_elf_unwind_dw2_parse (obj, name, flags);
} }
bool bool
rtems_rtl_elf_unwind_register (rtems_rtl_obj_t* obj) rtems_rtl_elf_unwind_register (rtems_rtl_obj* obj)
{ {
return rtems_rtl_elf_unwind_dw2_register (obj); return rtems_rtl_elf_unwind_dw2_register (obj);
} }
bool bool
rtems_rtl_elf_unwind_deregister (rtems_rtl_obj_t* obj) rtems_rtl_elf_unwind_deregister (rtems_rtl_obj* obj)
{ {
return rtems_rtl_elf_unwind_dw2_deregister (obj); return rtems_rtl_elf_unwind_dw2_deregister (obj);
} }

View File

@@ -13,8 +13,8 @@
#include "rtl-unwind-dw2.h" #include "rtl-unwind-dw2.h"
uint32_t uint32_t
rtems_rtl_elf_section_flags (const rtems_rtl_obj_t* obj, rtems_rtl_elf_section_flags (const rtems_rtl_obj* obj,
const Elf_Shdr* shdr) const Elf_Shdr* shdr)
{ {
return 0; return 0;
} }
@@ -26,12 +26,12 @@ rtems_rtl_elf_rel_resolve_sym (Elf_Word type)
} }
bool bool
rtems_rtl_elf_relocate_rela (const rtems_rtl_obj_t* obj, rtems_rtl_elf_relocate_rela (const rtems_rtl_obj* obj,
const Elf_Rela* rela, const Elf_Rela* rela,
const rtems_rtl_obj_sect_t* sect, const rtems_rtl_obj_sect* sect,
const char* symname, const char* symname,
const Elf_Byte syminfo, const Elf_Byte syminfo,
const Elf_Word symvalue) const Elf_Word symvalue)
{ {
Elf_Addr *where; Elf_Addr *where;
Elf32_Word tmp; Elf32_Word tmp;
@@ -117,33 +117,33 @@ rtems_rtl_elf_relocate_rela (const rtems_rtl_obj_t* obj,
} }
bool bool
rtems_rtl_elf_relocate_rel (const rtems_rtl_obj_t* obj, rtems_rtl_elf_relocate_rel (const rtems_rtl_obj* obj,
const Elf_Rel* rel, const Elf_Rel* rel,
const rtems_rtl_obj_sect_t* sect, const rtems_rtl_obj_sect* sect,
const char* symname, const char* symname,
const Elf_Byte syminfo, const Elf_Byte syminfo,
const Elf_Word symvalue) const Elf_Word symvalue)
{ {
rtems_rtl_set_error (EINVAL, "rela type record not supported"); rtems_rtl_set_error (EINVAL, "rela type record not supported");
return false; return false;
} }
bool bool
rtems_rtl_elf_unwind_parse (const rtems_rtl_obj_t* obj, rtems_rtl_elf_unwind_parse (const rtems_rtl_obj* obj,
const char* name, const char* name,
uint32_t flags) uint32_t flags)
{ {
return rtems_rtl_elf_unwind_dw2_parse (obj, name, flags); return rtems_rtl_elf_unwind_dw2_parse (obj, name, flags);
} }
bool bool
rtems_rtl_elf_unwind_register (rtems_rtl_obj_t* obj) rtems_rtl_elf_unwind_register (rtems_rtl_obj* obj)
{ {
return rtems_rtl_elf_unwind_dw2_register (obj); return rtems_rtl_elf_unwind_dw2_register (obj);
} }
bool bool
rtems_rtl_elf_unwind_deregister (rtems_rtl_obj_t* obj) rtems_rtl_elf_unwind_deregister (rtems_rtl_obj* obj)
{ {
return rtems_rtl_elf_unwind_dw2_deregister (obj); return rtems_rtl_elf_unwind_dw2_deregister (obj);
} }

View File

@@ -33,8 +33,8 @@ static inline int overflow_16_check(int value)
} }
uint32_t uint32_t
rtems_rtl_elf_section_flags (const rtems_rtl_obj_t* obj, rtems_rtl_elf_section_flags (const rtems_rtl_obj* obj,
const Elf_Shdr* shdr) const Elf_Shdr* shdr)
{ {
return 0; return 0;
} }
@@ -46,14 +46,14 @@ rtems_rtl_elf_rel_resolve_sym (Elf_Word type)
} }
bool bool
rtems_rtl_elf_relocate_rela (const rtems_rtl_obj_t* obj, rtems_rtl_elf_relocate_rela (const rtems_rtl_obj* obj,
const Elf_Rela* rela, const Elf_Rela* rela,
const rtems_rtl_obj_sect_t* sect, const rtems_rtl_obj_sect* sect,
const char* symnane, const char* symnane,
const Elf_Byte syminfo, const Elf_Byte syminfo,
const Elf_Word symvalue) const Elf_Word symvalue)
{ {
Elf_Addr target = 0; Elf_Addr target = 0;
Elf_Addr* where; Elf_Addr* where;
Elf_Word tmp; Elf_Word tmp;
@@ -145,33 +145,33 @@ rtems_rtl_elf_relocate_rela (const rtems_rtl_obj_t* obj,
} }
bool bool
rtems_rtl_elf_relocate_rel (const rtems_rtl_obj_t* obj, rtems_rtl_elf_relocate_rel (const rtems_rtl_obj* obj,
const Elf_Rel* rel, const Elf_Rel* rel,
const rtems_rtl_obj_sect_t* sect, const rtems_rtl_obj_sect* sect,
const char* symname, const char* symname,
const Elf_Byte syminfo, const Elf_Byte syminfo,
const Elf_Word symvalue) const Elf_Word symvalue)
{ {
rtems_rtl_set_error (EINVAL, "rel type record not supported"); rtems_rtl_set_error (EINVAL, "rel type record not supported");
return false; return false;
} }
bool bool
rtems_rtl_elf_unwind_parse (const rtems_rtl_obj_t* obj, rtems_rtl_elf_unwind_parse (const rtems_rtl_obj* obj,
const char* name, const char* name,
uint32_t flags) uint32_t flags)
{ {
return rtems_rtl_elf_unwind_dw2_parse (obj, name, flags); return rtems_rtl_elf_unwind_dw2_parse (obj, name, flags);
} }
bool bool
rtems_rtl_elf_unwind_register (rtems_rtl_obj_t* obj) rtems_rtl_elf_unwind_register (rtems_rtl_obj* obj)
{ {
return rtems_rtl_elf_unwind_dw2_register (obj); return rtems_rtl_elf_unwind_dw2_register (obj);
} }
bool bool
rtems_rtl_elf_unwind_deregister (rtems_rtl_obj_t* obj) rtems_rtl_elf_unwind_deregister (rtems_rtl_obj* obj)
{ {
return rtems_rtl_elf_unwind_dw2_deregister (obj); return rtems_rtl_elf_unwind_dw2_deregister (obj);
} }

View File

@@ -13,8 +13,8 @@
#include "rtl-unwind-dw2.h" #include "rtl-unwind-dw2.h"
uint32_t uint32_t
rtems_rtl_elf_section_flags (const rtems_rtl_obj_t* obj, rtems_rtl_elf_section_flags (const rtems_rtl_obj* obj,
const Elf_Shdr* shdr) const Elf_Shdr* shdr)
{ {
return 0; return 0;
} }
@@ -26,12 +26,12 @@ rtems_rtl_elf_rel_resolve_sym (Elf_Word type)
} }
bool bool
rtems_rtl_elf_relocate_rela (const rtems_rtl_obj_t* obj, rtems_rtl_elf_relocate_rela (const rtems_rtl_obj* obj,
const Elf_Rela* rela, const Elf_Rela* rela,
const rtems_rtl_obj_sect_t* sect, const rtems_rtl_obj_sect* sect,
const char* symname, const char* symname,
const Elf_Byte syminfo, const Elf_Byte syminfo,
const Elf_Word symvalue) const Elf_Word symvalue)
{ {
rtems_rtl_set_error (EINVAL, "rela type record not supported"); rtems_rtl_set_error (EINVAL, "rela type record not supported");
return false; return false;
@@ -46,12 +46,12 @@ rtems_rtl_elf_relocate_rela (const rtems_rtl_obj_t* obj,
* just consider symtype here. * just consider symtype here.
*/ */
bool bool
rtems_rtl_elf_relocate_rel (const rtems_rtl_obj_t* obj, rtems_rtl_elf_relocate_rel (const rtems_rtl_obj* obj,
const Elf_Rel* rel, const Elf_Rel* rel,
const rtems_rtl_obj_sect_t* sect, const rtems_rtl_obj_sect* sect,
const char* symname, const char* symname,
const Elf_Byte syminfo, const Elf_Byte syminfo,
const Elf_Word symvalue) const Elf_Word symvalue)
{ {
Elf_Addr *where; Elf_Addr *where;
Elf_Word tmp; Elf_Word tmp;
@@ -199,21 +199,21 @@ rtems_rtl_elf_relocate_rel (const rtems_rtl_obj_t* obj,
} }
bool bool
rtems_rtl_elf_unwind_parse (const rtems_rtl_obj_t* obj, rtems_rtl_elf_unwind_parse (const rtems_rtl_obj* obj,
const char* name, const char* name,
uint32_t flags) uint32_t flags)
{ {
return rtems_rtl_elf_unwind_dw2_parse (obj, name, flags); return rtems_rtl_elf_unwind_dw2_parse (obj, name, flags);
} }
bool bool
rtems_rtl_elf_unwind_register (rtems_rtl_obj_t* obj) rtems_rtl_elf_unwind_register (rtems_rtl_obj* obj)
{ {
return rtems_rtl_elf_unwind_dw2_register (obj); return rtems_rtl_elf_unwind_dw2_register (obj);
} }
bool bool
rtems_rtl_elf_unwind_deregister (rtems_rtl_obj_t* obj) rtems_rtl_elf_unwind_deregister (rtems_rtl_obj* obj)
{ {
return rtems_rtl_elf_unwind_dw2_deregister (obj); return rtems_rtl_elf_unwind_dw2_deregister (obj);
} }

View File

@@ -14,8 +14,8 @@
#include "rtl-unwind-dw2.h" #include "rtl-unwind-dw2.h"
uint32_t uint32_t
rtems_rtl_elf_section_flags (const rtems_rtl_obj_t* obj, rtems_rtl_elf_section_flags (const rtems_rtl_obj* obj,
const Elf_Shdr* shdr) const Elf_Shdr* shdr)
{ {
return 0; return 0;
} }
@@ -27,12 +27,12 @@ rtems_rtl_elf_rel_resolve_sym (Elf_Word type)
} }
bool bool
rtems_rtl_elf_relocate_rela (const rtems_rtl_obj_t* obj, rtems_rtl_elf_relocate_rela (const rtems_rtl_obj* obj,
const Elf_Rela* rela, const Elf_Rela* rela,
const rtems_rtl_obj_sect_t* sect, const rtems_rtl_obj_sect* sect,
const char* symname, const char* symname,
const Elf_Byte syminfo, const Elf_Byte syminfo,
const Elf_Word symvalue) const Elf_Word symvalue)
{ {
Elf_Addr *where; Elf_Addr *where;
Elf_Sword tmp; Elf_Sword tmp;
@@ -85,33 +85,33 @@ rtems_rtl_elf_relocate_rela (const rtems_rtl_obj_t* obj,
} }
bool bool
rtems_rtl_elf_relocate_rel (const rtems_rtl_obj_t* obj, rtems_rtl_elf_relocate_rel (const rtems_rtl_obj* obj,
const Elf_Rel* rel, const Elf_Rel* rel,
const rtems_rtl_obj_sect_t* sect, const rtems_rtl_obj_sect* sect,
const char* symname, const char* symname,
const Elf_Byte syminfo, const Elf_Byte syminfo,
const Elf_Word symvalue) const Elf_Word symvalue)
{ {
rtems_rtl_set_error (EINVAL, "rel type record not supported"); rtems_rtl_set_error (EINVAL, "rel type record not supported");
return false; return false;
} }
bool bool
rtems_rtl_elf_unwind_parse (const rtems_rtl_obj_t* obj, rtems_rtl_elf_unwind_parse (const rtems_rtl_obj* obj,
const char* name, const char* name,
uint32_t flags) uint32_t flags)
{ {
return rtems_rtl_elf_unwind_dw2_parse (obj, name, flags); return rtems_rtl_elf_unwind_dw2_parse (obj, name, flags);
} }
bool bool
rtems_rtl_elf_unwind_register (rtems_rtl_obj_t* obj) rtems_rtl_elf_unwind_register (rtems_rtl_obj* obj)
{ {
return rtems_rtl_elf_unwind_dw2_register (obj); return rtems_rtl_elf_unwind_dw2_register (obj);
} }
bool bool
rtems_rtl_elf_unwind_deregister (rtems_rtl_obj_t* obj) rtems_rtl_elf_unwind_deregister (rtems_rtl_obj* obj)
{ {
return rtems_rtl_elf_unwind_dw2_deregister (obj); return rtems_rtl_elf_unwind_dw2_deregister (obj);
} }

View File

@@ -24,8 +24,8 @@
#define l(x) ((u_int32_t)(x) & 0xffff) #define l(x) ((u_int32_t)(x) & 0xffff)
uint32_t uint32_t
rtems_rtl_elf_section_flags (const rtems_rtl_obj_t* obj, rtems_rtl_elf_section_flags (const rtems_rtl_obj* obj,
const Elf_Shdr* shdr) const Elf_Shdr* shdr)
{ {
return 0; return 0;
} }
@@ -37,12 +37,12 @@ rtems_rtl_elf_rel_resolve_sym (Elf_Word type)
} }
bool bool
rtems_rtl_elf_relocate_rela (const rtems_rtl_obj_t* obj, rtems_rtl_elf_relocate_rela (const rtems_rtl_obj* obj,
const Elf_Rela* rela, const Elf_Rela* rela,
const rtems_rtl_obj_sect_t* sect, const rtems_rtl_obj_sect* sect,
const char* symname, const char* symname,
const Elf_Byte syminfo, const Elf_Byte syminfo,
const Elf_Word symvalue) const Elf_Word symvalue)
{ {
Elf_Addr* where; Elf_Addr* where;
Elf_Word tmp; Elf_Word tmp;
@@ -198,33 +198,33 @@ rtems_rtl_elf_relocate_rela (const rtems_rtl_obj_t* obj,
} }
bool bool
rtems_rtl_elf_relocate_rel (const rtems_rtl_obj_t* obj, rtems_rtl_elf_relocate_rel (const rtems_rtl_obj* obj,
const Elf_Rel* rel, const Elf_Rel* rel,
const rtems_rtl_obj_sect_t* sect, const rtems_rtl_obj_sect* sect,
const char* symname, const char* symname,
const Elf_Byte syminfo, const Elf_Byte syminfo,
const Elf_Word symvalue) const Elf_Word symvalue)
{ {
printf ("rtl: rel type record not supported; please report\n"); printf ("rtl: rel type record not supported; please report\n");
return false; return false;
} }
bool bool
rtems_rtl_elf_unwind_parse (const rtems_rtl_obj_t* obj, rtems_rtl_elf_unwind_parse (const rtems_rtl_obj* obj,
const char* name, const char* name,
uint32_t flags) uint32_t flags)
{ {
return rtems_rtl_elf_unwind_dw2_parse (obj, name, flags); return rtems_rtl_elf_unwind_dw2_parse (obj, name, flags);
} }
bool bool
rtems_rtl_elf_unwind_register (rtems_rtl_obj_t* obj) rtems_rtl_elf_unwind_register (rtems_rtl_obj* obj)
{ {
return rtems_rtl_elf_unwind_dw2_register (obj); return rtems_rtl_elf_unwind_dw2_register (obj);
} }
bool bool
rtems_rtl_elf_unwind_deregister (rtems_rtl_obj_t* obj) rtems_rtl_elf_unwind_deregister (rtems_rtl_obj* obj)
{ {
return rtems_rtl_elf_unwind_dw2_deregister (obj); return rtems_rtl_elf_unwind_dw2_deregister (obj);
} }

View File

@@ -131,8 +131,8 @@ static const int reloc_target_bitmask[] = {
#define RELOC_VALUE_BITMASK(t) (reloc_target_bitmask[t]) #define RELOC_VALUE_BITMASK(t) (reloc_target_bitmask[t])
uint32_t uint32_t
rtems_rtl_elf_section_flags (const rtems_rtl_obj_t* obj, rtems_rtl_elf_section_flags (const rtems_rtl_obj* obj,
const Elf_Shdr* shdr) const Elf_Shdr* shdr)
{ {
return 0; return 0;
} }
@@ -144,12 +144,12 @@ rtems_rtl_elf_rel_resolve_sym (Elf_Word type)
} }
bool bool
rtems_rtl_elf_relocate_rela (const rtems_rtl_obj_t* obj, rtems_rtl_elf_relocate_rela (const rtems_rtl_obj* obj,
const Elf_Rela* rela, const Elf_Rela* rela,
const rtems_rtl_obj_sect_t* sect, const rtems_rtl_obj_sect* sect,
const char* symname, const char* symname,
const Elf_Byte syminfo, const Elf_Byte syminfo,
const Elf_Word symvalue) const Elf_Word symvalue)
{ {
Elf_Addr *where; Elf_Addr *where;
Elf_Word type, value, mask; Elf_Word type, value, mask;
@@ -260,33 +260,33 @@ rtems_rtl_elf_relocate_rela (const rtems_rtl_obj_t* obj,
} }
bool bool
rtems_rtl_elf_relocate_rel (const rtems_rtl_obj_t* obj, rtems_rtl_elf_relocate_rel (const rtems_rtl_obj* obj,
const Elf_Rel* rel, const Elf_Rel* rel,
const rtems_rtl_obj_sect_t* sect, const rtems_rtl_obj_sect* sect,
const char* symname, const char* symname,
const Elf_Byte syminfo, const Elf_Byte syminfo,
const Elf_Word symvalue) const Elf_Word symvalue)
{ {
printf ("rtl: rel type record not supported; please report\n"); printf ("rtl: rel type record not supported; please report\n");
return false; return false;
} }
bool bool
rtems_rtl_elf_unwind_parse (const rtems_rtl_obj_t* obj, rtems_rtl_elf_unwind_parse (const rtems_rtl_obj* obj,
const char* name, const char* name,
uint32_t flags) uint32_t flags)
{ {
return rtems_rtl_elf_unwind_dw2_parse (obj, name, flags); return rtems_rtl_elf_unwind_dw2_parse (obj, name, flags);
} }
bool bool
rtems_rtl_elf_unwind_register (rtems_rtl_obj_t* obj) rtems_rtl_elf_unwind_register (rtems_rtl_obj* obj)
{ {
return rtems_rtl_elf_unwind_dw2_register (obj); return rtems_rtl_elf_unwind_dw2_register (obj);
} }
bool bool
rtems_rtl_elf_unwind_deregister (rtems_rtl_obj_t* obj) rtems_rtl_elf_unwind_deregister (rtems_rtl_obj* obj)
{ {
return rtems_rtl_elf_unwind_dw2_deregister (obj); return rtems_rtl_elf_unwind_dw2_deregister (obj);
} }

View File

@@ -14,8 +14,8 @@
#include "rtl-unwind-dw2.h" #include "rtl-unwind-dw2.h"
uint32_t uint32_t
rtems_rtl_elf_section_flags (const rtems_rtl_obj_t* obj, rtems_rtl_elf_section_flags (const rtems_rtl_obj* obj,
const Elf_Shdr* shdr) const Elf_Shdr* shdr)
{ {
return 0; return 0;
} }
@@ -27,12 +27,12 @@ rtems_rtl_elf_rel_resolve_sym (Elf_Word type)
} }
bool bool
rtems_rtl_elf_relocate_rela (const rtems_rtl_obj_t* obj, rtems_rtl_elf_relocate_rela (const rtems_rtl_obj* obj,
const Elf_Rela* rela, const Elf_Rela* rela,
const rtems_rtl_obj_sect_t* sect, const rtems_rtl_obj_sect* sect,
const char* symname, const char* symname,
const Elf_Byte syminfo, const Elf_Byte syminfo,
const Elf_Word symvalue) const Elf_Word symvalue)
{ {
Elf_Addr *where; Elf_Addr *where;
Elf_Word tmp; Elf_Word tmp;
@@ -94,33 +94,33 @@ rtems_rtl_elf_relocate_rela (const rtems_rtl_obj_t* obj,
} }
bool bool
rtems_rtl_elf_relocate_rel (const rtems_rtl_obj_t* obj, rtems_rtl_elf_relocate_rel (const rtems_rtl_obj* obj,
const Elf_Rel* rel, const Elf_Rel* rel,
const rtems_rtl_obj_sect_t* sect, const rtems_rtl_obj_sect* sect,
const char* symname, const char* symname,
const Elf_Byte syminfo, const Elf_Byte syminfo,
const Elf_Word symvalue) const Elf_Word symvalue)
{ {
rtems_rtl_set_error (EINVAL, "rel type record not supported"); rtems_rtl_set_error (EINVAL, "rel type record not supported");
return false; return false;
} }
bool bool
rtems_rtl_elf_unwind_parse (const rtems_rtl_obj_t* obj, rtems_rtl_elf_unwind_parse (const rtems_rtl_obj* obj,
const char* name, const char* name,
uint32_t flags) uint32_t flags)
{ {
return rtems_rtl_elf_unwind_dw2_parse (obj, name, flags); return rtems_rtl_elf_unwind_dw2_parse (obj, name, flags);
} }
bool bool
rtems_rtl_elf_unwind_register (rtems_rtl_obj_t* obj) rtems_rtl_elf_unwind_register (rtems_rtl_obj* obj)
{ {
return rtems_rtl_elf_unwind_dw2_register (obj); return rtems_rtl_elf_unwind_dw2_register (obj);
} }
bool bool
rtems_rtl_elf_unwind_deregister (rtems_rtl_obj_t* obj) rtems_rtl_elf_unwind_deregister (rtems_rtl_obj* obj)
{ {
return rtems_rtl_elf_unwind_dw2_deregister (obj); return rtems_rtl_elf_unwind_dw2_deregister (obj);
} }

View File

@@ -1,5 +1,5 @@
/* /*
* COPYRIGHT (c) 2012 Chris Johns <chrisj@rtems.org> * COPYRIGHT (c) 2012, 2018 Chris Johns <chrisj@rtems.org>
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at
@@ -31,7 +31,7 @@
#include <rtems/rtl/rtl-trace.h> #include <rtems/rtl/rtl-trace.h>
bool bool
rtems_rtl_obj_cache_open (rtems_rtl_obj_cache_t* cache, size_t size) rtems_rtl_obj_cache_open (rtems_rtl_obj_cache* cache, size_t size)
{ {
cache->fd = -1; cache->fd = -1;
cache->file_size = 0; cache->file_size = 0;
@@ -48,7 +48,7 @@ rtems_rtl_obj_cache_open (rtems_rtl_obj_cache_t* cache, size_t size)
} }
void void
rtems_rtl_obj_cache_close (rtems_rtl_obj_cache_t* cache) rtems_rtl_obj_cache_close (rtems_rtl_obj_cache* cache)
{ {
if (rtems_rtl_trace (RTEMS_RTL_TRACE_CACHE)) if (rtems_rtl_trace (RTEMS_RTL_TRACE_CACHE))
printf ("rtl: cache: %2d: close\n", cache->fd); printf ("rtl: cache: %2d: close\n", cache->fd);
@@ -60,7 +60,7 @@ rtems_rtl_obj_cache_close (rtems_rtl_obj_cache_t* cache)
} }
void void
rtems_rtl_obj_cache_flush (rtems_rtl_obj_cache_t* cache) rtems_rtl_obj_cache_flush (rtems_rtl_obj_cache* cache)
{ {
if (rtems_rtl_trace (RTEMS_RTL_TRACE_CACHE)) if (rtems_rtl_trace (RTEMS_RTL_TRACE_CACHE))
printf ("rtl: cache: %2d: flush\n", cache->fd); printf ("rtl: cache: %2d: flush\n", cache->fd);
@@ -71,11 +71,11 @@ rtems_rtl_obj_cache_flush (rtems_rtl_obj_cache_t* cache)
} }
bool bool
rtems_rtl_obj_cache_read (rtems_rtl_obj_cache_t* cache, rtems_rtl_obj_cache_read (rtems_rtl_obj_cache* cache,
int fd, int fd,
off_t offset, off_t offset,
void** buffer, void** buffer,
size_t* length) size_t* length)
{ {
struct stat sb; struct stat sb;
@@ -238,11 +238,11 @@ rtems_rtl_obj_cache_read (rtems_rtl_obj_cache_t* cache,
} }
bool bool
rtems_rtl_obj_cache_read_byval (rtems_rtl_obj_cache_t* cache, rtems_rtl_obj_cache_read_byval (rtems_rtl_obj_cache* cache,
int fd, int fd,
off_t offset, off_t offset,
void* buffer, void* buffer,
size_t length) size_t length)
{ {
void* cbuffer = 0; void* cbuffer = 0;
size_t len = length; size_t len = length;

View File

@@ -1,5 +1,5 @@
/* /*
* COPYRIGHT (c) 2012 Chris Johns <chrisj@rtems.org> * COPYRIGHT (c) 2012, 2018 Chris Johns <chrisj@rtems.org>
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at
@@ -31,8 +31,8 @@
#include <stdio.h> #include <stdio.h>
bool bool
rtems_rtl_obj_comp_open (rtems_rtl_obj_comp_t* comp, rtems_rtl_obj_comp_open (rtems_rtl_obj_comp* comp,
size_t size) size_t size)
{ {
comp->cache = NULL; comp->cache = NULL;
comp->fd = -1; comp->fd = -1;
@@ -51,7 +51,7 @@ rtems_rtl_obj_comp_open (rtems_rtl_obj_comp_t* comp,
} }
void void
rtems_rtl_obj_comp_close (rtems_rtl_obj_comp_t* comp) rtems_rtl_obj_comp_close (rtems_rtl_obj_comp* comp)
{ {
rtems_rtl_alloc_del (RTEMS_RTL_ALLOC_OBJECT, comp->buffer); rtems_rtl_alloc_del (RTEMS_RTL_ALLOC_OBJECT, comp->buffer);
comp->cache = NULL; comp->cache = NULL;
@@ -64,11 +64,11 @@ rtems_rtl_obj_comp_close (rtems_rtl_obj_comp_t* comp)
} }
void void
rtems_rtl_obj_comp_set (rtems_rtl_obj_comp_t* comp, rtems_rtl_obj_comp_set (rtems_rtl_obj_comp* comp,
rtems_rtl_obj_cache_t* cache, rtems_rtl_obj_cache* cache,
int fd, int fd,
int compression, int compression,
off_t offset) off_t offset)
{ {
comp->cache = cache; comp->cache = cache;
comp->fd = fd; comp->fd = fd;
@@ -79,9 +79,9 @@ rtems_rtl_obj_comp_set (rtems_rtl_obj_comp_t* comp,
} }
bool bool
rtems_rtl_obj_comp_read (rtems_rtl_obj_comp_t* comp, rtems_rtl_obj_comp_read (rtems_rtl_obj_comp* comp,
void* buffer, void* buffer,
size_t length) size_t length)
{ {
uint8_t* bin = buffer; uint8_t* bin = buffer;

View File

@@ -1,5 +1,5 @@
/* /*
* COPYRIGHT (c) 2012 Chris Johns <chrisj@rtems.org> * COPYRIGHT (c) 2012, 2018 Chris Johns <chrisj@rtems.org>
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at
@@ -51,7 +51,7 @@
* The table of supported loader formats. * The table of supported loader formats.
*/ */
#define RTEMS_RTL_LOADERS (RTEMS_RTL_ELF_LOADER_COUNT + RTEMS_RTL_RAP_LOADER_COUNT) #define RTEMS_RTL_LOADERS (RTEMS_RTL_ELF_LOADER_COUNT + RTEMS_RTL_RAP_LOADER_COUNT)
static const rtems_rtl_loader_table_t loaders[RTEMS_RTL_LOADERS] = static const rtems_rtl_loader_table loaders[RTEMS_RTL_LOADERS] =
{ {
#if RTEMS_RTL_RAP_LOADER #if RTEMS_RTL_RAP_LOADER
{ .check = rtems_rtl_rap_file_check, { .check = rtems_rtl_rap_file_check,
@@ -68,12 +68,12 @@ static const rtems_rtl_loader_table_t loaders[RTEMS_RTL_LOADERS] =
#endif #endif
}; };
rtems_rtl_obj_t* rtems_rtl_obj*
rtems_rtl_obj_alloc (void) rtems_rtl_obj_alloc (void)
{ {
rtems_rtl_obj_t* obj = rtems_rtl_alloc_new (RTEMS_RTL_ALLOC_OBJECT, rtems_rtl_obj* obj = rtems_rtl_alloc_new (RTEMS_RTL_ALLOC_OBJECT,
sizeof (rtems_rtl_obj_t), sizeof (rtems_rtl_obj),
true); true);
if (obj) if (obj)
{ {
/* /*
@@ -89,7 +89,7 @@ rtems_rtl_obj_alloc (void)
} }
static void static void
rtems_rtl_obj_free_names (rtems_rtl_obj_t* obj) rtems_rtl_obj_free_names (rtems_rtl_obj* obj)
{ {
if (rtems_rtl_obj_oname_valid (obj)) if (rtems_rtl_obj_oname_valid (obj))
rtems_rtl_alloc_del (RTEMS_RTL_ALLOC_OBJECT, (void*) obj->oname); rtems_rtl_alloc_del (RTEMS_RTL_ALLOC_OBJECT, (void*) obj->oname);
@@ -100,7 +100,7 @@ rtems_rtl_obj_free_names (rtems_rtl_obj_t* obj)
} }
bool bool
rtems_rtl_obj_free (rtems_rtl_obj_t* obj) rtems_rtl_obj_free (rtems_rtl_obj* obj)
{ {
if (obj->users || ((obj->flags & RTEMS_RTL_OBJ_LOCKED) != 0)) if (obj->users || ((obj->flags & RTEMS_RTL_OBJ_LOCKED) != 0))
{ {
@@ -122,7 +122,7 @@ rtems_rtl_obj_free (rtems_rtl_obj_t* obj)
} }
bool bool
rtems_rtl_obj_unresolved (rtems_rtl_obj_t* obj) rtems_rtl_obj_unresolved (rtems_rtl_obj* obj)
{ {
return (obj->flags & RTEMS_RTL_OBJ_UNRESOLVED) != 0 ? true : false; return (obj->flags & RTEMS_RTL_OBJ_UNRESOLVED) != 0 ? true : false;
} }
@@ -208,7 +208,7 @@ rtems_rtl_parse_name (const char* name,
} }
static bool static bool
rtems_rtl_obj_parse_name (rtems_rtl_obj_t* obj, const char* name) rtems_rtl_obj_parse_name (rtems_rtl_obj* obj, const char* name)
{ {
return rtems_rtl_parse_name (name, &(obj->aname), &(obj->oname), &(obj->ooffset)); return rtems_rtl_parse_name (name, &(obj->aname), &(obj->oname), &(obj->ooffset));
} }
@@ -262,13 +262,13 @@ typedef struct
{ {
uint32_t mask; /**< The selection mask to sum. */ uint32_t mask; /**< The selection mask to sum. */
size_t size; /**< The size of all section fragments. */ size_t size; /**< The size of all section fragments. */
} rtems_rtl_obj_sect_summer_t; } rtems_rtl_obj_sect_summer_data;
static bool static bool
rtems_rtl_obj_sect_summer (rtems_chain_node* node, void* data) rtems_rtl_obj_sect_summer (rtems_chain_node* node, void* data)
{ {
rtems_rtl_obj_sect_t* sect = (rtems_rtl_obj_sect_t*) node; rtems_rtl_obj_sect* sect = (rtems_rtl_obj_sect*) node;
rtems_rtl_obj_sect_summer_t* summer = data; rtems_rtl_obj_sect_summer_data* summer = data;
if ((sect->flags & summer->mask) == summer->mask) if ((sect->flags & summer->mask) == summer->mask)
summer->size = summer->size =
rtems_rtl_sect_align (summer->size, sect->alignment) + sect->size; rtems_rtl_sect_align (summer->size, sect->alignment) + sect->size;
@@ -276,9 +276,9 @@ rtems_rtl_obj_sect_summer (rtems_chain_node* node, void* data)
} }
static size_t static size_t
rtems_rtl_obj_section_size (const rtems_rtl_obj_t* obj, uint32_t mask) rtems_rtl_obj_section_size (const rtems_rtl_obj* obj, uint32_t mask)
{ {
rtems_rtl_obj_sect_summer_t summer; rtems_rtl_obj_sect_summer_data summer;
summer.mask = mask; summer.mask = mask;
summer.size = 0; summer.size = 0;
rtems_rtl_chain_iterate ((rtems_chain_control*) &obj->sections, rtems_rtl_chain_iterate ((rtems_chain_control*) &obj->sections,
@@ -295,7 +295,7 @@ typedef struct
{ {
uint32_t mask; /**< The selection mask to look for alignment. */ uint32_t mask; /**< The selection mask to look for alignment. */
uint32_t alignment; /**< The alignment of the section type. */ uint32_t alignment; /**< The alignment of the section type. */
} rtems_rtl_obj_sect_aligner_t; } rtems_rtl_obj_sect_aligner_data;
/** /**
* The section aligner iterator. * The section aligner iterator.
@@ -303,8 +303,8 @@ typedef struct
static bool static bool
rtems_rtl_obj_sect_aligner (rtems_chain_node* node, void* data) rtems_rtl_obj_sect_aligner (rtems_chain_node* node, void* data)
{ {
rtems_rtl_obj_sect_t* sect = (rtems_rtl_obj_sect_t*) node; rtems_rtl_obj_sect* sect = (rtems_rtl_obj_sect*) node;
rtems_rtl_obj_sect_aligner_t* aligner = data; rtems_rtl_obj_sect_aligner_data* aligner = data;
if ((sect->flags & aligner->mask) == aligner->mask) if ((sect->flags & aligner->mask) == aligner->mask)
{ {
aligner->alignment = sect->alignment; aligner->alignment = sect->alignment;
@@ -314,9 +314,9 @@ rtems_rtl_obj_sect_aligner (rtems_chain_node* node, void* data)
} }
static size_t static size_t
rtems_rtl_obj_section_alignment (const rtems_rtl_obj_t* obj, uint32_t mask) rtems_rtl_obj_section_alignment (const rtems_rtl_obj* obj, uint32_t mask)
{ {
rtems_rtl_obj_sect_aligner_t aligner; rtems_rtl_obj_sect_aligner_data aligner;
aligner.mask = mask; aligner.mask = mask;
aligner.alignment = 0; aligner.alignment = 0;
rtems_rtl_chain_iterate ((rtems_chain_control*) &obj->sections, rtems_rtl_chain_iterate ((rtems_chain_control*) &obj->sections,
@@ -326,16 +326,16 @@ rtems_rtl_obj_section_alignment (const rtems_rtl_obj_t* obj, uint32_t mask)
} }
static bool static bool
rtems_rtl_obj_section_handler (uint32_t mask, rtems_rtl_obj_section_handler (uint32_t mask,
rtems_rtl_obj_t* obj, rtems_rtl_obj* obj,
int fd, int fd,
rtems_rtl_obj_sect_handler_t handler, rtems_rtl_obj_sect_handler handler,
void* data) void* data)
{ {
rtems_chain_node* node = rtems_chain_first (&obj->sections); rtems_chain_node* node = rtems_chain_first (&obj->sections);
while (!rtems_chain_is_tail (&obj->sections, node)) while (!rtems_chain_is_tail (&obj->sections, node))
{ {
rtems_rtl_obj_sect_t* sect = (rtems_rtl_obj_sect_t*) node; rtems_rtl_obj_sect* sect = (rtems_rtl_obj_sect*) node;
if ((sect->flags & mask) != 0) if ((sect->flags & mask) != 0)
{ {
if (!handler (obj, fd, sect, data)) if (!handler (obj, fd, sect, data))
@@ -347,7 +347,7 @@ rtems_rtl_obj_section_handler (uint32_t mask,
} }
bool bool
rtems_rtl_match_name (rtems_rtl_obj_t* obj, const char* name) rtems_rtl_match_name (rtems_rtl_obj* obj, const char* name)
{ {
const char* n1 = obj->oname; const char* n1 = obj->oname;
while ((*n1 != '\0') && (*n1 != '\n') && (*n1 != '/') && while ((*n1 != '\0') && (*n1 != '\n') && (*n1 != '/') &&
@@ -363,10 +363,10 @@ rtems_rtl_match_name (rtems_rtl_obj_t* obj, const char* name)
} }
bool bool
rtems_rtl_obj_find_file (rtems_rtl_obj_t* obj, const char* name) rtems_rtl_obj_find_file (rtems_rtl_obj* obj, const char* name)
{ {
const char* pname; const char* pname;
rtems_rtl_data_t* rtl; rtems_rtl_data* rtl;
/* /*
* Parse the name. The object descriptor will have the archive name and/or * Parse the name. The object descriptor will have the archive name and/or
@@ -403,21 +403,21 @@ rtems_rtl_obj_find_file (rtems_rtl_obj_t* obj, const char* name)
} }
bool bool
rtems_rtl_obj_add_section (rtems_rtl_obj_t* obj, rtems_rtl_obj_add_section (rtems_rtl_obj* obj,
int section, int section,
const char* name, const char* name,
size_t size, size_t size,
off_t offset, off_t offset,
uint32_t alignment, uint32_t alignment,
int link, int link,
int info, int info,
uint32_t flags) uint32_t flags)
{ {
if (size > 0) if (size > 0)
{ {
rtems_rtl_obj_sect_t* sect = rtems_rtl_alloc_new (RTEMS_RTL_ALLOC_OBJECT, rtems_rtl_obj_sect* sect = rtems_rtl_alloc_new (RTEMS_RTL_ALLOC_OBJECT,
sizeof (rtems_rtl_obj_sect_t), sizeof (rtems_rtl_obj_sect),
true); true);
if (!sect) if (!sect)
{ {
rtems_rtl_set_error (ENOMEM, "adding allocated section"); rtems_rtl_set_error (ENOMEM, "adding allocated section");
@@ -442,13 +442,13 @@ rtems_rtl_obj_add_section (rtems_rtl_obj_t* obj,
} }
void void
rtems_rtl_obj_erase_sections (rtems_rtl_obj_t* obj) rtems_rtl_obj_erase_sections (rtems_rtl_obj* obj)
{ {
rtems_chain_node* node = rtems_chain_first (&obj->sections); rtems_chain_node* node = rtems_chain_first (&obj->sections);
while (!rtems_chain_is_tail (&obj->sections, node)) while (!rtems_chain_is_tail (&obj->sections, node))
{ {
rtems_rtl_obj_sect_t* sect = (rtems_rtl_obj_sect_t*) node; rtems_rtl_obj_sect* sect = (rtems_rtl_obj_sect*) node;
rtems_chain_node* next_node = rtems_chain_next (node); rtems_chain_node* next_node = rtems_chain_next (node);
rtems_chain_extract (node); rtems_chain_extract (node);
rtems_rtl_alloc_del (RTEMS_RTL_ALLOC_OBJECT, (void*) sect->name); rtems_rtl_alloc_del (RTEMS_RTL_ALLOC_OBJECT, (void*) sect->name);
rtems_rtl_alloc_del (RTEMS_RTL_ALLOC_OBJECT, sect); rtems_rtl_alloc_del (RTEMS_RTL_ALLOC_OBJECT, sect);
@@ -461,16 +461,16 @@ rtems_rtl_obj_erase_sections (rtems_rtl_obj_t* obj)
*/ */
typedef struct typedef struct
{ {
rtems_rtl_obj_sect_t* sect; /**< The matching section. */ rtems_rtl_obj_sect* sect; /**< The matching section. */
const char* name; /**< The name to match. */ const char* name; /**< The name to match. */
int index; /**< The index to match. */ int index; /**< The index to match. */
} rtems_rtl_obj_sect_finder_t; } rtems_rtl_obj_sect_finder;
static bool static bool
rtems_rtl_obj_sect_match_name (rtems_chain_node* node, void* data) rtems_rtl_obj_sect_match_name (rtems_chain_node* node, void* data)
{ {
rtems_rtl_obj_sect_t* sect = (rtems_rtl_obj_sect_t*) node; rtems_rtl_obj_sect* sect = (rtems_rtl_obj_sect*) node;
rtems_rtl_obj_sect_finder_t* match = data; rtems_rtl_obj_sect_finder* match = data;
if (strcmp (sect->name, match->name) == 0) if (strcmp (sect->name, match->name) == 0)
{ {
match->sect = sect; match->sect = sect;
@@ -479,11 +479,11 @@ rtems_rtl_obj_sect_match_name (rtems_chain_node* node, void* data)
return true; return true;
} }
rtems_rtl_obj_sect_t* rtems_rtl_obj_sect*
rtems_rtl_obj_find_section (const rtems_rtl_obj_t* obj, rtems_rtl_obj_find_section (const rtems_rtl_obj* obj,
const char* name) const char* name)
{ {
rtems_rtl_obj_sect_finder_t match; rtems_rtl_obj_sect_finder match;
match.sect = NULL; match.sect = NULL;
match.name = name; match.name = name;
rtems_rtl_chain_iterate ((rtems_chain_control*) &obj->sections, rtems_rtl_chain_iterate ((rtems_chain_control*) &obj->sections,
@@ -495,8 +495,8 @@ rtems_rtl_obj_find_section (const rtems_rtl_obj_t* obj,
static bool static bool
rtems_rtl_obj_sect_match_index (rtems_chain_node* node, void* data) rtems_rtl_obj_sect_match_index (rtems_chain_node* node, void* data)
{ {
rtems_rtl_obj_sect_t* sect = (rtems_rtl_obj_sect_t*) node; rtems_rtl_obj_sect* sect = (rtems_rtl_obj_sect*) node;
rtems_rtl_obj_sect_finder_t* match = data; rtems_rtl_obj_sect_finder* match = data;
if (sect->section == match->index) if (sect->section == match->index)
{ {
match->sect = sect; match->sect = sect;
@@ -505,11 +505,11 @@ rtems_rtl_obj_sect_match_index (rtems_chain_node* node, void* data)
return true; return true;
} }
rtems_rtl_obj_sect_t* rtems_rtl_obj_sect*
rtems_rtl_obj_find_section_by_index (const rtems_rtl_obj_t* obj, rtems_rtl_obj_find_section_by_index (const rtems_rtl_obj* obj,
int index) int index)
{ {
rtems_rtl_obj_sect_finder_t match; rtems_rtl_obj_sect_finder match;
match.sect = NULL; match.sect = NULL;
match.index = index; match.index = index;
rtems_rtl_chain_iterate ((rtems_chain_control*) &obj->sections, rtems_rtl_chain_iterate ((rtems_chain_control*) &obj->sections,
@@ -519,70 +519,70 @@ rtems_rtl_obj_find_section_by_index (const rtems_rtl_obj_t* obj,
} }
size_t size_t
rtems_rtl_obj_text_size (const rtems_rtl_obj_t* obj) rtems_rtl_obj_text_size (const rtems_rtl_obj* obj)
{ {
return rtems_rtl_obj_section_size (obj, RTEMS_RTL_OBJ_SECT_TEXT); return rtems_rtl_obj_section_size (obj, RTEMS_RTL_OBJ_SECT_TEXT);
} }
uint32_t uint32_t
rtems_rtl_obj_text_alignment (const rtems_rtl_obj_t* obj) rtems_rtl_obj_text_alignment (const rtems_rtl_obj* obj)
{ {
return rtems_rtl_obj_section_alignment (obj, RTEMS_RTL_OBJ_SECT_TEXT); return rtems_rtl_obj_section_alignment (obj, RTEMS_RTL_OBJ_SECT_TEXT);
} }
size_t size_t
rtems_rtl_obj_const_size (const rtems_rtl_obj_t* obj) rtems_rtl_obj_const_size (const rtems_rtl_obj* obj)
{ {
return rtems_rtl_obj_section_size (obj, RTEMS_RTL_OBJ_SECT_CONST); return rtems_rtl_obj_section_size (obj, RTEMS_RTL_OBJ_SECT_CONST);
} }
uint32_t uint32_t
rtems_rtl_obj_eh_alignment (const rtems_rtl_obj_t* obj) rtems_rtl_obj_eh_alignment (const rtems_rtl_obj* obj)
{ {
return rtems_rtl_obj_section_alignment (obj, RTEMS_RTL_OBJ_SECT_EH); return rtems_rtl_obj_section_alignment (obj, RTEMS_RTL_OBJ_SECT_EH);
} }
size_t size_t
rtems_rtl_obj_eh_size (const rtems_rtl_obj_t* obj) rtems_rtl_obj_eh_size (const rtems_rtl_obj* obj)
{ {
return rtems_rtl_obj_section_size (obj, RTEMS_RTL_OBJ_SECT_EH); return rtems_rtl_obj_section_size (obj, RTEMS_RTL_OBJ_SECT_EH);
} }
uint32_t uint32_t
rtems_rtl_obj_const_alignment (const rtems_rtl_obj_t* obj) rtems_rtl_obj_const_alignment (const rtems_rtl_obj* obj)
{ {
return rtems_rtl_obj_section_alignment (obj, RTEMS_RTL_OBJ_SECT_CONST); return rtems_rtl_obj_section_alignment (obj, RTEMS_RTL_OBJ_SECT_CONST);
} }
size_t size_t
rtems_rtl_obj_data_size (const rtems_rtl_obj_t* obj) rtems_rtl_obj_data_size (const rtems_rtl_obj* obj)
{ {
return rtems_rtl_obj_section_size (obj, RTEMS_RTL_OBJ_SECT_DATA); return rtems_rtl_obj_section_size (obj, RTEMS_RTL_OBJ_SECT_DATA);
} }
uint32_t uint32_t
rtems_rtl_obj_data_alignment (const rtems_rtl_obj_t* obj) rtems_rtl_obj_data_alignment (const rtems_rtl_obj* obj)
{ {
return rtems_rtl_obj_section_alignment (obj, RTEMS_RTL_OBJ_SECT_DATA); return rtems_rtl_obj_section_alignment (obj, RTEMS_RTL_OBJ_SECT_DATA);
} }
size_t size_t
rtems_rtl_obj_bss_size (const rtems_rtl_obj_t* obj) rtems_rtl_obj_bss_size (const rtems_rtl_obj* obj)
{ {
return rtems_rtl_obj_section_size (obj, RTEMS_RTL_OBJ_SECT_BSS); return rtems_rtl_obj_section_size (obj, RTEMS_RTL_OBJ_SECT_BSS);
} }
uint32_t uint32_t
rtems_rtl_obj_bss_alignment (const rtems_rtl_obj_t* obj) rtems_rtl_obj_bss_alignment (const rtems_rtl_obj* obj)
{ {
return rtems_rtl_obj_section_alignment (obj, RTEMS_RTL_OBJ_SECT_BSS); return rtems_rtl_obj_section_alignment (obj, RTEMS_RTL_OBJ_SECT_BSS);
} }
bool bool
rtems_rtl_obj_relocate (rtems_rtl_obj_t* obj, rtems_rtl_obj_relocate (rtems_rtl_obj* obj,
int fd, int fd,
rtems_rtl_obj_sect_handler_t handler, rtems_rtl_obj_sect_handler handler,
void* data) void* data)
{ {
uint32_t mask = RTEMS_RTL_OBJ_SECT_REL | RTEMS_RTL_OBJ_SECT_RELA; uint32_t mask = RTEMS_RTL_OBJ_SECT_REL | RTEMS_RTL_OBJ_SECT_RELA;
return rtems_rtl_obj_section_handler (mask, obj, fd, handler, data); return rtems_rtl_obj_section_handler (mask, obj, fd, handler, data);
@@ -597,15 +597,15 @@ typedef struct
void *start_va; void *start_va;
void *end_va; void *end_va;
size_t cache_line_size; size_t cache_line_size;
} rtems_rtl_obj_sect_sync_ctx_t; } rtems_rtl_obj_sect_sync_ctx;
static bool static bool
rtems_rtl_obj_sect_sync_handler (rtems_chain_node* node, void* data) rtems_rtl_obj_sect_sync_handler (rtems_chain_node* node, void* data)
{ {
rtems_rtl_obj_sect_t* sect = (rtems_rtl_obj_sect_t*) node; rtems_rtl_obj_sect* sect = (rtems_rtl_obj_sect*) node;
rtems_rtl_obj_sect_sync_ctx_t* sync_ctx = data; rtems_rtl_obj_sect_sync_ctx* sync_ctx = data;
uintptr_t old_end; uintptr_t old_end;
uintptr_t new_start; uintptr_t new_start;
if ((sect->flags & sync_ctx->mask) == 0 || sect->size == 0) if ((sect->flags & sync_ctx->mask) == 0 || sect->size == 0)
return true; return true;
@@ -633,9 +633,9 @@ rtems_rtl_obj_sect_sync_handler (rtems_chain_node* node, void* data)
} }
void void
rtems_rtl_obj_synchronize_cache (rtems_rtl_obj_t* obj) rtems_rtl_obj_synchronize_cache (rtems_rtl_obj* obj)
{ {
rtems_rtl_obj_sect_sync_ctx_t sync_ctx; rtems_rtl_obj_sect_sync_ctx sync_ctx;
if (rtems_cache_get_instruction_line_size() == 0) if (rtems_cache_get_instruction_line_size() == 0)
return; return;
@@ -659,19 +659,19 @@ rtems_rtl_obj_synchronize_cache (rtems_rtl_obj_t* obj)
} }
bool bool
rtems_rtl_obj_load_symbols (rtems_rtl_obj_t* obj, rtems_rtl_obj_load_symbols (rtems_rtl_obj* obj,
int fd, int fd,
rtems_rtl_obj_sect_handler_t handler, rtems_rtl_obj_sect_handler handler,
void* data) void* data)
{ {
uint32_t mask = RTEMS_RTL_OBJ_SECT_SYM; uint32_t mask = RTEMS_RTL_OBJ_SECT_SYM;
return rtems_rtl_obj_section_handler (mask, obj, fd, handler, data); return rtems_rtl_obj_section_handler (mask, obj, fd, handler, data);
} }
static int static int
rtems_rtl_obj_sections_linked_to_order (rtems_rtl_obj_t* obj, rtems_rtl_obj_sections_linked_to_order (rtems_rtl_obj* obj,
int section, int section,
uint32_t visited_mask) uint32_t visited_mask)
{ {
rtems_chain_control* sections = &obj->sections; rtems_chain_control* sections = &obj->sections;
rtems_chain_node* node = rtems_chain_first (sections); rtems_chain_node* node = rtems_chain_first (sections);
@@ -681,7 +681,7 @@ rtems_rtl_obj_sections_linked_to_order (rtems_rtl_obj_t* obj,
*/ */
while (!rtems_chain_is_tail (sections, node)) while (!rtems_chain_is_tail (sections, node))
{ {
rtems_rtl_obj_sect_t* sect = (rtems_rtl_obj_sect_t*) node; rtems_rtl_obj_sect* sect = (rtems_rtl_obj_sect*) node;
if (sect->section == section) if (sect->section == section)
{ {
const uint32_t mask = sect->flags & RTEMS_RTL_OBJ_SECT_TYPES; const uint32_t mask = sect->flags & RTEMS_RTL_OBJ_SECT_TYPES;
@@ -704,7 +704,7 @@ rtems_rtl_obj_sections_linked_to_order (rtems_rtl_obj_t* obj,
node = rtems_chain_first (sections); node = rtems_chain_first (sections);
while (!rtems_chain_is_tail (sections, node)) while (!rtems_chain_is_tail (sections, node))
{ {
sect = (rtems_rtl_obj_sect_t*) node; sect = (rtems_rtl_obj_sect*) node;
if ((sect->flags & mask) == mask) if ((sect->flags & mask) == mask)
{ {
if (sect->section == section) if (sect->section == section)
@@ -721,14 +721,14 @@ rtems_rtl_obj_sections_linked_to_order (rtems_rtl_obj_t* obj,
} }
static void static void
rtems_rtl_obj_sections_link_order (uint32_t mask, rtems_rtl_obj_t* obj) rtems_rtl_obj_sections_link_order (uint32_t mask, rtems_rtl_obj* obj)
{ {
rtems_chain_control* sections = &obj->sections; rtems_chain_control* sections = &obj->sections;
rtems_chain_node* node = rtems_chain_first (sections); rtems_chain_node* node = rtems_chain_first (sections);
int order = 0; int order = 0;
while (!rtems_chain_is_tail (sections, node)) while (!rtems_chain_is_tail (sections, node))
{ {
rtems_rtl_obj_sect_t* sect = (rtems_rtl_obj_sect_t*) node; rtems_rtl_obj_sect* sect = (rtems_rtl_obj_sect*) node;
if ((sect->flags & mask) == mask) if ((sect->flags & mask) == mask)
{ {
/* /*
@@ -750,12 +750,12 @@ rtems_rtl_obj_sections_link_order (uint32_t mask, rtems_rtl_obj_t* obj)
} }
static size_t static size_t
rtems_rtl_obj_sections_loader (uint32_t mask, rtems_rtl_obj_sections_loader (uint32_t mask,
rtems_rtl_obj_t* obj, rtems_rtl_obj* obj,
int fd, int fd,
uint8_t* base, uint8_t* base,
rtems_rtl_obj_sect_handler_t handler, rtems_rtl_obj_sect_handler handler,
void* data) void* data)
{ {
rtems_chain_control* sections = &obj->sections; rtems_chain_control* sections = &obj->sections;
rtems_chain_node* node = rtems_chain_first (sections); rtems_chain_node* node = rtems_chain_first (sections);
@@ -765,7 +765,7 @@ rtems_rtl_obj_sections_loader (uint32_t mask,
while (!rtems_chain_is_tail (sections, node)) while (!rtems_chain_is_tail (sections, node))
{ {
rtems_rtl_obj_sect_t* sect = (rtems_rtl_obj_sect_t*) node; rtems_rtl_obj_sect* sect = (rtems_rtl_obj_sect*) node;
if ((sect->size != 0) && ((sect->flags & mask) != 0)) if ((sect->size != 0) && ((sect->flags & mask) != 0))
{ {
@@ -819,10 +819,10 @@ rtems_rtl_obj_sections_loader (uint32_t mask,
} }
bool bool
rtems_rtl_obj_load_sections (rtems_rtl_obj_t* obj, rtems_rtl_obj_load_sections (rtems_rtl_obj* obj,
int fd, int fd,
rtems_rtl_obj_sect_handler_t handler, rtems_rtl_obj_sect_handler handler,
void* data) void* data)
{ {
size_t text_size; size_t text_size;
size_t const_size; size_t const_size;
@@ -907,17 +907,17 @@ rtems_rtl_obj_load_sections (rtems_rtl_obj_t* obj,
} }
static void static void
rtems_rtl_obj_run_cdtors (rtems_rtl_obj_t* obj, uint32_t mask) rtems_rtl_obj_run_cdtors (rtems_rtl_obj* obj, uint32_t mask)
{ {
rtems_chain_node* node = rtems_chain_first (&obj->sections); rtems_chain_node* node = rtems_chain_first (&obj->sections);
while (!rtems_chain_is_tail (&obj->sections, node)) while (!rtems_chain_is_tail (&obj->sections, node))
{ {
rtems_rtl_obj_sect_t* sect = (rtems_rtl_obj_sect_t*) node; rtems_rtl_obj_sect* sect = (rtems_rtl_obj_sect*) node;
if ((sect->flags & mask) == mask) if ((sect->flags & mask) == mask)
{ {
rtems_rtl_cdtor_t* handler; rtems_rtl_cdtor* handler;
size_t handlers = sect->size / sizeof (rtems_rtl_cdtor_t); size_t handlers = sect->size / sizeof (rtems_rtl_cdtor);
int c; int c;
for (c = 0, handler = sect->base; c < handlers; ++c) for (c = 0, handler = sect->base; c < handlers; ++c)
if (*handler) if (*handler)
(*handler) (); (*handler) ();
@@ -927,13 +927,13 @@ rtems_rtl_obj_run_cdtors (rtems_rtl_obj_t* obj, uint32_t mask)
} }
void void
rtems_rtl_obj_run_ctors (rtems_rtl_obj_t* obj) rtems_rtl_obj_run_ctors (rtems_rtl_obj* obj)
{ {
return rtems_rtl_obj_run_cdtors (obj, RTEMS_RTL_OBJ_SECT_CTOR); return rtems_rtl_obj_run_cdtors (obj, RTEMS_RTL_OBJ_SECT_CTOR);
} }
void void
rtems_rtl_obj_run_dtors (rtems_rtl_obj_t* obj) rtems_rtl_obj_run_dtors (rtems_rtl_obj* obj)
{ {
return rtems_rtl_obj_run_cdtors (obj, RTEMS_RTL_OBJ_SECT_DTOR); return rtems_rtl_obj_run_cdtors (obj, RTEMS_RTL_OBJ_SECT_DTOR);
} }
@@ -943,7 +943,7 @@ rtems_rtl_obj_run_dtors (rtems_rtl_obj_t* obj)
* object descriptor. * object descriptor.
*/ */
static bool static bool
rtems_rtl_obj_archive_find (rtems_rtl_obj_t* obj, int fd) rtems_rtl_obj_archive_find (rtems_rtl_obj* obj, int fd)
{ {
#define RTEMS_RTL_AR_IDENT "!<arch>\n" #define RTEMS_RTL_AR_IDENT "!<arch>\n"
#define RTEMS_RTL_AR_IDENT_SIZE (sizeof (RTEMS_RTL_AR_IDENT) - 1) #define RTEMS_RTL_AR_IDENT_SIZE (sizeof (RTEMS_RTL_AR_IDENT) - 1)
@@ -1167,11 +1167,11 @@ rtems_rtl_obj_archive_find (rtems_rtl_obj_t* obj, int fd)
} }
static bool static bool
rtems_rtl_obj_file_load (rtems_rtl_obj_t* obj, int fd) rtems_rtl_obj_file_load (rtems_rtl_obj* obj, int fd)
{ {
int l; int l;
for (l = 0; l < (sizeof (loaders) / sizeof (rtems_rtl_loader_table_t)); ++l) for (l = 0; l < (sizeof (loaders) / sizeof (rtems_rtl_loader_table)); ++l)
{ {
if (loaders[l].check (obj, fd)) if (loaders[l].check (obj, fd))
{ {
@@ -1185,7 +1185,7 @@ rtems_rtl_obj_file_load (rtems_rtl_obj_t* obj, int fd)
} }
static bool static bool
rtems_rtl_obj_file_unload (rtems_rtl_obj_t* obj) rtems_rtl_obj_file_unload (rtems_rtl_obj* obj)
{ {
if (obj->format >= 0 && obj->format < RTEMS_RTL_LOADERS) if (obj->format >= 0 && obj->format < RTEMS_RTL_LOADERS)
return loaders[obj->format].unload (obj); return loaders[obj->format].unload (obj);
@@ -1193,7 +1193,7 @@ rtems_rtl_obj_file_unload (rtems_rtl_obj_t* obj)
} }
bool bool
rtems_rtl_obj_load (rtems_rtl_obj_t* obj) rtems_rtl_obj_load (rtems_rtl_obj* obj)
{ {
int fd; int fd;
@@ -1244,7 +1244,7 @@ rtems_rtl_obj_load (rtems_rtl_obj_t* obj)
} }
bool bool
rtems_rtl_obj_unload (rtems_rtl_obj_t* obj) rtems_rtl_obj_unload (rtems_rtl_obj* obj)
{ {
_rtld_linkmap_delete(obj); _rtld_linkmap_delete(obj);
rtems_rtl_obj_file_unload (obj); rtems_rtl_obj_file_unload (obj);

View File

@@ -1,5 +1,5 @@
/* /*
* COPYRIGHT (c) 2012-2013 Chris Johns <chrisj@rtems.org> * COPYRIGHT (c) 2012-2013, 2018 Chris Johns <chrisj@rtems.org>
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at
@@ -45,7 +45,7 @@
/** /**
* The ELF format signature. * The ELF format signature.
*/ */
static rtems_rtl_loader_format_t rap_sig = static rtems_rtl_loader_format rap_sig =
{ {
.label = "RAP", .label = "RAP",
.flags = RTEMS_RTL_FMT_COMP .flags = RTEMS_RTL_FMT_COMP
@@ -54,11 +54,11 @@ static rtems_rtl_loader_format_t rap_sig =
/** /**
* The section definitions found in a RAP file. * The section definitions found in a RAP file.
*/ */
typedef struct rtems_rtl_rap_sectdef_s typedef struct rtems_rtl_rap_sectdef
{ {
const char* name; /**< Name of the section. */ const char* name; /**< Name of the section. */
const uint32_t flags; /**< Section flags. */ const uint32_t flags; /**< Section flags. */
} rtems_rtl_rap_sectdef_t; } rtems_rtl_rap_sectdef;
/** /**
* The section indexes. These are fixed. * The section indexes. These are fixed.
@@ -74,7 +74,7 @@ typedef struct rtems_rtl_rap_sectdef_s
/** /**
* The sections as loaded from a RAP file. * The sections as loaded from a RAP file.
*/ */
static const rtems_rtl_rap_sectdef_t rap_sections[RTEMS_RTL_RAP_SECS] = static const rtems_rtl_rap_sectdef rap_sections[RTEMS_RTL_RAP_SECS] =
{ {
{ ".text", RTEMS_RTL_OBJ_SECT_TEXT | RTEMS_RTL_OBJ_SECT_LOAD }, { ".text", RTEMS_RTL_OBJ_SECT_TEXT | RTEMS_RTL_OBJ_SECT_LOAD },
{ ".const", RTEMS_RTL_OBJ_SECT_CONST | RTEMS_RTL_OBJ_SECT_LOAD }, { ".const", RTEMS_RTL_OBJ_SECT_CONST | RTEMS_RTL_OBJ_SECT_LOAD },
@@ -87,38 +87,38 @@ static const rtems_rtl_rap_sectdef_t rap_sections[RTEMS_RTL_RAP_SECS] =
/** /**
* The section definitions found in a RAP file. * The section definitions found in a RAP file.
*/ */
typedef struct rtems_rtl_rap_section_s typedef struct rtems_rtl_rap_section
{ {
uint32_t size; /**< The size of the section. */ uint32_t size; /**< The size of the section. */
uint32_t alignment; /**< The alignment of the section. */ uint32_t alignment; /**< The alignment of the section. */
} rtems_rtl_rap_section_t; } rtems_rtl_rap_section;
/** /**
* The RAP loader. * The RAP loader.
*/ */
typedef struct rtems_rtl_rap_s typedef struct rtems_rtl_rap
{ {
rtems_rtl_obj_cache_t* file; /**< The file cache for the RAP file. */ rtems_rtl_obj_cache* file; /**< The file cache for the RAP file. */
rtems_rtl_obj_comp_t* decomp; /**< The decompression streamer. */ rtems_rtl_obj_comp* decomp; /**< The decompression streamer. */
uint32_t length; /**< The file length. */ uint32_t length; /**< The file length. */
uint32_t version; /**< The RAP file version. */ uint32_t version; /**< The RAP file version. */
uint32_t compression; /**< The type of compression. */ uint32_t compression; /**< The type of compression. */
uint32_t checksum; /**< The checksum. */ uint32_t checksum; /**< The checksum. */
uint32_t machinetype; /**< The ELF machine type. */ uint32_t machinetype; /**< The ELF machine type. */
uint32_t datatype; /**< The ELF data type. */ uint32_t datatype; /**< The ELF data type. */
uint32_t class; /**< The ELF class. */ uint32_t class; /**< The ELF class. */
uint32_t init; /**< The initialisation strtab offset. */ uint32_t init; /**< The initialisation strtab offset. */
uint32_t fini; /**< The finish strtab offset. */ uint32_t fini; /**< The finish strtab offset. */
rtems_rtl_rap_section_t secs[RTEMS_RTL_RAP_SECS]; /**< The sections. */ rtems_rtl_rap_section secs[RTEMS_RTL_RAP_SECS]; /**< The sections. */
uint32_t symtab_size; /**< The symbol table size. */ uint32_t symtab_size; /**< The symbol table size. */
char* strtab; /**< The string table. */ char* strtab; /**< The string table. */
uint32_t strtab_size; /**< The string table size. */ uint32_t strtab_size; /**< The string table size. */
uint32_t relocs_size; /**< The relocation table size. */ uint32_t relocs_size; /**< The relocation table size. */
uint32_t symbols; /**< The number of symbols. */ uint32_t symbols; /**< The number of symbols. */
uint32_t strtable_size;/**< The size of section names and obj names. */ uint32_t strtable_size;/**< The size of section names and obj names. */
uint32_t rpathlen; /**< The length of rpath. */ uint32_t rpathlen; /**< The length of rpath. */
char* strtable; /**< The detail string which resides in obj detail. */ char* strtable; /**< The detail string which resides in obj detail. */
} rtems_rtl_rap_t; } rtems_rtl_rap;
/** /**
* Check the machine type. * Check the machine type.
@@ -191,7 +191,7 @@ rtems_rtl_rap_get_uint32 (const uint8_t* buffer)
} }
static bool static bool
rtems_rtl_rap_read_uint32 (rtems_rtl_obj_comp_t* comp, uint32_t* value) rtems_rtl_rap_read_uint32 (rtems_rtl_obj_comp* comp, uint32_t* value)
{ {
uint8_t buffer[sizeof (uint32_t)]; uint8_t buffer[sizeof (uint32_t)];
@@ -204,12 +204,12 @@ rtems_rtl_rap_read_uint32 (rtems_rtl_obj_comp_t* comp, uint32_t* value)
} }
static bool static bool
rtems_rtl_rap_loader (rtems_rtl_obj_t* obj, rtems_rtl_rap_loader (rtems_rtl_obj* obj,
int fd, int fd,
rtems_rtl_obj_sect_t* sect, rtems_rtl_obj_sect* sect,
void* data) void* data)
{ {
rtems_rtl_rap_t* rap = (rtems_rtl_rap_t*) data; rtems_rtl_rap* rap = (rtems_rtl_rap*) data;
if (rtems_rtl_trace (RTEMS_RTL_TRACE_LOAD)) if (rtems_rtl_trace (RTEMS_RTL_TRACE_LOAD))
printf ("rtl: rap: input %s=%" PRIu32 "\n", printf ("rtl: rap: input %s=%" PRIu32 "\n",
@@ -219,7 +219,7 @@ rtems_rtl_rap_loader (rtems_rtl_obj_t* obj,
} }
static bool static bool
rtems_rtl_rap_relocate (rtems_rtl_rap_t* rap, rtems_rtl_obj_t* obj) rtems_rtl_rap_relocate (rtems_rtl_rap* rap, rtems_rtl_obj* obj)
{ {
#define SYMNAME_BUFFER_SIZE (1024) #define SYMNAME_BUFFER_SIZE (1024)
char* symname_buffer = NULL; char* symname_buffer = NULL;
@@ -237,11 +237,11 @@ rtems_rtl_rap_relocate (rtems_rtl_rap_t* rap, rtems_rtl_obj_t* obj)
for (section = 0; section < RTEMS_RTL_RAP_SECS; ++section) for (section = 0; section < RTEMS_RTL_RAP_SECS; ++section)
{ {
rtems_rtl_obj_sect_t* targetsect; rtems_rtl_obj_sect* targetsect;
uint32_t header = 0; uint32_t header = 0;
int relocs; int relocs;
bool is_rela; bool is_rela;
int r; int r;
targetsect = rtems_rtl_obj_find_section (obj, rap_sections[section].name); targetsect = rtems_rtl_obj_find_section (obj, rap_sections[section].name);
@@ -320,7 +320,7 @@ rtems_rtl_rap_relocate (rtems_rtl_rap_t* rap, rtems_rtl_obj_t* obj)
if ((info & (1 << 31)) == 0) if ((info & (1 << 31)) == 0)
{ {
rtems_rtl_obj_sect_t* symsect; rtems_rtl_obj_sect* symsect;
symsect = rtems_rtl_obj_find_section_by_index (obj, info >> 8); symsect = rtems_rtl_obj_find_section_by_index (obj, info >> 8);
if (!symsect) if (!symsect)
@@ -333,7 +333,7 @@ rtems_rtl_rap_relocate (rtems_rtl_rap_t* rap, rtems_rtl_obj_t* obj)
} }
else if (rtems_rtl_elf_rel_resolve_sym (type)) else if (rtems_rtl_elf_rel_resolve_sym (type))
{ {
rtems_rtl_obj_sym_t* symbol; rtems_rtl_obj_sym* symbol;
symname_size = (info & ~(3 << 30)) >> 8; symname_size = (info & ~(3 << 30)) >> 8;
@@ -432,7 +432,7 @@ rtems_rtl_rap_relocate (rtems_rtl_rap_t* rap, rtems_rtl_obj_t* obj)
* *
*/ */
static bool static bool
rtems_rtl_rap_load_linkmap (rtems_rtl_rap_t* rap, rtems_rtl_obj_t* obj) rtems_rtl_rap_load_linkmap (rtems_rtl_rap* rap, rtems_rtl_obj* obj)
{ {
void* detail; void* detail;
struct link_map* tmp1; struct link_map* tmp1;
@@ -565,13 +565,13 @@ rtems_rtl_rap_load_linkmap (rtems_rtl_rap_t* rap, rtems_rtl_obj_t* obj)
} }
static bool static bool
rtems_rtl_rap_load_symbols (rtems_rtl_rap_t* rap, rtems_rtl_obj_t* obj) rtems_rtl_rap_load_symbols (rtems_rtl_rap* rap, rtems_rtl_obj* obj)
{ {
rtems_rtl_obj_sym_t* gsym; rtems_rtl_obj_sym* gsym;
int sym; int sym;
obj->global_size = obj->global_size =
rap->symbols * sizeof (rtems_rtl_obj_sym_t) + rap->strtab_size; rap->symbols * sizeof (rtems_rtl_obj_sym) + rap->strtab_size;
obj->global_table = rtems_rtl_alloc_new (RTEMS_RTL_ALLOC_SYMBOL, obj->global_table = rtems_rtl_alloc_new (RTEMS_RTL_ALLOC_SYMBOL,
obj->global_size, true); obj->global_size, true);
@@ -585,7 +585,7 @@ rtems_rtl_rap_load_symbols (rtems_rtl_rap_t* rap, rtems_rtl_obj_t* obj)
obj->global_syms = rap->symbols; obj->global_syms = rap->symbols;
rap->strtab = (((char*) obj->global_table) + rap->strtab = (((char*) obj->global_table) +
(rap->symbols * sizeof (rtems_rtl_obj_sym_t))); (rap->symbols * sizeof (rtems_rtl_obj_sym)));
if (!rtems_rtl_obj_comp_read (rap->decomp, rap->strtab, rap->strtab_size)) if (!rtems_rtl_obj_comp_read (rap->decomp, rap->strtab, rap->strtab_size))
{ {
@@ -595,10 +595,10 @@ rtems_rtl_rap_load_symbols (rtems_rtl_rap_t* rap, rtems_rtl_obj_t* obj)
for (sym = 0, gsym = obj->global_table; sym < rap->symbols; ++sym) for (sym = 0, gsym = obj->global_table; sym < rap->symbols; ++sym)
{ {
rtems_rtl_obj_sect_t* symsect; rtems_rtl_obj_sect* symsect;
uint32_t data; uint32_t data;
uint32_t name; uint32_t name;
uint32_t value; uint32_t value;
if (!rtems_rtl_rap_read_uint32 (rap->decomp, &data) || if (!rtems_rtl_rap_read_uint32 (rap->decomp, &data) ||
!rtems_rtl_rap_read_uint32 (rap->decomp, &name) || !rtems_rtl_rap_read_uint32 (rap->decomp, &name) ||
@@ -756,15 +756,15 @@ rtems_rtl_rap_parse_header (uint8_t* rhdr,
} }
bool bool
rtems_rtl_rap_file_check (rtems_rtl_obj_t* obj, int fd) rtems_rtl_rap_file_check (rtems_rtl_obj* obj, int fd)
{ {
rtems_rtl_obj_cache_t* header; rtems_rtl_obj_cache* header;
uint8_t* rhdr = NULL; uint8_t* rhdr = NULL;
size_t rlen = 64; size_t rlen = 64;
uint32_t length = 0; uint32_t length = 0;
uint32_t version = 0; uint32_t version = 0;
uint32_t compression = 0; uint32_t compression = 0;
uint32_t checksum = 0; uint32_t checksum = 0;
rtems_rtl_obj_caches (&header, NULL, NULL); rtems_rtl_obj_caches (&header, NULL, NULL);
@@ -784,12 +784,12 @@ rtems_rtl_rap_file_check (rtems_rtl_obj_t* obj, int fd)
} }
bool bool
rtems_rtl_rap_file_load (rtems_rtl_obj_t* obj, int fd) rtems_rtl_rap_file_load (rtems_rtl_obj* obj, int fd)
{ {
rtems_rtl_rap_t rap = { 0 }; rtems_rtl_rap rap = { 0 };
uint8_t* rhdr = NULL; uint8_t* rhdr = NULL;
size_t rlen = 64; size_t rlen = 64;
int section; int section;
rtems_rtl_obj_caches (&rap.file, NULL, NULL); rtems_rtl_obj_caches (&rap.file, NULL, NULL);
@@ -811,8 +811,8 @@ rtems_rtl_rap_file_load (rtems_rtl_obj_t* obj, int fd)
/* /*
* Set up the decompressor. * Set up the decompressor.
*/ */
rtems_rtl_obj_comp (&rap.decomp, rap.file, fd, rap.compression, rtems_rtl_obj_decompress (&rap.decomp, rap.file, fd, rap.compression,
rlen + obj->ooffset); rlen + obj->ooffset);
/* /*
* uint32_t: machinetype * uint32_t: machinetype
@@ -990,13 +990,13 @@ rtems_rtl_rap_file_load (rtems_rtl_obj_t* obj, int fd)
} }
bool bool
rtems_rtl_rap_file_unload (rtems_rtl_obj_t* obj) rtems_rtl_rap_file_unload (rtems_rtl_obj* obj)
{ {
(void) obj; (void) obj;
return true; return true;
} }
rtems_rtl_loader_format_t* rtems_rtl_loader_format*
rtems_rtl_rap_file_sig (void) rtems_rtl_rap_file_sig (void)
{ {
return &rap_sig; return &rap_sig;

View File

@@ -1,5 +1,5 @@
/* /*
* COPYRIGHT (c) 2012 Chris Johns <chrisj@rtems.org> * COPYRIGHT (c) 2012, 2018 Chris Johns <chrisj@rtems.org>
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at
@@ -30,7 +30,7 @@ extern "C" {
* @param obj The object being checked. * @param obj The object being checked.
* @param fd The file descriptor. * @param fd The file descriptor.
*/ */
bool rtems_rtl_rap_file_check (rtems_rtl_obj_t* obj, int fd); bool rtems_rtl_rap_file_check (rtems_rtl_obj* obj, int fd);
/** /**
* The RAP format load handler. * The RAP format load handler.
@@ -38,21 +38,21 @@ bool rtems_rtl_rap_file_check (rtems_rtl_obj_t* obj, int fd);
* @param obj The object to load. * @param obj The object to load.
* @param fd The file descriptor. * @param fd The file descriptor.
*/ */
bool rtems_rtl_rap_file_load (rtems_rtl_obj_t* obj, int fd); bool rtems_rtl_rap_file_load (rtems_rtl_obj* obj, int fd);
/** /**
* The RAP format unload handler. * The RAP format unload handler.
* *
* @param obj The object to unload. * @param obj The object to unload.
*/ */
bool rtems_rtl_rap_file_unload (rtems_rtl_obj_t* obj); bool rtems_rtl_rap_file_unload (rtems_rtl_obj* obj);
/** /**
* The RAP format signature handler. * The RAP format signature handler.
* *
* @return rtems_rtl_loader_format_t* The format's signature. * @return rtems_rtl_loader_format* The format's signature.
*/ */
rtems_rtl_loader_format_t* rtems_rtl_rap_file_sig (void); rtems_rtl_loader_format* rtems_rtl_rap_file_sig (void);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@@ -1,5 +1,5 @@
/* /*
* COPYRIGHT (c) 2012 Chris Johns <chrisj@rtems.org> * COPYRIGHT (c) 2012, 2018 Chris Johns <chrisj@rtems.org>
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at
@@ -33,17 +33,17 @@
/** /**
* The type of the shell handlers we have. * The type of the shell handlers we have.
*/ */
typedef int (*rtems_rtl_shell_handler_t) (rtems_rtl_data_t* rtl, int argc, char *argv[]); typedef int (*rtems_rtl_shell_handler) (rtems_rtl_data* rtl, int argc, char *argv[]);
/** /**
* Table of handlers we parse to invoke the command. * Table of handlers we parse to invoke the command.
*/ */
typedef struct typedef struct
{ {
const char* name; /**< The sub-command's name. */ const char* name; /**< The sub-command's name. */
rtems_rtl_shell_handler_t handler; /**< The sub-command's handler. */ rtems_rtl_shell_handler handler; /**< The sub-command's handler. */
const char* help; /**< The sub-command's help. */ const char* help; /**< The sub-command's help. */
} rtems_rtl_shell_cmd_t; } rtems_rtl_shell_cmd;
/** /**
* Object summary data. * Object summary data.
@@ -53,7 +53,7 @@ typedef struct
int count; /**< The number of object files. */ int count; /**< The number of object files. */
size_t exec; /**< The amount of executable memory allocated. */ size_t exec; /**< The amount of executable memory allocated. */
size_t symbols; /**< The amount of symbol memory allocated. */ size_t symbols; /**< The amount of symbol memory allocated. */
} rtems_rtl_obj_summary_t; } rtems_rtl_obj_summary;
/** /**
* Object summary iterator. * Object summary iterator.
@@ -61,8 +61,8 @@ typedef struct
static bool static bool
rtems_rtl_obj_summary_iterator (rtems_chain_node* node, void* data) rtems_rtl_obj_summary_iterator (rtems_chain_node* node, void* data)
{ {
rtems_rtl_obj_summary_t* summary = data; rtems_rtl_obj_summary* summary = data;
rtems_rtl_obj_t* obj = (rtems_rtl_obj_t*) node; rtems_rtl_obj* obj = (rtems_rtl_obj*) node;
++summary->count; ++summary->count;
summary->exec += obj->exec_size; summary->exec += obj->exec_size;
summary->symbols += obj->global_size; summary->symbols += obj->global_size;
@@ -73,7 +73,7 @@ rtems_rtl_obj_summary_iterator (rtems_chain_node* node, void* data)
* Count the number of symbols. * Count the number of symbols.
*/ */
static int static int
rtems_rtl_count_symbols (rtems_rtl_data_t* rtl) rtems_rtl_count_symbols (rtems_rtl_data* rtl)
{ {
int count; int count;
int bucket; int bucket;
@@ -83,10 +83,10 @@ rtems_rtl_count_symbols (rtems_rtl_data_t* rtl)
} }
static int static int
rtems_rtl_shell_status (rtems_rtl_data_t* rtl, int argc, char *argv[]) rtems_rtl_shell_status (rtems_rtl_data* rtl, int argc, char *argv[])
{ {
rtems_rtl_obj_summary_t summary; rtems_rtl_obj_summary summary;
size_t total_memory; size_t total_memory;
summary.count = 0; summary.count = 0;
summary.exec = 0; summary.exec = 0;
@@ -98,7 +98,7 @@ rtems_rtl_shell_status (rtems_rtl_data_t* rtl, int argc, char *argv[])
* Currently does not include the name strings in the obj struct. * Currently does not include the name strings in the obj struct.
*/ */
total_memory = total_memory =
sizeof (*rtl) + (summary.count * sizeof (rtems_rtl_obj_t)) + sizeof (*rtl) + (summary.count * sizeof (rtems_rtl_obj)) +
summary.exec + summary.symbols; summary.exec + summary.symbols;
printf ("Runtime Linker Status:\n"); printf ("Runtime Linker Status:\n");
@@ -117,14 +117,14 @@ rtems_rtl_shell_status (rtems_rtl_data_t* rtl, int argc, char *argv[])
*/ */
typedef struct typedef struct
{ {
rtems_rtl_data_t* rtl; /**< The RTL data. */ rtems_rtl_data* rtl; /**< The RTL data. */
int indent; /**< Spaces to indent. */ int indent; /**< Spaces to indent. */
bool oname; /**< Print object names. */ bool oname; /**< Print object names. */
bool names; /**< Print details of all names. */ bool names; /**< Print details of all names. */
bool memory_map; /**< Print the memory map. */ bool memory_map; /**< Print the memory map. */
bool symbols; /**< Print the global symbols. */ bool symbols; /**< Print the global symbols. */
bool base; /**< Include the base object file. */ bool base; /**< Include the base object file. */
} rtems_rtl_obj_print_t; } rtems_rtl_obj_print;
/** /**
* Return the different between 2 void*. * Return the different between 2 void*.
@@ -172,7 +172,7 @@ rtems_rtl_symbols_arg (int argc, char *argv[])
* Object printer. * Object printer.
*/ */
static bool static bool
rtems_rtl_obj_printer (rtems_rtl_obj_print_t* print, rtems_rtl_obj_t* obj) rtems_rtl_obj_printer (rtems_rtl_obj_print* print, rtems_rtl_obj* obj)
{ {
char flags_str[33]; char flags_str[33];
@@ -239,10 +239,10 @@ rtems_rtl_obj_printer (rtems_rtl_obj_print_t* print, rtems_rtl_obj_t* obj)
* Object unresolved symbols printer. * Object unresolved symbols printer.
*/ */
static bool static bool
rtems_rtl_unresolved_printer (rtems_rtl_unresolv_rec_t* rec, rtems_rtl_unresolved_printer (rtems_rtl_unresolv_rec* rec,
void* data) void* data)
{ {
rtems_rtl_obj_print_t* print = (rtems_rtl_obj_print_t*) data; rtems_rtl_obj_print* print = (rtems_rtl_obj_print*) data;
if (rec->type == rtems_rtl_unresolved_name) if (rec->type == rtems_rtl_unresolved_name)
printf ("%-*c%s\n", print->indent + 2, ' ', rec->rec.name.name); printf ("%-*c%s\n", print->indent + 2, ' ', rec->rec.name.name);
return false; return false;
@@ -254,15 +254,15 @@ rtems_rtl_unresolved_printer (rtems_rtl_unresolv_rec_t* rec,
static bool static bool
rtems_rtl_obj_print_iterator (rtems_chain_node* node, void* data) rtems_rtl_obj_print_iterator (rtems_chain_node* node, void* data)
{ {
rtems_rtl_obj_print_t* print = data; rtems_rtl_obj_print* print = data;
rtems_rtl_obj_t* obj = (rtems_rtl_obj_t*) node; rtems_rtl_obj* obj = (rtems_rtl_obj*) node;
return rtems_rtl_obj_printer (print, obj); return rtems_rtl_obj_printer (print, obj);
} }
static int static int
rtems_rtl_shell_list (rtems_rtl_data_t* rtl, int argc, char *argv[]) rtems_rtl_shell_list (rtems_rtl_data* rtl, int argc, char *argv[])
{ {
rtems_rtl_obj_print_t print; rtems_rtl_obj_print print;
print.rtl = rtl; print.rtl = rtl;
print.indent = 1; print.indent = 1;
print.oname = true; print.oname = true;
@@ -277,9 +277,9 @@ rtems_rtl_shell_list (rtems_rtl_data_t* rtl, int argc, char *argv[])
} }
static int static int
rtems_rtl_shell_sym (rtems_rtl_data_t* rtl, int argc, char *argv[]) rtems_rtl_shell_sym (rtems_rtl_data* rtl, int argc, char *argv[])
{ {
rtems_rtl_obj_print_t print; rtems_rtl_obj_print print;
print.rtl = rtl; print.rtl = rtl;
print.indent = 1; print.indent = 1;
print.oname = true; print.oname = true;
@@ -296,7 +296,7 @@ rtems_rtl_shell_sym (rtems_rtl_data_t* rtl, int argc, char *argv[])
} }
static int static int
rtems_rtl_shell_object (rtems_rtl_data_t* rtl, int argc, char *argv[]) rtems_rtl_shell_object (rtems_rtl_data* rtl, int argc, char *argv[])
{ {
return 0; return 0;
} }
@@ -315,7 +315,7 @@ rtems_rtl_shell_usage (const char* arg)
int int
rtems_rtl_shell_command (int argc, char* argv[]) rtems_rtl_shell_command (int argc, char* argv[])
{ {
const rtems_rtl_shell_cmd_t table[] = const rtems_rtl_shell_cmd table[] =
{ {
{ "status", rtems_rtl_shell_status, { "status", rtems_rtl_shell_status,
"Display the status of the RTL" }, "Display the status of the RTL" },
@@ -343,7 +343,7 @@ rtems_rtl_shell_command (int argc, char* argv[])
case 'l': case 'l':
printf ("%s: commands are:\n", argv[0]); printf ("%s: commands are:\n", argv[0]);
for (t = 0; for (t = 0;
t < (sizeof (table) / sizeof (const rtems_rtl_shell_cmd_t)); t < (sizeof (table) / sizeof (const rtems_rtl_shell_cmd));
++t) ++t)
printf (" %s\t%s\n", table[t].name, table[t].help); printf (" %s\t%s\n", table[t].name, table[t].help);
return 0; return 0;
@@ -358,13 +358,13 @@ rtems_rtl_shell_command (int argc, char* argv[])
else else
{ {
for (t = 0; for (t = 0;
t < (sizeof (table) / sizeof (const rtems_rtl_shell_cmd_t)); t < (sizeof (table) / sizeof (const rtems_rtl_shell_cmd));
++t) ++t)
{ {
if (strncmp (argv[arg], table[t].name, strlen (argv[arg])) == 0) if (strncmp (argv[arg], table[t].name, strlen (argv[arg])) == 0)
{ {
rtems_rtl_data_t* rtl = rtems_rtl_data (); rtems_rtl_data* rtl = rtems_rtl_lock ();
int r; int r;
if (!rtl) if (!rtl)
{ {
printf ("error: cannot lock the linker\n"); printf ("error: cannot lock the linker\n");

View File

@@ -1,5 +1,5 @@
/* /*
* COPYRIGHT (c) 2012-2014 Chris Johns <chrisj@rtems.org> * COPYRIGHT (c) 2012-2014, 2018 Chris Johns <chrisj@rtems.org>
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at
@@ -32,7 +32,7 @@
* The single symbol forced into the global symbol table that is used to load a * The single symbol forced into the global symbol table that is used to load a
* symbol table from an object file. * symbol table from an object file.
*/ */
static rtems_rtl_obj_sym_t global_sym_add = static rtems_rtl_obj_sym global_sym_add =
{ {
.name = "rtems_rtl_base_sym_global_add", .name = "rtems_rtl_base_sym_global_add",
.value = (void*) rtems_rtl_base_sym_global_add .value = (void*) rtems_rtl_base_sym_global_add
@@ -49,8 +49,8 @@ rtems_rtl_symbol_hash (const char *s)
} }
static void static void
rtems_rtl_symbol_global_insert (rtems_rtl_symbols_t* symbols, rtems_rtl_symbol_global_insert (rtems_rtl_symbols* symbols,
rtems_rtl_obj_sym_t* symbol) rtems_rtl_obj_sym* symbol)
{ {
uint_fast32_t hash = rtems_rtl_symbol_hash (symbol->name); uint_fast32_t hash = rtems_rtl_symbol_hash (symbol->name);
rtems_chain_append (&symbols->buckets[hash % symbols->nbuckets], rtems_chain_append (&symbols->buckets[hash % symbols->nbuckets],
@@ -58,8 +58,8 @@ rtems_rtl_symbol_global_insert (rtems_rtl_symbols_t* symbols,
} }
bool bool
rtems_rtl_symbol_table_open (rtems_rtl_symbols_t* symbols, rtems_rtl_symbol_table_open (rtems_rtl_symbols* symbols,
size_t buckets) size_t buckets)
{ {
symbols->buckets = rtems_rtl_alloc_new (RTEMS_RTL_ALLOC_SYMBOL, symbols->buckets = rtems_rtl_alloc_new (RTEMS_RTL_ALLOC_SYMBOL,
buckets * sizeof (rtems_chain_control), buckets * sizeof (rtems_chain_control),
@@ -77,21 +77,21 @@ rtems_rtl_symbol_table_open (rtems_rtl_symbols_t* symbols,
} }
void void
rtems_rtl_symbol_table_close (rtems_rtl_symbols_t* symbols) rtems_rtl_symbol_table_close (rtems_rtl_symbols* symbols)
{ {
rtems_rtl_alloc_del (RTEMS_RTL_ALLOC_SYMBOL, symbols->buckets); rtems_rtl_alloc_del (RTEMS_RTL_ALLOC_SYMBOL, symbols->buckets);
} }
bool bool
rtems_rtl_symbol_global_add (rtems_rtl_obj_t* obj, rtems_rtl_symbol_global_add (rtems_rtl_obj* obj,
const unsigned char* esyms, const unsigned char* esyms,
unsigned int size) unsigned int size)
{ {
rtems_rtl_symbols_t* symbols; rtems_rtl_symbols* symbols;
rtems_rtl_obj_sym_t* sym; rtems_rtl_obj_sym* sym;
size_t count; size_t count;
size_t s; size_t s;
uint32_t marker; uint32_t marker;
count = 0; count = 0;
s = 0; s = 0;
@@ -127,7 +127,7 @@ rtems_rtl_symbol_global_add (rtems_rtl_obj_t* obj,
if (rtems_rtl_trace (RTEMS_RTL_TRACE_GLOBAL_SYM)) if (rtems_rtl_trace (RTEMS_RTL_TRACE_GLOBAL_SYM))
printf ("rtl: global symbol add: %zi\n", count); printf ("rtl: global symbol add: %zi\n", count);
obj->global_size = count * sizeof (rtems_rtl_obj_sym_t); obj->global_size = count * sizeof (rtems_rtl_obj_sym);
obj->global_table = rtems_rtl_alloc_new (RTEMS_RTL_ALLOC_SYMBOL, obj->global_table = rtems_rtl_alloc_new (RTEMS_RTL_ALLOC_SYMBOL,
obj->global_size, true); obj->global_size, true);
if (!obj->global_table) if (!obj->global_table)
@@ -172,10 +172,10 @@ rtems_rtl_symbol_global_add (rtems_rtl_obj_t* obj,
return true; return true;
} }
rtems_rtl_obj_sym_t* rtems_rtl_obj_sym*
rtems_rtl_symbol_global_find (const char* name) rtems_rtl_symbol_global_find (const char* name)
{ {
rtems_rtl_symbols_t* symbols; rtems_rtl_symbols* symbols;
uint_fast32_t hash; uint_fast32_t hash;
rtems_chain_control* bucket; rtems_chain_control* bucket;
rtems_chain_node* node; rtems_chain_node* node;
@@ -188,7 +188,7 @@ rtems_rtl_symbol_global_find (const char* name)
while (!rtems_chain_is_tail (bucket, node)) while (!rtems_chain_is_tail (bucket, node))
{ {
rtems_rtl_obj_sym_t* sym = (rtems_rtl_obj_sym_t*) node; rtems_rtl_obj_sym* sym = (rtems_rtl_obj_sym*) node;
/* /*
* Use the hash. I could add this to the symbol but it uses more memory. * Use the hash. I could add this to the symbol but it uses more memory.
*/ */
@@ -200,11 +200,11 @@ rtems_rtl_symbol_global_find (const char* name)
return NULL; return NULL;
} }
rtems_rtl_obj_sym_t* rtems_rtl_obj_sym*
rtems_rtl_symbol_obj_find (rtems_rtl_obj_t* obj, const char* name) rtems_rtl_symbol_obj_find (rtems_rtl_obj* obj, const char* name)
{ {
rtems_rtl_obj_sym_t* sym; rtems_rtl_obj_sym* sym;
size_t s; size_t s;
/* /*
* Check the object file's symbols first. If not found search the * Check the object file's symbols first. If not found search the
* global symbol table. * global symbol table.
@@ -225,11 +225,11 @@ rtems_rtl_symbol_obj_find (rtems_rtl_obj_t* obj, const char* name)
} }
void void
rtems_rtl_symbol_obj_add (rtems_rtl_obj_t* obj) rtems_rtl_symbol_obj_add (rtems_rtl_obj* obj)
{ {
rtems_rtl_symbols_t* symbols; rtems_rtl_symbols* symbols;
rtems_rtl_obj_sym_t* sym; rtems_rtl_obj_sym* sym;
size_t s; size_t s;
symbols = rtems_rtl_global_symbols (); symbols = rtems_rtl_global_symbols ();
@@ -238,7 +238,7 @@ rtems_rtl_symbol_obj_add (rtems_rtl_obj_t* obj)
} }
void void
rtems_rtl_symbol_obj_erase_local (rtems_rtl_obj_t* obj) rtems_rtl_symbol_obj_erase_local (rtems_rtl_obj* obj)
{ {
if (obj->local_table) if (obj->local_table)
{ {
@@ -250,13 +250,13 @@ rtems_rtl_symbol_obj_erase_local (rtems_rtl_obj_t* obj)
} }
void void
rtems_rtl_symbol_obj_erase (rtems_rtl_obj_t* obj) rtems_rtl_symbol_obj_erase (rtems_rtl_obj* obj)
{ {
rtems_rtl_symbol_obj_erase_local (obj); rtems_rtl_symbol_obj_erase_local (obj);
if (obj->global_table) if (obj->global_table)
{ {
rtems_rtl_obj_sym_t* sym; rtems_rtl_obj_sym* sym;
size_t s; size_t s;
for (s = 0, sym = obj->global_table; s < obj->global_syms; ++s, ++sym) for (s = 0, sym = obj->global_table; s < obj->global_syms; ++s, ++sym)
if (!rtems_chain_is_node_off_chain (&sym->node)) if (!rtems_chain_is_node_off_chain (&sym->node))
rtems_chain_extract (&sym->node); rtems_chain_extract (&sym->node);

View File

@@ -1,5 +1,5 @@
/* /*
* COPYRIGHT (c) 2012 Chris Johns <chrisj@rtems.org> * COPYRIGHT (c) 2012, 2018 Chris Johns <chrisj@rtems.org>
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at
@@ -28,16 +28,16 @@
#include <rtems/rtl/rtl-unresolved.h> #include <rtems/rtl/rtl-unresolved.h>
#include <rtems/rtl/rtl-trace.h> #include <rtems/rtl/rtl-trace.h>
static rtems_rtl_unresolv_block_t* static rtems_rtl_unresolv_block*
rtems_rtl_unresolved_block_alloc (rtems_rtl_unresolved_t* unresolved) rtems_rtl_unresolved_block_alloc (rtems_rtl_unresolved* unresolved)
{ {
/* /*
* The block header contains a record. * The block header contains a record.
*/ */
size_t size = size_t size =
(sizeof(rtems_rtl_unresolv_block_t) + (sizeof(rtems_rtl_unresolv_block) +
(sizeof(rtems_rtl_unresolv_rec_t) * (unresolved->block_recs - 1))); (sizeof(rtems_rtl_unresolv_rec) * (unresolved->block_recs - 1)));
rtems_rtl_unresolv_block_t* block = rtems_rtl_unresolv_block* block =
rtems_rtl_alloc_new (RTEMS_RTL_ALLOC_EXTERNAL, size, true); rtems_rtl_alloc_new (RTEMS_RTL_ALLOC_EXTERNAL, size, true);
if (block) if (block)
rtems_chain_append (&unresolved->blocks, &block->link); rtems_chain_append (&unresolved->blocks, &block->link);
@@ -50,25 +50,25 @@ static size_t
rtems_rtl_unresolved_name_recs (const char* name) rtems_rtl_unresolved_name_recs (const char* name)
{ {
size_t length = strlen (name); size_t length = strlen (name);
return ((length + sizeof(rtems_rtl_unresolv_name_t) - 1) / return ((length + sizeof(rtems_rtl_unresolv_name) - 1) /
sizeof(rtems_rtl_unresolv_name_t)); sizeof(rtems_rtl_unresolv_name));
} }
static int static int
rtems_rtl_unresolved_rec_index (rtems_rtl_unresolv_block_t* block, rtems_rtl_unresolved_rec_index (rtems_rtl_unresolv_block* block,
rtems_rtl_unresolv_rec_t* rec) rtems_rtl_unresolv_rec* rec)
{ {
return (rec - &block->rec) / sizeof (rtems_rtl_unresolv_rec_t); return (rec - &block->rec) / sizeof (rtems_rtl_unresolv_rec);
} }
static rtems_rtl_unresolv_rec_t* static rtems_rtl_unresolv_rec*
rtems_rtl_unresolved_rec_first (rtems_rtl_unresolv_block_t* block) rtems_rtl_unresolved_rec_first (rtems_rtl_unresolv_block* block)
{ {
return &block->rec; return &block->rec;
} }
static rtems_rtl_unresolv_rec_t* static rtems_rtl_unresolv_rec*
rtems_rtl_unresolved_rec_next (rtems_rtl_unresolv_rec_t* rec) rtems_rtl_unresolved_rec_next (rtems_rtl_unresolv_rec* rec)
{ {
switch (rec->type) switch (rec->type)
@@ -84,8 +84,8 @@ rtems_rtl_unresolved_rec_next (rtems_rtl_unresolv_rec_t* rec)
/* /*
* Determine how many records the name occupies. Round up. * Determine how many records the name occupies. Round up.
*/ */
rec += ((rec->rec.name.length + sizeof(rtems_rtl_unresolv_name_t) - 1) / rec += ((rec->rec.name.length + sizeof(rtems_rtl_unresolv_name) - 1) /
sizeof(rtems_rtl_unresolv_name_t)); sizeof(rtems_rtl_unresolv_name));
break; break;
case rtems_rtl_unresolved_reloc: case rtems_rtl_unresolved_reloc:
@@ -100,23 +100,23 @@ rtems_rtl_unresolved_rec_next (rtems_rtl_unresolv_rec_t* rec)
} }
static bool static bool
rtems_rtl_unresolved_rec_is_last (rtems_rtl_unresolv_block_t* block, rtems_rtl_unresolved_rec_is_last (rtems_rtl_unresolv_block* block,
rtems_rtl_unresolv_rec_t* rec) rtems_rtl_unresolv_rec* rec)
{ {
int index = (rec - &block->rec) / sizeof (rec); int index = (rec - &block->rec) / sizeof (rec);
return !rec || (index >= block->recs) || (rec->type == rtems_rtl_unresolved_empty); return !rec || (index >= block->recs) || (rec->type == rtems_rtl_unresolved_empty);
} }
static rtems_rtl_unresolv_rec_t* static rtems_rtl_unresolv_rec*
rtems_rtl_unresolved_rec_first_free (rtems_rtl_unresolv_block_t* block) rtems_rtl_unresolved_rec_first_free (rtems_rtl_unresolv_block* block)
{ {
return &block->rec + block->recs; return &block->rec + block->recs;
} }
static int static int
rtems_rtl_unresolved_find_name (rtems_rtl_unresolved_t* unresolved, rtems_rtl_unresolved_find_name (rtems_rtl_unresolved* unresolved,
const char* name, const char* name,
bool update_refcount) bool update_refcount)
{ {
size_t length = strlen (name); size_t length = strlen (name);
int index = 1; int index = 1;
@@ -124,8 +124,8 @@ rtems_rtl_unresolved_find_name (rtems_rtl_unresolved_t* unresolved,
rtems_chain_node* node = rtems_chain_first (&unresolved->blocks); rtems_chain_node* node = rtems_chain_first (&unresolved->blocks);
while (!rtems_chain_is_tail (&unresolved->blocks, node)) while (!rtems_chain_is_tail (&unresolved->blocks, node))
{ {
rtems_rtl_unresolv_block_t* block = (rtems_rtl_unresolv_block_t*) node; rtems_rtl_unresolv_block* block = (rtems_rtl_unresolv_block*) node;
rtems_rtl_unresolv_rec_t* rec = rtems_rtl_unresolved_rec_first (block); rtems_rtl_unresolv_rec* rec = rtems_rtl_unresolved_rec_first (block);
while (!rtems_rtl_unresolved_rec_is_last (block, rec)) while (!rtems_rtl_unresolved_rec_is_last (block, rec))
{ {
@@ -152,21 +152,21 @@ rtems_rtl_unresolved_find_name (rtems_rtl_unresolved_t* unresolved,
/** /**
* Struct to pass relocation data in the interator. * Struct to pass relocation data in the interator.
*/ */
typedef struct rtems_rtl_unresolved_reloc_data_s typedef struct rtems_rtl_unresolved_reloc_data
{ {
uint16_t name; /**< Name index. */ uint16_t name; /**< Name index. */
rtems_rtl_unresolv_rec_t* name_rec; /**< Name record. */ rtems_rtl_unresolv_rec* name_rec; /**< Name record. */
rtems_rtl_obj_sym_t* sym; /**< The symbol record. */ rtems_rtl_obj_sym* sym; /**< The symbol record. */
} rtems_rtl_unresolved_reloc_data_t; } rtems_rtl_unresolved_reloc_data;
static bool static bool
rtems_rtl_unresolved_resolve_reloc (rtems_rtl_unresolv_rec_t* rec, rtems_rtl_unresolved_resolve_reloc (rtems_rtl_unresolv_rec* rec,
void* data) void* data)
{ {
if (rec->type == rtems_rtl_unresolved_reloc) if (rec->type == rtems_rtl_unresolved_reloc)
{ {
rtems_rtl_unresolved_reloc_data_t* rd; rtems_rtl_unresolved_reloc_data* rd;
rd = (rtems_rtl_unresolved_reloc_data_t*) data; rd = (rtems_rtl_unresolved_reloc_data*) data;
if (rec->rec.reloc.name == rd->name) if (rec->rec.reloc.name == rd->name)
{ {
@@ -190,13 +190,13 @@ rtems_rtl_unresolved_resolve_reloc (rtems_rtl_unresolv_rec_t* rec,
} }
static bool static bool
rtems_rtl_unresolved_resolve_iterator (rtems_rtl_unresolv_rec_t* rec, rtems_rtl_unresolved_resolve_iterator (rtems_rtl_unresolv_rec* rec,
void* data) void* data)
{ {
if (rec->type == rtems_rtl_unresolved_name) if (rec->type == rtems_rtl_unresolved_name)
{ {
rtems_rtl_unresolved_reloc_data_t* rd; rtems_rtl_unresolved_reloc_data* rd;
rd = (rtems_rtl_unresolved_reloc_data_t*) data; rd = (rtems_rtl_unresolved_reloc_data*) data;
++rd->name; ++rd->name;
@@ -223,25 +223,25 @@ rtems_rtl_unresolved_resolve_iterator (rtems_rtl_unresolv_rec_t* rec,
} }
static void static void
rtems_rtl_unresolved_clean_block (rtems_rtl_unresolv_block_t* block, rtems_rtl_unresolved_clean_block (rtems_rtl_unresolv_block* block,
rtems_rtl_unresolv_rec_t* rec, rtems_rtl_unresolv_rec* rec,
size_t count, size_t count,
size_t recs_per_block) size_t recs_per_block)
{ {
size_t index = rtems_rtl_unresolved_rec_index (block, rec); size_t index = rtems_rtl_unresolved_rec_index (block, rec);
size_t bytes = size_t bytes =
(block->recs - index - count) * sizeof (rtems_rtl_unresolv_rec_t); (block->recs - index - count) * sizeof (rtems_rtl_unresolv_rec);
if (bytes) if (bytes)
memmove (rec, rec + count, bytes); memmove (rec, rec + count, bytes);
--block->recs; --block->recs;
bytes = count * sizeof (rtems_rtl_unresolv_rec_t); bytes = count * sizeof (rtems_rtl_unresolv_rec);
memset (&block->rec + block->recs, 0, bytes); memset (&block->rec + block->recs, 0, bytes);
} }
static void static void
rtems_rtl_unresolved_compact (void) rtems_rtl_unresolved_compact (void)
{ {
rtems_rtl_unresolved_t* unresolved = rtems_rtl_unresolved (); rtems_rtl_unresolved* unresolved = rtems_rtl_unresolved_unprotected ();
if (unresolved) if (unresolved)
{ {
/* /*
@@ -251,9 +251,9 @@ rtems_rtl_unresolved_compact (void)
rtems_chain_node* node = rtems_chain_last (&unresolved->blocks); rtems_chain_node* node = rtems_chain_last (&unresolved->blocks);
while (!rtems_chain_is_head (&unresolved->blocks, node)) while (!rtems_chain_is_head (&unresolved->blocks, node))
{ {
rtems_chain_node* prev = rtems_chain_previous (node); rtems_chain_node* prev = rtems_chain_previous (node);
rtems_rtl_unresolv_block_t* block = (rtems_rtl_unresolv_block_t*) node; rtems_rtl_unresolv_block* block = (rtems_rtl_unresolv_block*) node;
rtems_rtl_unresolv_rec_t* rec = rtems_rtl_unresolved_rec_first (block); rtems_rtl_unresolv_rec* rec = rtems_rtl_unresolved_rec_first (block);
while (!rtems_rtl_unresolved_rec_is_last (block, rec)) while (!rtems_rtl_unresolved_rec_is_last (block, rec))
{ {
@@ -295,8 +295,8 @@ rtems_rtl_unresolved_compact (void)
} }
bool bool
rtems_rtl_unresolved_table_open (rtems_rtl_unresolved_t* unresolved, rtems_rtl_unresolved_table_open (rtems_rtl_unresolved* unresolved,
size_t block_recs) size_t block_recs)
{ {
unresolved->marker = 0xdeadf00d; unresolved->marker = 0xdeadf00d;
unresolved->block_recs = block_recs; unresolved->block_recs = block_recs;
@@ -305,7 +305,7 @@ rtems_rtl_unresolved_table_open (rtems_rtl_unresolved_t* unresolved,
} }
void void
rtems_rtl_unresolved_table_close (rtems_rtl_unresolved_t* unresolved) rtems_rtl_unresolved_table_close (rtems_rtl_unresolved* unresolved)
{ {
rtems_chain_node* node = rtems_chain_first (&unresolved->blocks); rtems_chain_node* node = rtems_chain_first (&unresolved->blocks);
while (!rtems_chain_is_tail (&unresolved->blocks, node)) while (!rtems_chain_is_tail (&unresolved->blocks, node))
@@ -317,17 +317,17 @@ rtems_rtl_unresolved_table_close (rtems_rtl_unresolved_t* unresolved)
} }
bool bool
rtems_rtl_unresolved_interate (rtems_rtl_unresolved_iterator_t iterator, rtems_rtl_unresolved_interate (rtems_rtl_unresolved_iterator iterator,
void* data) void* data)
{ {
rtems_rtl_unresolved_t* unresolved = rtems_rtl_unresolved (); rtems_rtl_unresolved* unresolved = rtems_rtl_unresolved_unprotected ();
if (unresolved) if (unresolved)
{ {
rtems_chain_node* node = rtems_chain_first (&unresolved->blocks); rtems_chain_node* node = rtems_chain_first (&unresolved->blocks);
while (!rtems_chain_is_tail (&unresolved->blocks, node)) while (!rtems_chain_is_tail (&unresolved->blocks, node))
{ {
rtems_rtl_unresolv_block_t* block = (rtems_rtl_unresolv_block_t*) node; rtems_rtl_unresolv_block* block = (rtems_rtl_unresolv_block*) node;
rtems_rtl_unresolv_rec_t* rec = rtems_rtl_unresolved_rec_first (block); rtems_rtl_unresolv_rec* rec = rtems_rtl_unresolved_rec_first (block);
while (!rtems_rtl_unresolved_rec_is_last (block, rec)) while (!rtems_rtl_unresolved_rec_is_last (block, rec))
{ {
@@ -343,24 +343,24 @@ rtems_rtl_unresolved_interate (rtems_rtl_unresolved_iterator_t iterator,
} }
bool bool
rtems_rtl_unresolved_add (rtems_rtl_obj_t* obj, rtems_rtl_unresolved_add (rtems_rtl_obj* obj,
const uint16_t flags, const uint16_t flags,
const char* name, const char* name,
const uint16_t sect, const uint16_t sect,
const rtems_rtl_word_t* rel) const rtems_rtl_word* rel)
{ {
rtems_rtl_unresolved_t* unresolved; rtems_rtl_unresolved* unresolved;
rtems_chain_node* node; rtems_chain_node* node;
rtems_rtl_unresolv_block_t* block; rtems_rtl_unresolv_block* block;
rtems_rtl_unresolv_rec_t* rec; rtems_rtl_unresolv_rec* rec;
int name_index; int name_index;
size_t name_recs; size_t name_recs;
if (rtems_rtl_trace (RTEMS_RTL_TRACE_UNRESOLVED)) if (rtems_rtl_trace (RTEMS_RTL_TRACE_UNRESOLVED))
printf ("rtl: unresolv: add: %s(s:%d) -> %s\n", printf ("rtl: unresolv: add: %s(s:%d) -> %s\n",
rtems_rtl_obj_oname (obj), sect, name); rtems_rtl_obj_oname (obj), sect, name);
unresolved = rtems_rtl_unresolved (); unresolved = rtems_rtl_unresolved_unprotected ();
if (!unresolved) if (!unresolved)
return false; return false;
@@ -371,7 +371,7 @@ rtems_rtl_unresolved_add (rtems_rtl_obj_t* obj,
block = NULL; block = NULL;
while (!rtems_chain_is_tail (&unresolved->blocks, node)) while (!rtems_chain_is_tail (&unresolved->blocks, node))
{ {
block = (rtems_rtl_unresolv_block_t*) node; block = (rtems_rtl_unresolv_block*) node;
if (block->recs < unresolved->block_recs) if (block->recs < unresolved->block_recs)
break; break;
block = NULL; block = NULL;
@@ -397,7 +397,7 @@ rtems_rtl_unresolved_add (rtems_rtl_obj_t* obj,
*/ */
if (name_index < 0) if (name_index < 0)
{ {
rtems_rtl_unresolv_block_t* name_block = block; rtems_rtl_unresolv_block* name_block = block;
/* /*
* Is there enough room to fit the name ? It not add a new block. * Is there enough room to fit the name ? It not add a new block.
@@ -447,7 +447,7 @@ rtems_rtl_unresolved_add (rtems_rtl_obj_t* obj,
void void
rtems_rtl_unresolved_resolve (void) rtems_rtl_unresolved_resolve (void)
{ {
rtems_rtl_unresolved_reloc_data_t rd; rtems_rtl_unresolved_reloc_data rd;
if (rtems_rtl_trace (RTEMS_RTL_TRACE_UNRESOLVED)) if (rtems_rtl_trace (RTEMS_RTL_TRACE_UNRESOLVED))
printf ("rtl: unresolv: global resolve\n"); printf ("rtl: unresolv: global resolve\n");
rd.name = 0; rd.name = 0;
@@ -458,15 +458,14 @@ rtems_rtl_unresolved_resolve (void)
} }
bool bool
rtems_rtl_unresolved_remove (rtems_rtl_obj_t* obj, rtems_rtl_unresolved_remove (rtems_rtl_obj* obj,
const char* name, const char* name,
const uint16_t sect, const uint16_t sect,
const rtems_rtl_word_t* rel) const rtems_rtl_word* rel)
{ {
rtems_rtl_unresolved_t* unresolved; rtems_rtl_unresolved* unresolved;
unresolved = rtems_rtl_unresolved (); unresolved = rtems_rtl_unresolved_unprotected ();
if (!unresolved) if (!unresolved)
return false; return false;
return false; return false;
} }

View File

@@ -1,5 +1,5 @@
/* /*
* COPYRIGHT (c) 2012-2016 Chris Johns <chrisj@rtems.org> * COPYRIGHT (c) 2012-2016, 2018 Chris Johns <chrisj@rtems.org>
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at
@@ -35,9 +35,9 @@ void __register_frame (void *begin);
void __deregister_frame (void *begin); void __deregister_frame (void *begin);
bool bool
rtems_rtl_elf_unwind_dw2_parse (const rtems_rtl_obj_t* obj, rtems_rtl_elf_unwind_dw2_parse (const rtems_rtl_obj* obj,
const char* name, const char* name,
uint32_t flags) uint32_t flags)
{ {
return return
((flags & RTEMS_RTL_OBJ_SECT_CONST) != 0) && ((flags & RTEMS_RTL_OBJ_SECT_CONST) != 0) &&
@@ -46,9 +46,9 @@ rtems_rtl_elf_unwind_dw2_parse (const rtems_rtl_obj_t* obj,
} }
bool bool
rtems_rtl_elf_unwind_dw2_register (const rtems_rtl_obj_t* obj) rtems_rtl_elf_unwind_dw2_register (const rtems_rtl_obj* obj)
{ {
rtems_rtl_obj_sect_t* sect = rtems_rtl_obj_find_section (obj, ".eh_frame"); rtems_rtl_obj_sect* sect = rtems_rtl_obj_find_section (obj, ".eh_frame");
if (sect != NULL && sect->size > 0 && sect->base != NULL) if (sect != NULL && sect->size > 0 && sect->base != NULL)
{ {
@@ -58,9 +58,9 @@ rtems_rtl_elf_unwind_dw2_register (const rtems_rtl_obj_t* obj)
return true; return true;
} }
bool rtems_rtl_elf_unwind_dw2_deregister (const rtems_rtl_obj_t* obj) bool rtems_rtl_elf_unwind_dw2_deregister (const rtems_rtl_obj* obj)
{ {
rtems_rtl_obj_sect_t* sect = rtems_rtl_obj_find_section (obj, ".eh_frame"); rtems_rtl_obj_sect* sect = rtems_rtl_obj_find_section (obj, ".eh_frame");
if (sect != NULL && sect->size > 0 && sect->base != NULL) if (sect != NULL && sect->size > 0 && sect->base != NULL)
{ {

View File

@@ -1,5 +1,5 @@
/* /*
* COPYRIGHT (c) 2016 Chris Johns <chrisj@rtems.org> * COPYRIGHT (c) 2016, 2018 Chris Johns <chrisj@rtems.org>
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at
@@ -42,9 +42,9 @@ extern "C" {
* @retval true The section contains unwind information. * @retval true The section contains unwind information.
* @retval false The section does not contain unwind information. * @retval false The section does not contain unwind information.
*/ */
bool rtems_rtl_elf_unwind_dw2_parse (const rtems_rtl_obj_t* obj, bool rtems_rtl_elf_unwind_dw2_parse (const rtems_rtl_obj* obj,
const char* name, const char* name,
uint32_t flags); uint32_t flags);
/** /**
* Architecture specific handler to add an object file's unwind information to * Architecture specific handler to add an object file's unwind information to
@@ -54,7 +54,7 @@ bool rtems_rtl_elf_unwind_dw2_parse (const rtems_rtl_obj_t* obj,
* @retval true The unwind information has been registered. * @retval true The unwind information has been registered.
* @retval false The unwind information could not be registered. * @retval false The unwind information could not be registered.
*/ */
bool rtems_rtl_elf_unwind_dw2_register (const rtems_rtl_obj_t* obj); bool rtems_rtl_elf_unwind_dw2_register (const rtems_rtl_obj* obj);
/** /**
* Architecture specific handler to remove an object file's unwind information * Architecture specific handler to remove an object file's unwind information
@@ -64,7 +64,7 @@ bool rtems_rtl_elf_unwind_dw2_register (const rtems_rtl_obj_t* obj);
* @retval true The unwind information has been deregistered. * @retval true The unwind information has been deregistered.
* @retval false The unwind information could not be deregistered. * @retval false The unwind information could not be deregistered.
*/ */
bool rtems_rtl_elf_unwind_dw2_deregister (const rtems_rtl_obj_t* obj); bool rtems_rtl_elf_unwind_dw2_deregister (const rtems_rtl_obj* obj);
/** /**
* Read signed and unsigned LEB128 values. * Read signed and unsigned LEB128 values.

View File

@@ -1,5 +1,5 @@
/* /*
* COPYRIGHT (c) 2016 Chris Johns <chrisj@rtems.org> * COPYRIGHT (c) 2016, 2018 Chris Johns <chrisj@rtems.org>
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at
@@ -32,9 +32,9 @@ extern "C" {
* @retval true The section contains unwind information. * @retval true The section contains unwind information.
* @retval false The section does not contain unwind information. * @retval false The section does not contain unwind information.
*/ */
bool rtems_rtl_elf_unwind_parse (const rtems_rtl_obj_t* obj, bool rtems_rtl_elf_unwind_parse (const rtems_rtl_obj* obj,
const char* name, const char* name,
uint32_t flags); uint32_t flags);
/** /**
* Architecture specific handler to add an object file's unwind information to * Architecture specific handler to add an object file's unwind information to
@@ -44,7 +44,7 @@ bool rtems_rtl_elf_unwind_parse (const rtems_rtl_obj_t* obj,
* @retval true The unwind information has been registered. * @retval true The unwind information has been registered.
* @retval false The unwind information could not be registered. * @retval false The unwind information could not be registered.
*/ */
bool rtems_rtl_elf_unwind_register (rtems_rtl_obj_t* obj); bool rtems_rtl_elf_unwind_register (rtems_rtl_obj* obj);
/** /**
* Architecture specific handler to remove an object file's unwind information * Architecture specific handler to remove an object file's unwind information
@@ -54,7 +54,7 @@ bool rtems_rtl_elf_unwind_register (rtems_rtl_obj_t* obj);
* @retval true The unwind information has been deregistered. * @retval true The unwind information has been deregistered.
* @retval false The unwind information could not be deregistered. * @retval false The unwind information could not be deregistered.
*/ */
bool rtems_rtl_elf_unwind_deregister (rtems_rtl_obj_t* obj); bool rtems_rtl_elf_unwind_deregister (rtems_rtl_obj* obj);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@@ -1,5 +1,5 @@
/* /*
* COPYRIGHT (c) 2012 Chris Johns <chrisj@rtems.org> * COPYRIGHT (c) 2012, 2018 Chris Johns <chrisj@rtems.org>
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at
@@ -54,8 +54,8 @@
/** /**
* Static RTL data is returned to the user when the linker is locked. * Static RTL data is returned to the user when the linker is locked.
*/ */
static rtems_rtl_data_t* rtl; static rtems_rtl_data* rtl;
static bool rtl_data_init; static bool rtl_data_init;
/** /**
* Define a default base global symbol loader function that is weak * Define a default base global symbol loader function that is weak
@@ -101,7 +101,7 @@ rtems_rtl_data_init (void)
/* /*
* Always in the heap. * Always in the heap.
*/ */
rtl = malloc (sizeof (rtems_rtl_data_t)); rtl = malloc (sizeof (rtems_rtl_data));
if (!rtl) if (!rtl)
{ {
rtems_libio_unlock (); rtems_libio_unlock ();
@@ -109,7 +109,7 @@ rtems_rtl_data_init (void)
return false; return false;
} }
*rtl = (rtems_rtl_data_t) { 0 }; *rtl = (rtems_rtl_data) { 0 };
/* /*
* The initialise the allocator data. * The initialise the allocator data.
@@ -230,13 +230,13 @@ rtems_rtl_data_init (void)
return true; return true;
} }
rtems_rtl_data_t* rtems_rtl_data*
rtems_rtl_data (void) rtems_rtl_data_unprotected (void)
{ {
return rtl; return rtl;
} }
rtems_rtl_symbols_t* rtems_rtl_symbols*
rtems_rtl_global_symbols (void) rtems_rtl_global_symbols (void)
{ {
if (!rtl) if (!rtl)
@@ -247,8 +247,8 @@ rtems_rtl_global_symbols (void)
return &rtl->globals; return &rtl->globals;
} }
rtems_rtl_unresolved_t* rtems_rtl_unresolved*
rtems_rtl_unresolved (void) rtems_rtl_unresolved_unprotected (void)
{ {
if (!rtl) if (!rtl)
{ {
@@ -259,9 +259,9 @@ rtems_rtl_unresolved (void)
} }
void void
rtems_rtl_obj_caches (rtems_rtl_obj_cache_t** symbols, rtems_rtl_obj_caches (rtems_rtl_obj_cache** symbols,
rtems_rtl_obj_cache_t** strings, rtems_rtl_obj_cache** strings,
rtems_rtl_obj_cache_t** relocs) rtems_rtl_obj_cache** relocs)
{ {
if (!rtl) if (!rtl)
{ {
@@ -295,11 +295,11 @@ rtems_rtl_obj_caches_flush (void)
} }
void void
rtems_rtl_obj_comp (rtems_rtl_obj_comp_t** decomp, rtems_rtl_obj_decompress (rtems_rtl_obj_comp** decomp,
rtems_rtl_obj_cache_t* cache, rtems_rtl_obj_cache* cache,
int fd, int fd,
int compression, int compression,
off_t offset) off_t offset)
{ {
if (!rtl) if (!rtl)
{ {
@@ -312,7 +312,7 @@ rtems_rtl_obj_comp (rtems_rtl_obj_comp_t** decomp,
} }
} }
rtems_rtl_data_t* rtems_rtl_data*
rtems_rtl_lock (void) rtems_rtl_lock (void)
{ {
if (!rtems_rtl_data_init ()) if (!rtems_rtl_data_init ())
@@ -329,10 +329,10 @@ rtems_rtl_unlock (void)
rtems_recursive_mutex_unlock (&rtl->lock); rtems_recursive_mutex_unlock (&rtl->lock);
} }
rtems_rtl_obj_t* rtems_rtl_obj*
rtems_rtl_check_handle (void* handle) rtems_rtl_check_handle (void* handle)
{ {
rtems_rtl_obj_t* obj; rtems_rtl_obj* obj;
rtems_chain_node* node; rtems_chain_node* node;
obj = handle; obj = handle;
@@ -340,7 +340,7 @@ rtems_rtl_check_handle (void* handle)
while (!rtems_chain_is_tail (&rtl->objects, node)) while (!rtems_chain_is_tail (&rtl->objects, node))
{ {
rtems_rtl_obj_t* check = (rtems_rtl_obj_t*) node; rtems_rtl_obj* check = (rtems_rtl_obj*) node;
if (check == obj) if (check == obj)
return obj; return obj;
node = rtems_chain_next (node); node = rtems_chain_next (node);
@@ -349,11 +349,11 @@ rtems_rtl_check_handle (void* handle)
return NULL; return NULL;
} }
rtems_rtl_obj_t* rtems_rtl_obj*
rtems_rtl_find_obj (const char* name) rtems_rtl_find_obj (const char* name)
{ {
rtems_chain_node* node; rtems_chain_node* node;
rtems_rtl_obj_t* found = NULL; rtems_rtl_obj* found = NULL;
const char* aname = NULL; const char* aname = NULL;
const char* oname = NULL; const char* oname = NULL;
off_t ooffset; off_t ooffset;
@@ -365,7 +365,7 @@ rtems_rtl_find_obj (const char* name)
while (!rtems_chain_is_tail (&rtl->objects, node)) while (!rtems_chain_is_tail (&rtl->objects, node))
{ {
rtems_rtl_obj_t* obj = (rtems_rtl_obj_t*) node; rtems_rtl_obj* obj = (rtems_rtl_obj*) node;
if ((aname == NULL && strcmp (obj->oname, oname) == 0) || if ((aname == NULL && strcmp (obj->oname, oname) == 0) ||
(aname != NULL && (aname != NULL &&
strcmp (obj->aname, aname) == 0 && strcmp (obj->oname, oname) == 0)) strcmp (obj->aname, aname) == 0 && strcmp (obj->oname, oname) == 0))
@@ -385,10 +385,10 @@ rtems_rtl_find_obj (const char* name)
return found; return found;
} }
rtems_rtl_obj_t* rtems_rtl_obj*
rtems_rtl_load_object (const char* name, int mode) rtems_rtl_load_object (const char* name, int mode)
{ {
rtems_rtl_obj_t* obj; rtems_rtl_obj* obj;
if (rtems_rtl_trace (RTEMS_RTL_TRACE_LOAD)) if (rtems_rtl_trace (RTEMS_RTL_TRACE_LOAD))
printf ("rtl: loading '%s'\n", name); printf ("rtl: loading '%s'\n", name);
@@ -464,7 +464,7 @@ rtems_rtl_load_object (const char* name, int mode)
} }
bool bool
rtems_rtl_unload_object (rtems_rtl_obj_t* obj) rtems_rtl_unload_object (rtems_rtl_obj* obj)
{ {
bool ok = true; bool ok = true;
@@ -505,7 +505,7 @@ rtems_rtl_unload_object (rtems_rtl_obj_t* obj)
} }
void void
rtems_rtl_run_ctors (rtems_rtl_obj_t* obj) rtems_rtl_run_ctors (rtems_rtl_obj* obj)
{ {
rtems_rtl_obj_run_ctors (obj); rtems_rtl_obj_run_ctors (obj);
} }
@@ -615,7 +615,7 @@ rtems_rtl_base_sym_global_add (const unsigned char* esyms,
rtems_rtl_unlock (); rtems_rtl_unlock ();
} }
rtems_rtl_obj_t* rtems_rtl_obj*
rtems_rtl_baseimage (void) rtems_rtl_baseimage (void)
{ {
return NULL; return NULL;