source: rtems-docs/user/tools/symbols.rst

Last change on this file was d5b631f, checked in by Chris Johns <chrisj@…>, on 02/27/19 at 21:36:39

User: Change output block to type none.

  • Property mode set to 100644
File size: 6.2 KB
Line 
1.. SPDX-License-Identifier: CC-BY-SA-4.0
2
3.. Copyright (C) 2017 Chris Johns <chrisj@rtems.org>
4
5.. _RTEMSSymbols:
6
7RTEMS Symbols
8=============
9
10.. index:: Tools, rtems-syms
11
12The RTEMS Symbols (:program:`rtems-syms`) command is an RTEMS tool to generate
13symbol tables used by the RTEMS Runtime Loader (RTL). The symbol table contains
14the exported base kernel symbols user code dynamically loaded can reference.
15
16The RTEMS Runtime Loader supports two methods of loading a symbol table,
17embedded and runtime loading. Embedding the table requires linking the symbol
18table with the base image and runtime loading loads the table using the dynamic
19loader when RTEMS is running.
20
21.. sidebar:: *Filtering Symbols*
22
23   Currently there is no filtering of symbols in the symbol table. This means
24   all base kernel image symbols are present in the symbol table when only a
25   sub-set of the symbols are referenced.
26
27Embedding the symbol table creates self contained images. A target may not have
28any external media, for example RTEMS tests, or there is a requirement to avoid
29the management need to match the symbol table with the kernel base
30image. Embedding the symbol table requires a 2-pass link process making the
31application's build system more complicated.
32
33A dynamically loadable symbol table is simpler to create however the symbol
34table and the kernel base image must match or the behaviour is undefined. There
35is currently no mechnanisum to ensure the symbol table and the kernel image
36match The :program:`rtems-syms` command is run against the base kernel image
37and the generated symbol table is installed on to the target hardware and
38loaded before any other modules.
39
40Symbol Table
41------------
42
43The symbol table is an ELF object file in the target's ELF format and is built
44using the target's RTEMS C compiler. The :program:`rtems-syms` command searches
45for the C compller under the prefix this command is installed under or the
46system path. If the target's C compiler is not located in either of these paths
47use the option ``-c`` or ``--cc`` to specify the path to the compiler.
48
49The :program:`rtems-syms` command loads the base kernel image's ELF file and
50reads the global or public symbols, creates a temporary C file and then
51compiles it using the target's RTEMS C compiler. The command automatically
52detects the architecture from the base kernel image's ELF file and uses it to
53create the C compiler's name. The option ``-E`` or ``--exec-prefix`` can be
54used to override the executable prefix used.
55
56It is important to supply suitable C compiler flags (``cflags``) that match the
57kernel image's so the symbol table can be linked or loaded.
58
592-Pass Linking
60--------------
61
622-Pass linking is used to embed a symbol table in a base kernel image. The
63first link pass is a normal RTEMS kernel link process. The link output is
64passed to the :program:`rtems-syms` command and the ``-e`` or ``--embed``
65option is used. The symbol table object file created by :program:`rtems-syms`
66is added to the linker command used in the first pass to create the second
67pass. The address map will change between the first pass and second pass
68without causing a problem, the symbol table embedded in the second link pass
69will adjust the symbol addresses to match.
70
71Command
72-------
73
74:program:`rtems-syms` [options] kernel
75
76.. option:: -V, --version
77
78   Display the version information and then exit.
79
80.. option:: -v, --verbose
81
82   Increase the verbose level by 1. The option can be used more than once to
83   get more detailed trace and debug information.
84
85.. option:: -w, --warn
86
87   Enable build warnings. This is useful when debugging symbol table
88   generation.
89
90.. option:: -k, --keep
91
92   Do not delete temporary files on exit, keep them.
93
94.. option:: -e, --embed
95
96   Create a symbol table that can be embedded in the base kernel image using a
97   2-pass link process.
98
99.. option:: -S, --symc
100
101   Specify the symbol's C source file. The defautl is to use a temporary file
102   name.
103
104.. option:: -o, --output
105
106   Specify the ELF output file name.
107
108.. option:: -m, --map
109
110   Create a map file using the provided file name.
111
112.. option:: -C, --cc
113
114   Specify the C compile executable file name. The file can be absolute and no
115   path is search or relative and the environment's path is searched.
116
117.. option:: -E, --exec-prefix
118
119   Specify the RTEMS tool prefix. For example for RTEMS 5 and the SPARC
120   architecture the prefix is ``sparc-rtems5``.
121
122.. option:: -c, --cflags
123
124   Specify the C compiler flags used to build the symbol table with. These
125   should be the same or compatible with the flags used to build the RTEMS
126   kernel.
127
128.. option:: -?, -h
129
130   Reort the usage help.
131
132Examples
133--------
134
135Create a dynamlically loaded symbol table for the ``minimum.exe`` sample
136program for the ``i386/pc686`` BSP:
137
138.. code-block:: none
139
140  $ rtems-syms -o ms.o i386-rtems5/c/pc686/testsuites/samples/minimum/minimum.exe
141  $ file ms.o
142  ms.o: ELF 32-bit LSB relocatable, Intel 80386, version 1 (SYSV), not stripped
143
144Run the same command, this time create a map file:
145
146.. code-block:: none
147
148  $ rtems-syms -o ms.o -m ms.map i386-rtems5/c/pc686/testsuites/samples/minimum/minimum.exe
149  $ head -10 ms.map
150  RTEMS Kernel Symbols Map
151   kernel: i386-rtems5/c/pc686/testsuites/samples/minimum/minimum.exe
152
153  Globals:
154   No.  Index Scope      Type        SHNDX  Address    Size    Name
155      0   931 STB_GLOBAL STT_OBJECT      11 0x0012df08       4 BSPBaseBaud   (minimum.exe)
156      1  1124 STB_GLOBAL STT_OBJECT      11 0x0012d894       4 BSPPrintkPort   (minimum.exe)
157      2   836 STB_GLOBAL STT_FUNC         1 0x00104b00     302 BSP_dispatch_isr   (minimum.exe)
158      3  1156 STB_GLOBAL STT_FUNC         1 0x001082d0      92 BSP_install_rtems_shared_irq_handler   (minimum.exe)
159      4   876 STB_GLOBAL STT_FUNC         1 0x00106500     138 BSP_outch   (minimum.exe)
160
161Run the same command with a raise verbose level to observe the stages the
162command performs:
163
164.. code-block:: none
165
166  $ rtems-syms -vvv -o ms.o i386-rtems5/c/pc686/testsuites/samples/minimum/minimum.exe
167  RTEMS Kernel Symbols 5.a72a462adc18
168  kernel: i386-rtems5/c/pc686/testsuites/samples/minimum/minimum.exe
169  cache:load-sym: object files: 1
170  cache:load-sym: symbols: 1043
171  symbol C file: /tmp/rld--X7paaa.c
172  symbol O file: ms.o
173  execute: i386-rtems5-gcc -O2 -c -o ms.o /tmp/rld--X7paaa.c
174  execute: status: 0
Note: See TracBrowser for help on using the repository browser.