This article was originally published by LinuxDevices.com, June 4, 2002, at http://www.linuxdevices.com/articles/AT8943314364.html. With the kind permission of LinuxDevices.com, it is being reproduced here.
LynxOS® v4.0, the newest release of the POSIX®-conformant hard real-time operating system (RTOS), has support for Linux® ABI compatibility—where Linux application binaries can run unchanged in the LynxOS environment without necessitating source code recompilation. This white paper examines the issues surrounding ABI compatibility in general and describes the architecture of the Linux ABI compatibility layer on LynxOS v4.0.
Application Binary Interface or ABI refers to the run-time interfaces between an application program and the OS environment where it is executing. The components of the OS environment that form the ABI for a particular OS are:
The OS environment usually provides a single
object file format by default for all applications within this environment. The various object file formats
that are used within the OS environment are
ELF. The OS
environment also consists of a set of well-defined
defined within the OS or in a set of dynamically linked libraries.
Application programs typically invoke these
to access OS services through the dynamically linked libraries.
The run-time linking and loading support in the OS facilitates
program execution by resolving all unresolved
in the application to the dynamically linked libraries at run-time.
The LynxOS ABI environment is shown in Figure 1.
ABI compatibility refers to the extent of run-time support provided by two different OS environments to support execution of application programs. The extent of ABI compatibility that exists between two OS environments dictates whether application programs that are created under one environment will run unchanged in the other environment. ABI compatibility if supported between two OS environments obviates the need to re-compile and re-link application programs built in one environment, in order to run in a different environment.
This has several benefits since it helps to surmount difficult legacy issues like unavailability of source code, unavailability of the technical expertise familiar with the application and unavailability of current resources.
ABI compatibility can extend to application programs executing in the following environments:
|Partitioning Operating Systems Versus Process-based Operating Systems|
|Real-time Secure Operating System|
|The Technology Behind LynxOS v4.0's Linux ABI Compatibility|
|Using the Microprocessor MMU for Software Protection in Real-Time Systems|
|Providing Open Architecture High Availability Solutions (PDF, 815kB)|
|Patented Threaded I/O Handling|
|An Empirical Evaluation of OS Endsystem Support for Real-time CORBA Object Request Brokers (at Washington University)|
|POSIX in Real-Time (at embedded.com)|
|MORE WHITE PAPERS|
The LynxOS-Linux ABI compatibility layer provides Linux ABI compatibility on LynxOS and provides an execution environment for Linux application programs to run unchanged in a true hard real-time environment.
The Linux ABI compatibility support in LynxOS v4.0 creates an OS execution environment for Linux applications that is similar to the one provided by the Linux operating system. The key components that are provided for Linux ABI compatibility in LynxOS are described in the next sections.
LynxOS v4.0 uses the ELF (Executable and Linking Format) as its default object file format. This ensures file format compatibility with Linux, which also uses the ELF file format as its default and provides the basic platform for ABI compatibility.
All well-behaved Linux applications are linked dynamically by default. (The Linux Standards Base / LSB specification defines a Linux application as LSB-conforming only if it is dynamically linked.) The Linux OS environment by default builds an application with dynamically linked library dependencies that are subsequently resolved by the run-time linker and loader during program execution. The resolution of these shared library dependencies in Linux is done by the run-time linker and loader (ld-linux.so), which loads all the required dynamic libraries used by the application into memory, and resolves all unresolved references with these libraries. The dynamic linking support in LynxOS v4.0 follows the widely used UNIX System V (SVR4) ABI for dynamic linking of applications. Dynamically linked applications identify the run-time linker and loader (ld.so) in the application's file format at build-time. During program execution, ld.so loads all needed shared libraries into memory and resolves run-time dependencies.
The similarity of the dynamic linking support between Linux and LynxOS forms another key component of Linux ABI compatibility on LynxOS.
One of the most significant components needed to ensure Linux ABI compatibility on LynxOS is the availbility of a common API . Most Linux applications use a significant set of API calls that are provided by the Linux kernel. (Linux kernel v2.4.x provides over 200 system call APIs.) The ability of the LynxOS execution environment to duplicate the behavior of each of these system calls invoked by a Linux application is essential to ensuring its successful execution.
LynxOS being a UNIX/POSIX conforming RTOS has over 150 system calls that are similar with the Linux system call API . However to ensure that these system calls' behavior is identical to Linux, changes were made in the following areas:
errno) in LynxOS were changed to match Linux.
The resultant LynxOS system call API has an extremely high level of compatibility with the Linux system call API with very minimal overhead for the LynxOS kernel. This convergence between the two operating system APIs is the critical component to ensuring ABI compatibility between the two.
Dynamically linked libraries in Linux provide additional sets of API functions that applications can dynamically link to, and the system call binding between Linux applications and the Linux kernel. The availability of Linux dynamic libraries in the LynxOS execution environment is essential for Linux ABI compatibility support on LynxOS v4.0.
LynxOS v4.0 uses a modified version of the Linux GLIBC dynamic library to resolve application calls at run-time. This modified GLIBC library provides the translation between Linux and LynxOS system calls. Application calls to GLIBC functions that are independent of system calls remain unchanged and are unaffected by the underlying LynxOS execution environment. However, application calls to Linux system calls are intercepted at the system call binding code in the modified GLIBC. Glue code was added in GLIBC to either call the LynxOS system call directly or make any modifications before the LynxOS system call invocation to ensure that the Linux system call behavior is achieved. Using this mechanism, a broad spectrum of Linux system calls is supported including Pthread interfaces, Asynchronous IO, Networking and other POSIX interfaces.
Further, any Linux dynamic library that does not have any system dependencies can be copied from Linux and used unchanged on LynxOS. The LynxOS run-time linker and loader recognizes the dynamic library dependency through the application ELF headers and proceeds to resolve application calls to these libraries (e.g.: libz.so.1, libjpeg.so.62 etc).
However, if an application uses a system call that is unsupported, it fails immediately and consistently since the corresponding system call binding does not exist in GLIBC.
Thus the overall architecture of the LynxOS-Linux application compatibility layer, as shown in Figure 2, combines the described set of components to provide an OS execution environment capable of executing an extensive set of Linux applications.
Since the ABI compatibility support is tied to the system API compatibility and dynamic library support, LynxOS-Linux ABI compatibility is currently dependent on a Linux kernel and GLIBC pair. LynxOS v4.0 supports applications based on Linux kernel v2.4.x and GLIBC v2.2.2/v2.2.4.
The current implementation does not provide support for statically linked Linux applications, application that make direct system calls and applications that use a feature that is not supported in LynxOS (e.g.: /proc file system). However this is a subset of the total available Linux applications.
The compatibility testing of the Linux ABI compatibility layer was done using a combination of automated and manual testing.
The automated testing of the LynxOS ABI compatibility layer uses the BlueCat Linux automated test suite (ATS) that contains over 5000 tests of POSIX 1a, 1b and other Linux system call interfaces. These automated test suites were built in a Linux kernel v2.4.x/GLIBC v2.2.2 environment and run on the BlueCat Linux product for baseline qualification. These same test binaries were then executed unchanged on the LynxOS v4.0 execution environment and test results were compared to ensure no difference in results.
The manual testing involved testing advanced Linux applications with several system and application-supplied dynamic libraries. Several advanced applications were successfully tested like the Opera browser, ACE-ORB, Gnome and KDE.
The performance considerations of the Linux ABI compatibility layer focus on two main areas:
The architecture of the Linux ABI compatibility layer on LynxOS is largely independent from the LynxOS native functionality. The kernel modifications that have been introduced to achieve better API compatibility mainly affect signal numbers, errno values and IOCTL values. These do not introduce any additional overhead and hence the performance of LynxOS native applications are completely unaffected by the ABI compatibility layer.
The performance of Linux applications on LynxOS is mainly dependent on the additional glue code that is introduced in the GLIBC library. However the glue code in most cases is very minimal, merely translating system call parameters and bit fields before invoking LynxOS system calls and translating it back to the application after the system call returns. This introduces very minimal overhead and the overall performance impact on the application is negligible.
The Linux ABI compatibility layer on LynxOS v4.0 provides several benefits to customers:
The Linux ABI compatibility layer on LynxOS v4.0 creates a unique execution environment where Linux applications can run unchanged in a true hard real-time environment. It provides the ability to leverage innumerable open source as well as proprietary applications to better meet time-to-market needs in the creation of products in the embedded marketplace.
Embedded Systems Technology
BSP Device Drivers
BSP Targets by Form Factor
Third-party add-ons for LynuxWorks operating systems