Files can be in two basic formats in the Blackfin Linux world:
Both formats support static and dynamic linking (shared libraries), although it is much easier to use and create shared libraries with ELF. Only ELF supports dynamic loading (
dlclose()), and the standard method for creating and maintaining shared libraries. For more information on libraries, see the creating libraries page.
Keep in mind that under Linux, we use the FDPIC ELF format. The difference between the FDPIC ELF format and the ELF format is merely in the internals (how the PLT is implemented) as a requirement for working without an MMU. For all intents and purposes from the programmer's perspective, the ELF is an ELF.
The BFLT format is used since it allows code and data to be relocated after loading them at arbitrary memory locations, which is needed on systems without an MMU. Compared with the ELF format, the BFLT format has a simpler header, smaller size and is quicker to load (relocate). Since it is normally used in embedded systems, where size is key, it also places an emphasis on reducing the storage requirements. It includes only those parts of the executable that are needed for loading, while normal ELF binaries include much more data, such as symbol tables and debugging information. For in-depth details on the file format itself, check out http://www.beyondlogic.org/uClinux/bflt.htm.
To produce FLAT binaries, you use the
bfin-uclinux-gcc toolchain. This includes a special linker script that gets invoked when linked with the
-Wl,-elf2flt flag. It takes the ELF output after the normal linking steps, processes all of the ELF relocations, and normalizes all of the output into the contiguous FLAT blob.
FLAT file support is on by default; it can be controlled with the following kernel configuration option:
Linux Kernel Configuration Executable file formats ---> [ ] Kernel support for FDPIC ELF binaries <*> Kernel support for flat binaries [ ] Enable ZFLAT support [ ] Enable shared FLAT support
Here, support for compressed FLAT files, or shared FLAT libraries can be turned on.
Whether the userspace is built as FLAT, FLAT shared, or ELF is controlled in the Vendor/User configuration menu.
If you want static FLAT (the default):
Vendor/User Settings Blackfin build Options ---> (FLAT) Binary format
If you want shared FLAT:
Vendor/User Settings Blackfin build Options ---> (Shared-FLAT) Binary format
ELF Files may be larger (due to the extra symbol information) and run slower than a FLAT file (since a slightly less efficient calling convention is used). The main advantage is the ease with which shared libraries can be created and used, and the option to use dynamic loading. Everything that can be done with shared objects on a desktop Linux system can also be done under Linux on the Blackfin when ELF binaries are used.
To produce FDPIC ELF binaries, you use the
bfin-linux-uclibc-gcc toolchain. This should operate for all intents and purposes like ELF objects on a system with an MMU.
To ensure the kernel has ELF support, there needs to be some kernel configuration made:
Linux Kernel Configuration Executable file formats ---> [*] Kernel support for FDPIC ELF binaries <*> Kernel support for flat binaries [ ] Enable ZFLAT support [ ] Enable shared FLAT support
Whether the userspace is built as FLAT, FLAT shared, or ELF is controlled in the Vendor/User configuration menu. If you want support for dynamic loading (FDPIC-ELF):
Vendor/User Settings Blackfin build Options ---> (FDPIC) Binary format