VxWorks symbol table

Source: Internet
Author: User
Symbol table InitializationThe symbol table is used to establish the relationship between symbol names, types, and values. It is an arbitrary string ending with null. Its type is an integer that identifies various symbols. Its value is a character pointer. Symbol tables are mainly used as the basis for loading the target module, but they can be used whenever names and values need to be associated. The operating system usually has two symbol table structures: syssymtbl and statsymtbl. Syssymtbl is the system symbol table of the target machine. the symbols of the symbol module of the target module dynamically loaded by the program or tshell are added to the symbol table, the syssymtbl and statsymtbl tabs are contained in the system symbol table. Statsymtbl contains errno information. If you use the printerrno command in tshell, the table must contain this symbol. The target server of the host uses only one symbol table. The global variable tgtsymtbl is used for access. In VxWorks, the symbol table function library symlib provides functions related to symbol table operations. The system symbol table allows conflict of the same name. If a symbol of the same name is added back to the symbol table, no error is reported. When a symbol is referenced, the system uses symfindbyname by default. Therefore, the newly added symbol is always found first, replace the old symbol to complete the reference. The existence of symbols with the same name poses another problem. You cannot ensure that the searched symbols are loaded by yourself, that is, the group number cannot be guaranteed. The functions in the host symlib library are used to maintain the host symbol table tgtsymtbl. The symbol table of VxWorks is the same as the symbol table of the compiler. the symbol table of VxWorks dynamically exists in the system and is maintained by the functions provided by symlib. During running, symbols can be added and deleted, it is mainly used for dynamic loading of the target module and has nothing to do with the format of the target module. The symbol table in the compiler is static. It is generated and used by the compiler and connector when a program image is created. It is mainly used for static parsing of symbols to help build an image, their format is related to the target type. Source code debugging in the Cross-debugger. pages are supported by static symbol tables, which occupy a large space for program image. When a program is released, can be removed (the-G option is not used ). Token, used to generate a symbol array to compile and enter the program image. The tool makesymtbl.exe is used to create symtbl that contains the symbol array. the C file contains the names, addresses, and types of all global symbols in the target module. The global array name is standtbl and its size is standtblsize, which is stored in the data segment of the program image. The makestattbl.exe tool is used to create a symbol array of Status Code, which contains the names and values of all status codes defined in some header files. All status codes start with "S, this is usually the definition in the header file of the library ., The global array name becomes stattbl, and its size is stattblsize. statsymtbl is mainly used by the printerrno function, and can also be used by applications to output status information of the specific meaning, stored in the data segment of the program image. The initial mode of the symbol table is build-in and downloaded. When the built-in symbol table is used, part of the VxWorks program image is used. When the downloaded symbol table is separated from the VxWorks image, the sym file is downloaded from the target machine to obtain the symbol. If you use the download symbol table, use the host tool xsym to generate the symbol module File VxWorks. sym. The file is the same as the common target module, but it does not have data and BSS segments. After being downloaded to the target machine, it is dynamically loaded as the common target module, the symbols in the module are added to the system symbol table. The auxiliary mechanism for dynamic loading, connection, and debugging of the target symbol table does not affect the normal running of the program, as long as the target module is not dynamically loaded from the target machine, the program image symbols are statically connected for parsing, and there can be no symbols on the target machine. The host development tools use the host symbol table tgtsymtbl for cross debugging. Symbol table SynchronizationThe host and the target machine use different symbol tables. The tools used on the host cannot access all the content on the target machine, tools communicate with the target agent on the target server and the target machine. Both the host and the target machine cannot directly access the symbol information of the target machine. Both the host and the target host maintain their own symbol tables. When adding symbols, add the symbols to one of the tables and add the symbols on the wshell to the host symbol table, the symbols added on tshell are in the destination symbol table. The two tables do not share each other due to lack of time. You can add the symbol table synchronization component ------ include_sym_tbl_sync, in this way, the symbols will benefit between the host and the target machine, and the two symbol tables will be updated at the same time. The host and target hosts use different symbol tables. When the system starts, the two symbol tables have the same content. When the target module is dynamically loaded, the two symbol tables are inconsistent, after loading the target module from wshell, you want to reference the module symbol from tshell or use the host tool to debug the module after loading the module from tshell, because neither wshell nor tshell can see the module loaded by the other party, the following error may occur: Error: module contains undefined symbol unresolved symbol fatal error: to solve this problem, unresolvable symbol needs to use the symbol table synchronization mechanism. VxWorks provides the symsynclib library to synchronize symbol tables. The system is running, the symbols added from the host or target machine can be seen by the other party. symsynclib creates a synchronization task tsymsyc on the target machine, which is used as a wtx tool to connect to the target server of the host, when the task is started, the symbol table is synchronized immediately. If you no longer need to synchronize the symbol table, you can manually pause tsymsync to improve the performance of the target machine. Error statusIf there is a problem with function execution in the VxWorks library, the function returns the error value and sets the error status to indicate the specific cause and location. The error status library errnolib is used to obtain and set the error status value errno for tasks and interruptions. In VxWorks, each task and interruption has its own errno. The errno of the task is stored in TCB and is private to the task, the interrupted errno is stored in the interrupt stack. As long as the word is used, errno is valid in the interrupt processing function. The errno value of VxWorks is composed of 4 bytes. The high text indicates the database where an error occurs. The corresponding values of each database are "taget/h/vwmodnum. H ", which indicates a specific error occurred in the database. It is defined in the header file of the corresponding database. It is agreed that the Vxworks system module should use a high value, ranging from 1 ~ 500. Other values can be used by the application module. There is no rule for low-word values. Usrlib provides the printerrno function to display specific error information. printerrno finds the corresponding error information in statsymtbl based on the input errno value and displays it in the standard output. ----> Printerrno 0xd0003 0xd0003 = s_ioslib_invalid_file_descriptor "s _" indicates the status, ioslib indicates the name of the database in which an error occurs, and invalid_file_descriptor indicates the specific error of the database. If you want to call printerrno in a tshell or program to display the error message, the program image must contain the error code component --- Include_stat_sym_tblTo create statsymtbl on the target machine. 'If you cannot use printerrno, you can also manually find the header file to get the error message, such as "d0003", first in vwmodnum. h. Find the library corresponding to "D", convert "D" to "13" in decimal format, find m_ioslib: # define m_ioslib (13 <16), and then go to the ioslib library's own header file ioslib. h. The macro corresponding to "0003" is defined as: # define s_ioslib_invalid_file_descriptor (m_ioslib | 3). This macro definition name is the error information you need to know.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.