![]() |
|
|||
File indexing completed on 2025-05-11 08:24:12
0001 /* SPDX-License-Identifier: BSD-2-Clause */ 0002 0003 /* 0004 * COPYRIGHT (c) 2012-2014, 2018 Chris Johns <chrisj@rtems.org> 0005 * 0006 * Redistribution and use in source and binary forms, with or without 0007 * modification, are permitted provided that the following conditions 0008 * are met: 0009 * 1. Redistributions of source code must retain the above copyright 0010 * notice, this list of conditions and the following disclaimer. 0011 * 2. Redistributions in binary form must reproduce the above copyright 0012 * notice, this list of conditions and the following disclaimer in the 0013 * documentation and/or other materials provided with the distribution. 0014 * 0015 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 0016 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 0017 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 0018 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 0019 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 0020 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 0021 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 0022 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 0023 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 0024 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 0025 * POSSIBILITY OF SUCH DAMAGE. 0026 */ 0027 /** 0028 * @file 0029 * 0030 * @ingroup rtems_rtl 0031 * 0032 * @brief RTEMS Run-Time Linker Object File Symbol Table. 0033 */ 0034 0035 #if !defined (_RTEMS_RTL_SYM_H_) 0036 #define _RTEMS_RTL_SYM_H_ 0037 0038 #include <rtems.h> 0039 #include "rtl-obj-fwd.h" 0040 0041 #ifdef __cplusplus 0042 extern "C" { 0043 #endif /* __cplusplus */ 0044 0045 /** 0046 * An object file symbol. 0047 */ 0048 typedef struct rtems_rtl_obj_sym 0049 { 0050 rtems_chain_node node; /**< The node's link in the chain. */ 0051 const char* name; /**< The symbol's name. */ 0052 void* value; /**< The value of the symbol. */ 0053 uint32_t data; /**< Format specific data. */ 0054 } rtems_rtl_obj_sym; 0055 0056 /** 0057 * Table of symbols stored in a hash table. 0058 */ 0059 typedef struct rtems_rtl_symbols 0060 { 0061 rtems_chain_control* buckets; 0062 size_t nbuckets; 0063 } rtems_rtl_symbols; 0064 0065 /** 0066 * A TLS variable offset call. There is one per base image TLS 0067 * variable. 0068 */ 0069 typedef size_t (*rtems_rtl_tls_offset_func)(void); 0070 0071 /** 0072 * A TLS symbol offset entry. It is used with an exported symbol table 0073 * to find a TSL table offset for a variable at runtime. 0074 */ 0075 typedef struct rtems_rtl_tls_offset 0076 { 0077 size_t index; /** exported symbol table index */ 0078 rtems_rtl_tls_offset_func offset; /** TLS offset function */ 0079 } rtems_rtl_tls_offset; 0080 0081 /** 0082 * Open a symbol table with the specified number of buckets. 0083 * 0084 * @param symbols The symbol table to open. 0085 * @param buckets The number of buckets in the hash table. 0086 * @retval true The symbol is open. 0087 * @retval false The symbol table could not created. The RTL 0088 * error has the error. 0089 */ 0090 bool rtems_rtl_symbol_table_open (rtems_rtl_symbols* symbols, 0091 size_t buckets); 0092 0093 /** 0094 * Close the table and erase the hash table. 0095 * 0096 * @param symbols Close the symbol table. 0097 */ 0098 void rtems_rtl_symbol_table_close (rtems_rtl_symbols* symbols); 0099 0100 /** 0101 * Add a table of exported symbols to the symbol table. 0102 * 0103 * The export table is a series of symbol records and each record has two 0104 * fields: 0105 * 0106 * 1. label 0107 * 2. address 0108 * 0109 * The 'label' is an ASCIIZ string of variable length. The address is of size 0110 * of an unsigned long for the target running the link editor. The byte order 0111 * is defined by the machine type because the table should be built by the 0112 * target compiler. 0113 * 0114 * The table is terminated with a nul string followed by the bytes 0xDE, 0xAD, 0115 * 0xBE, and 0xEF. This avoids alignments issues. 0116 * 0117 * @param obj The object table the symbols are for. 0118 * @param esyms The exported symbol table. 0119 * @param size The size of the table in bytes. 0120 * @param tls_offsets The TLS offsets table. If NULL none provided. 0121 * @param tls_size The number TLS offset entries in the table. 0122 */ 0123 bool rtems_rtl_symbol_global_add (rtems_rtl_obj* obj, 0124 const unsigned char* esyms, 0125 unsigned int size, 0126 const rtems_rtl_tls_offset* tls_offsets, 0127 unsigned int tls_size); 0128 0129 /** 0130 * Find a symbol given the symbol label in the global symbol table. 0131 * 0132 * @param name The name as an ASCIIZ string. 0133 * @retval NULL No symbol found. 0134 * @return rtems_rtl_obj_sym* Reference to the symbol. 0135 */ 0136 rtems_rtl_obj_sym* rtems_rtl_symbol_global_find (const char* name); 0137 0138 /** 0139 * Sort an object file's local and global symbol table. This needs to 0140 * be done before calling @ref rtems_rtl_symbol_obj_find as it 0141 * performs a binary search on the tables. 0142 * 0143 * @param obj The object file to sort. 0144 */ 0145 void rtems_rtl_symbol_obj_sort (rtems_rtl_obj* obj); 0146 0147 /** 0148 * Find a symbol given the symbol label in the local object file. 0149 * 0150 * @param obj The object file to search. 0151 * @param name The name as an ASCIIZ string. 0152 * @retval NULL No symbol found. 0153 * @return rtems_rtl_obj_sym* Reference to the symbol. 0154 */ 0155 rtems_rtl_obj_sym* rtems_rtl_symbol_obj_find (rtems_rtl_obj* obj, 0156 const char* name); 0157 0158 /** 0159 * Add the object file's symbols to the global table. 0160 * 0161 * @param obj The object file the symbols are to be added. 0162 */ 0163 void rtems_rtl_symbol_obj_add (rtems_rtl_obj* obj); 0164 0165 /** 0166 * Erase the object file's local symbols. 0167 * 0168 * @param obj The object file the local symbols are to be erased from. 0169 */ 0170 void rtems_rtl_symbol_obj_erase_local (rtems_rtl_obj* obj); 0171 0172 /** 0173 * Erase the object file's symbols. 0174 * 0175 * @param obj The object file the symbols are to be erased from. 0176 */ 0177 void rtems_rtl_symbol_obj_erase (rtems_rtl_obj* obj); 0178 0179 #ifdef __cplusplus 0180 } 0181 #endif /* __cplusplus */ 0182 0183 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |