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

5
Last change on this file since e52906b was e52906b, checked in by Sebastian Huber <sebastian.huber@…>, on 01/09/19 at 15:14:06

Simplify SPDX-License-Identifier comment

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