source: rtems-docs/user/exe/executables.rst @ 12dccfe

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

Remove superfluous "All rights reserved."

  • Property mode set to 100644
File size: 4.5 KB
Line 
1.. comment SPDX-License-Identifier: CC-BY-SA-4.0
2
3.. Copyright (C) 2018 Chris Johns <chrisj@rtems.org>
4
5RTEMS Executable
6================
7.. index:: RTEMS Executable
8
9Running executables is the most important part of working with RTEMS, it is
10after all how you run your application and use the RTEMS kernel services.
11
12An RTEMS executable is embedded in a target and executing an embedded
13executable has challenges not faced when executing software on a desktop or
14server computer. A desktop or server operating system kernel provides all the
15support needed to bring an executable's code and data into a process's address
16space passing control to it and cleaning up when it exits. An embedded target
17has to provide similar functionality to execute an embedded executable.
18
19An RTEMS Source Builder (RSB) built RTEMS tool chain is used to create RTEMS
20executables. The tool chain executable creates a fixed position statically
21linked Extendable Loader Format (ELF) file that contains the RTEMS kernel,
22standard libraries, 3rd party libraries and application code. RTEMS executes in
23a single address space which means it does not support the ``fork`` or ``exec``
24system calls so statically linking all the code is the easiest and best way to
25create an executable.
26
27An RTEMS application is constructed vertically with the RTEMS kernel, BSP
28support code and drivers close to the hardware, above which sit the RTEMS
29Application Programming Interfaces (API) for control of threads, mutex and
30other resources an application may use. Middle-ware services like networking,
31interpreted languages, and protocol stacks sit between the RTEMS APIs and the
32application components. The software built into an executable can be see as a
33vertical software stack.
34
35.. _fig-exe-vert-stack:
36
37.. figure:: ../../images/user/exe-vert-stack.png
38   :width: 35%
39   :alt: Vertical Software Stack
40   :figclass: align-center
41
42   Vertical Software Stack
43
44Building an Application
45=======================
46.. index:: Building an Application
47
48RTEMS views any code it is running and using it's interfaces as an
49application. RTEMS conforms to a number of international standards such as
50POSIX and can build and run portable code written in languages such as C, C++
51and Ada.
52
53Applications are built from source into ELF object files, 3rd party packages
54can be built as libraries or they can be imported as source into an application
55code base. The application, 3rd party packages, RTEMS and standard libraries
56are linked to create the RTEMS executable. The executable is transferred to the
57target and a bootloader loads it from the non-volatile storage into RAM or the
58code is executed in place in the non-volatile storage. The target hardware
59defines what happens.
60
61.. _fig-exe-app:
62
63.. figure:: ../../images/user/exe-app.png
64   :width: 90%
65   :alt: Building an Application
66   :figclass: align-center
67
68   Building an Application
69
70The standard and 3rd party libraries are a collection of object files built
71using the same set of tools the application source is compiled with. The
72package collects it's object files into an archive or library.
73
74RTEMS does not provide a standard application build system. The RTEMS ecosystem
75provides support so a range of build systems can be used. Applications can be
76built with ``make``, ``autotools``, ``cmake``, ``waf`` and more. User should
77select a build system that meets their project, system, corporate or personal
78needs.
79
80Machine Flags and ABI
81---------------------
82.. index:: Machine flags
83.. index:: Application Binary Interface
84.. index:: ABI
85
86
87All code in an RTEMS executable must be built with the same machine flags. The
88machine flags control the instruction set and application binary interface
89(ABI) the compiler generates. As the executable is statically linked all code
90must use the same instruction set the hardware is configured to support and all
91code must conform to the same ABI. Any variation can result in unpredictable
92behavior such as crashes, failures or lock ups. It is recommend an executable
93is built with the same or equivalent tool set. Mixing of tool set versions can
94also result in undefined behavior. The RTEMS tool ``rtems-execinfo`` can audit
95an RTEMS executable and list the machine flags and compilers used.
96
97RTEMS by default does not support instruction emulation for unsupported
98instructions. RTEMS applications are normally built from source so binary
99compatibility is not as important as performance. Instruction emulation is
100costly to execute and rebuilding the executable with the correct instruction
101set only needs to be done once.
Note: See TracBrowser for help on using the repository browser.