diff options
Diffstat (limited to 'cpukit/include')
-rw-r--r-- | cpukit/include/rtems/rtl/rtl-obj-fwd.h | 6 | ||||
-rw-r--r-- | cpukit/include/rtems/rtl/rtl-obj.h | 109 | ||||
-rw-r--r-- | cpukit/include/rtems/rtl/rtl-sym.h | 4 | ||||
-rw-r--r-- | cpukit/include/rtems/rtl/rtl.h | 25 |
4 files changed, 128 insertions, 16 deletions
diff --git a/cpukit/include/rtems/rtl/rtl-obj-fwd.h b/cpukit/include/rtems/rtl/rtl-obj-fwd.h index 39e28c58e1..6d41483aa2 100644 --- a/cpukit/include/rtems/rtl/rtl-obj-fwd.h +++ b/cpukit/include/rtems/rtl/rtl-obj-fwd.h @@ -27,6 +27,12 @@ struct rtems_rtl_obj_sect; typedef struct rtems_rtl_obj_sect rtems_rtl_obj_sect; /** + * The forward declaration of the obj depends structure. + */ +struct rtems_rtl_obj_depends; +typedef struct rtems_rtl_obj_depends rtems_rtl_obj_depends; + +/** * The forward declaration of the obj structure. */ struct rtems_rtl_obj; diff --git a/cpukit/include/rtems/rtl/rtl-obj.h b/cpukit/include/rtems/rtl/rtl-obj.h index be77a81c9d..976d6c293f 100644 --- a/cpukit/include/rtems/rtl/rtl-obj.h +++ b/cpukit/include/rtems/rtl/rtl-obj.h @@ -139,12 +139,35 @@ struct rtems_rtl_obj_sect }; /** + * Object file dependents. This is a list of tables of pointers to the object + * modules the object file depends on. The table is a list of tables because + * unresolved externals can exist when an object file is loaded and resolved + * later when the dependent object file is loaded. + */ +struct rtems_rtl_obj_depends +{ + rtems_chain_node node; /**< The node's link in the chain. */ + size_t dependents; /**< The number of dependent object pointers. */ + rtems_rtl_obj* depends[]; /**< Dependtent objects. More follow. */ +}; + +/** + * Dependency iterator. + */ +typedef bool (*rtems_rtl_obj_depends_iterator) (rtems_rtl_obj* obj, + rtems_rtl_obj* dependent, + void* data); + +/** * Object file descriptor flags. */ -#define RTEMS_RTL_OBJ_LOCKED (1 << 0) /**< Lock the object file so it cannot - * be unloaded. */ -#define RTEMS_RTL_OBJ_UNRESOLVED (1 << 1) /**< The object file has unresolved - * external symbols. */ +#define RTEMS_RTL_OBJ_LOCKED (1 << 0) /**< Lock the object file so it cannot + * be unloaded. */ +#define RTEMS_RTL_OBJ_UNRESOLVED (1 << 1) /**< The object file has unresolved + * external symbols. */ +#define RTEMS_RTL_OBJ_BASE (1 << 2) /**< The base image. */ +#define RTEMS_RTL_OBJ_RELOC_TAG (1 << 3) /**< Tag the object as visited when reloc + * parsing. */ /** * RTL Object. There is one for each object module loaded plus one for the base @@ -154,7 +177,8 @@ struct rtems_rtl_obj { rtems_chain_node link; /**< The node's link in the chain. */ uint32_t flags; /**< The status of the object file. */ - uint32_t users; /**< References to the object file. */ + size_t users; /**< Users of this object file, number of loads. */ + size_t refs; /**< References to the object file. */ int format; /**< The format of the object file. */ const char* fname; /**< The file name for the object. */ const char* oname; /**< The object file name. Can be @@ -164,27 +188,28 @@ struct rtems_rtl_obj * in a lib */ off_t ooffset; /**< The object offset in the archive. */ size_t fsize; /**< Size of the object file. */ - rtems_chain_control sections; /**< The sections of interest in the - * object file. */ + rtems_chain_control sections; /**< The sections of interest in the object + * file. */ + rtems_chain_control dependents; /**< The dependent object files. */ rtems_rtl_obj_sym* local_table; /**< Local symbol table. */ size_t local_syms; /**< Local symbol count. */ size_t local_size; /**< Local symbol memory usage. */ rtems_rtl_obj_sym* global_table; /**< Global symbol table. */ size_t global_syms; /**< Global symbol count. */ size_t global_size; /**< Global symbol memory usage. */ - uint32_t unresolved; /**< The number of unresolved relocations. */ + size_t unresolved; /**< The number of unresolved relocations. */ void* text_base; /**< The base address of the text section * in memory. */ size_t text_size; /**< The size of the text section. */ void* const_base; /**< The base address of the const section * in memory. */ - void* eh_base; /**< The base address of the eh section - * in memory. */ + void* eh_base; /**< The base address of the eh section in + * memory. */ size_t eh_size; /**< The size of the eh section. */ void* data_base; /**< The base address of the data section * in memory. */ - void* bss_base; /**< The base address of the bss section - * in memory. */ + void* bss_base; /**< The base address of the bss section in + * memory. */ size_t bss_size; /**< The size of the bss section. */ size_t exec_size; /**< The amount of executable memory * allocated */ @@ -192,9 +217,11 @@ struct rtems_rtl_obj uint32_t checksum; /**< The checksum of the text sections. A * zero means do not checksum. */ 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. */ - void* loader; /**< The file details specific to a loader. */ + void* loader; /**< The file details specific to a + * loader. */ }; /** @@ -443,6 +470,46 @@ rtems_rtl_obj_sect* rtems_rtl_obj_find_section_by_mask (const rtems_rtl_obj* obj uint32_t mask); /** + * Allocate a table for dependent objects. + * + * @param obj The object file's descriptor. + * @param dependents The size of the table. + * @retval true The table was allocated. + * @retval false The alloction failed. + */ +bool rtems_rtl_obj_alloc_dependents (rtems_rtl_obj* obj, size_t dependents); + +/** + * Erase the object file descriptor's dependents. + * + * @param obj The object file's descriptor. + */ +void rtems_rtl_obj_erase_dependents (rtems_rtl_obj* obj); + +/** + * Add an object file to the dependents table. + * + * @param obj The object file's descriptor. + * @param dependent The dependent object file to add. + * @retval true The dependent has been added to the table. + * @retval false There is no space in the table. + */ +bool rtems_rtl_obj_add_dependent (rtems_rtl_obj* obj, rtems_rtl_obj* dependent); + +/** + * Iterate over the module dependenices. + * + * @param obj The object file's descriptor. + * @param handler The iterator handler. Returns true to end. + * @param data User data passed to the iterator. + * @retval true The iterator handler returned true. + * @retval false The iterator handler returned false. + */ +bool rtems_rtl_obj_iterate_dependents (rtems_rtl_obj* obj, + rtems_rtl_obj_depends_iterator iterator, + void* data); + +/** * The text section size. Only use once all the sections has been added. It * includes alignments between sections that are part of the object's text * area. The consts sections are included in this section. @@ -643,6 +710,20 @@ void rtems_rtl_obj_run_ctors (rtems_rtl_obj* obj); void rtems_rtl_obj_run_dtors (rtems_rtl_obj* obj); /** + * Increment the object file reference count. + * + * @param obj The object file's descriptor. + */ +void rtems_rtl_obj_inc_reference (rtems_rtl_obj* obj); + +/** + * Decrement the object file reference count. + * + * @param obj The object file's descriptor. + */ +void rtems_rtl_obj_dec_reference (rtems_rtl_obj* obj); + +/** * Load the object file, reading all sections into memory, symbols and * performing any relocation fixups. * diff --git a/cpukit/include/rtems/rtl/rtl-sym.h b/cpukit/include/rtems/rtl/rtl-sym.h index be246a908d..aff9339ea1 100644 --- a/cpukit/include/rtems/rtl/rtl-sym.h +++ b/cpukit/include/rtems/rtl/rtl-sym.h @@ -92,7 +92,7 @@ bool rtems_rtl_symbol_global_add (rtems_rtl_obj* obj, * * @param name The name as an ASCIIZ string. * @retval NULL No symbol found. - * @return rtems_rtl_obj_sym_t* Reference to the symbol. + * @return rtems_rtl_obj_sym* Reference to the symbol. */ rtems_rtl_obj_sym* rtems_rtl_symbol_global_find (const char* name); @@ -102,7 +102,7 @@ rtems_rtl_obj_sym* rtems_rtl_symbol_global_find (const char* name); * @param obj The object file to search. * @param name The name as an ASCIIZ string. * @retval NULL No symbol found. - * @return rtems_rtl_obj_sym_t* Reference to the symbol. + * @return rtems_rtl_obj_sym* Reference to the symbol. */ rtems_rtl_obj_sym* rtems_rtl_symbol_obj_find (rtems_rtl_obj* obj, const char* name); diff --git a/cpukit/include/rtems/rtl/rtl.h b/cpukit/include/rtems/rtl/rtl.h index e30dba90ef..398ac2cd3f 100644 --- a/cpukit/include/rtems/rtl/rtl.h +++ b/cpukit/include/rtems/rtl/rtl.h @@ -28,6 +28,7 @@ #include <rtems/rtl/rtl-obj.h> #include <rtems/rtl/rtl-obj-cache.h> #include <rtems/rtl/rtl-obj-comp.h> +#include <rtems/rtl/rtl-sym.h> #include <rtems/rtl/rtl-unresolved.h> #ifdef __cplusplus @@ -71,6 +72,11 @@ extern "C" { #define RTEMS_RTL_UNRESOLVED_BLOCK_SIZE (64) /** + * The number of dependency record per block in the dependency table. + */ +#define RTEMS_RTL_DEPENDENCY_BLOCK_SIZE (16) + +/** * The global debugger interface variable. */ extern struct r_debug _rtld_debug; @@ -173,6 +179,16 @@ void rtems_rtl_obj_decompress (rtems_rtl_obj_comp** decomp, off_t offset); /** + * Update the mask in the object files. You can clear flags and then set + * flags. A zero (0) does not clear or set the flags. This is global to all + * object files that are laoded. + * + * @param clear The flag's clear mask, a 0 does not clear any flags. + * @param set The flag's set mask, a 0 does not set any flags. + */ +void rtems_rtl_obj_update_flags (uint32_t clear, uint32_t set); + +/** * Lock the Run-time Linker. * * @return rtems_rtl_data* The RTL data after being locked. @@ -207,6 +223,15 @@ rtems_rtl_obj* rtems_rtl_check_handle (void* handle); rtems_rtl_obj* rtems_rtl_find_obj (const char* name); /** + * Find the object file a symbol is exported from. + * + * @param sym The symbol to search with. + * @retval NULL No object file found. + * @return rtems_rtl_obj* Reference to the symbol. + */ +rtems_rtl_obj* rtems_rtl_find_obj_with_symbol (const rtems_rtl_obj_sym* sym); + +/** * Load an object file into memory relocating it. It will not be resolved * against other symbols in other object files or the base image. * |