History log of /seL4-refos-master/seL4_tools/elfloader-tool/CMakeLists.txt
Revision Date Author Comments
# ec5e7098 02-Jul-2020 Kent McLeod <Kent.Mcleod@data61.csiro.au>

elfloader: Remove optimization config restrictions

These optimization limits are no longer required due to aligned-access
compilation flags added in previous commit.

Signed-off-by: Kent McLeod <Kent.Mcleod@data61.csiro.au>


# a8111d41 02-Jul-2020 Kent McLeod <Kent.Mcleod@data61.csiro.au>

elfloader: Disable unaligned memory access on Arm

The two variants of compilation options prevent the compiler from
performing unaligned memory accesses. The architecture allows unaligned
access to normal memory, but not when the MMU is disabled.

Signed-off-by: Kent McLeod <Kent.Mcleod@data61.csiro.au>


# 9f904ed2 06-Mar-2020 Gerwin Klein <gerwin.klein@data61.csiro.au>

convert license headers to SPDX

Includes license review of 3rd-party files, adding missing upstream
headers, and moving the UNSW OZPLB license into its own file rather
than replicating it in the header.


# 152a68c4 12-Feb-2020 Damon Lee <Damon.Lee@data61.csiro.au>

trivial: Style changed files


# 0ce7e35f 12-Feb-2020 Damon Lee <Damon.Lee@data61.csiro.au>

CMake: Apply certain optimisation levels for KZM

On a release configuration and when built with GCC8, the KZM fails to
boot and stalls inside the elfloader. Setting these two files to a
specific optimisation level (-O1) rememdies this issue.


# 51eb6d9f 10-Feb-2020 Matthew <matt.phillips121@gmail.com>

Keep the original flags for gcc

Clang does not support the -mno-single-pic-base flag but
leave it in for gcc


# ba919fbd 09-Feb-2020 Matthew <matt.phillips121@gmail.com>

Add specific optimisation levels for some files

Some files cause elf loader errors
(hanging/timeouts) when compiled at certain
optimisation levels.
Explicitly set levels for these files.


# 134f2ee5 05-Feb-2020 Matthew <matt.phillips121@gmail.com>

Remove unsupported flags

Clang does not support some of the flags used for gcc.
Disable these flags for clang and remove for gcc if unused


# a0f4d06e 16-Dec-2019 Matthew <matt.phillips121@gmail.com>

Pass the target triple through when using clang

Whenever clang is invoked in a custom setting (not generated by CMake),
make sure to pass the triple as a flag


# 3441957c 11-Dec-2019 Matthew <matt.phillips121@gmail.com>

Pass linker flags using the Wl flag (clang & gcc)

Passing linker flags such as -T and -u to the linker does not work
directly if using clang. The -Wl flag is needed


# 0875e970 15-Dec-2019 Simon Shields <simon.shields@data61.csiro.au>

elfloader: enable ROOTSERVERS_LAST for EFI

this feature now works correctly on EFI.


# eb0b02b2 10-Dec-2019 Simon Shields <simon.shields@data61.csiro.au>

elfloader: use driver model for SMP on ARM

Previously, each platform had its own implementation of init_cpus().
This is particularly cumbersome in the case of aarch64, where all
platforms which support SMP use PSCI to do so. This patch moves
SMP on ARM to be implemented using the driver model.

It introduces a new driver type, DRIVER_SMP. This driver
has a single method, `cpu_on`, which, when given an
`elfloader_cpu` struct, turns on the CPU corresponding to that struct,
launching it at the given entry point with the provided stack.

This patch also makes the aarch64 and aarch32 CPU bringup logic
much more similar. Both architectures now wait for CPUs to come up
before starting the next.

Note that the i.MX7 is left as-is, using the old mechanism, due to a
lack of hardware to test on.


# 6e8ec638 21-Oct-2019 Simon Shields <simon.shields@data61.csiro.au>

elfloader: pick serial driver at runtime

On ARM, each serial driver now has an ELFLOADER_DRIVER(...), which
contains information about the compatible strings the driver
matches, the driver type and an "init" function for the driver to do
setup.

hardware_gen is now used by the ELF loader to generate a list of
interesting devices at compile-time, which go in a header file
"devices_gen.h".

The ELFLOADER_DRIVERs are put into a special "_driver_list" section
by the linker, and accessed as an array via the special
__start__driver_list and __stop__driver_list linker symbols.

At boot, the ELF loader calls initialise_devices(), which does the
following:
for each device in devices_gen.h
for each driver in elfloader_drivers array
if (device compat matches driver compat)
call driver->init(device, driver)
end if
end for
end for

For serial drivers, the serial driver calls uart_set_out with
the elfloader_device that should be the output for the elfloader
from the driver->init function.

There is a 'common' plat_console_putchar implementation which uses
the dynamically picked uart output. This eliminates the need
for a lot of the platform-specific code we have.

This implementation could one day be replaced with a in-ELF loader
device tree. This could also (possibly) be used to handle dynamically
picking SMP core bringup mechanisms.

As all RISC-V platforms use SBI to provide a serial port, RISCV is
only modified to register the SBI putc implementation as the fputc
implementatin.


# 030d83bf 11-Nov-2019 Simon Shields <simon.shields@data61.csiro.au>

elfloader: improve EFI support

Rather than using a bunch of assembly code to relocate the
ELF loader, we use gnu-efi[1] to build an EFI executable.
This approach handles things like nested structs better, by including
a "proper" way to handle ELF relocations.

[1]: https://sourceforge.net/projects/gnu-efi/


# 52046d3e 01-Sep-2019 Kent McLeod <Kent.Mcleod@data61.csiro.au>

elfloader: Re-add IMAGE_START_ADDR override

This was accidentally removed in a previous refactor. It is required for
platform configurations that rely on an exact IMAGE_START_ADDR.


# c1d01151 05-Aug-2019 G. Branden Robinson <Branden.Robinson@data61.csiro.au>

elfloader: simplify and generalise interface

Migrate the `shoehorn` tool from a fragile command-line interface to a
more robust one. The existing one did not support platforms that didn't
include the DTB in the ELF-loader image, and did not support checksum
files for the kernel and rootserver ELF files (an advanced configuration
option). Now `shoehorn` takes only two operands: the platform YAML file
(as before) and the ELF-loader image ("archive.o"), not a list of the
image's contents. `shoehorn` now understands the structure of the
ELF-loader image: an ELF object file header prepended to a System V
ASCII CPIO archive without checksum.

Update ELF-loader CMakeLists.txt file to no longer require any knowledge
of the contents of the ELF-loader image for the purpose of calling
`shoehorn`; cmake simply passes it (and the platform YAML file) to the
tool.

Refactor and enhance `elf_sift` tool to support extracting ELF loadable
segment size information from a BinaryIO object; required since
`shoehorn` now reads CPIO archive entries into memory.

* cmake-tool/helpers/elf_sift.py:
+ Add notice of unstable API.
+ Rename `get_memory_size()` to `get_memory_usage_from_file()`.
+ ...and update its call site.
+ Add new function `get_memory_usage()`.
+ Make `get_memory_usage_from_file()` a context-managing wrapper
around `get_memory_usage()`.
+ Import `BinaryIO` symbol from `typing` module to support PEP 484
type hints.

* cmake-tool/helpers/platform_sift.py:
+ Use `safe_load()` method of PyYAML 5.1 and later since there doesn't
seem to be any reason to expect executable Python code to be present
in the hardware description files.
+ Rename `platform_file` and `yaml_file` variables to `*_filename` to
better document the fact that they are pathname/filespec strings.

* cmake-tool/helpers/shoehorn.py:
+ Add notice of unstable API.
+ Rewrite and improve usage message (and main docstring).
+ Flesh out diagnostic interface. Add `write()`, `debug()`, `die()`,
`notice()`, and `warn()` functions. Migrate call sites of
`sys.stderr.write()` to appropriate diagnostic functions.
+ Add new function `get_bytes()`. Returns an io.BytesIO object with
the contents of the given (CPIO) archive entry.
+ Add new function `get_cpio()`. Returns an io.BytesIO object with
the CPIO file contained in `payload_file` (the ELF-loader image).
+ Drop stale comments.
+ Update argument interface to support only `platform_yaml` and
`payload_file` operands.
+ Only perform DTB-based memory computations if a DTB is present.
+ Load ELF objects in CPIO archive into memory, and measure them with
`get_memory_usage()` from `elf_sift` instead of `get_memory_size()`.
+ Recognize checksum entries in CPIO archive (their names end in
".bin"), but issue a diagnostic instead of handling them. Right now
the rest of the build does not provide a mechanism for naming
rootserver checksum files such that they won't collide if multiple
rootservers are present.
+ Simplify variable naming and locality for better readability.
+ Simplify redundant Boolean expression.
+ Stop making an iterator out of an already-iterable list.
+ Update comments.
+ Improve the fatal diagnostic when the image cannot be fitted into
memory, directing the user where to look for the source of the
problem (i.e., they need to reconcile the size of the ELF-loader
image with the memory described as available in the platform YAML
file).
+ Rename `payload_file` variable to `payload_filename` to better
document the fact that it is a pathname/filespec string.

* elfloader-tool/CMakeLists.txt: Simplify; stop munging the list of CPIO
archive members, and just invoke `shoehorn` with two arguments: the
platform YAML file and the ELF-loader image ("archive.o").


# f0674bd6 31-Jul-2019 Kent McLeod <Kent.Mcleod@data61.csiro.au>

elfloader-tool: Add link dependency on link script

This causes the executable to be relinked if the preprocessed linker
script is updated.


# 895ce2d0 31-Jul-2019 Kent McLeod <Kent.Mcleod@data61.csiro.au>

elfloader-tool: Allow overriding IMAGE_START_ADDR

Sometimes the IMAGE_START_ADDR needs to be set explicitly for certain
platforms. Setting it as a cache variable via
-DIMAGE_START_ADDR=0xaddress allows the final elfloader to have that
start address.


# f9e033c5 30-Jul-2019 Kent McLeod <Kent.Mcleod@data61.csiro.au>

elfloader: enable ElfloaderIncludeDtb for RISC-V

RISC-V platforms also declare a DTB for the kernel that the elfloader
can use.


# 8a6264d8 30-Jul-2019 Kent McLeod <Kent.Mcleod@data61.csiro.au>

trivial: Style elfloader-tool/CMakeLists.txt


# f6069f2d 30-Jul-2019 Kent McLeod <Kent.Mcleod@data61.csiro.au>

elfloader: Add dependency for PLATFORM_INFO_H gen

We need to explicitly add PLATFORM_INFO_H as a header file dependency on
src/common.c. Otherwise CMake doesn't run the rule to generate
PLATFORM_INFO_H. We don't need to do this for regular header files as
Ninja uses gcc -MD to generate make-style depends files.


# c19720ab 30-Jul-2019 Kent McLeod <Kent.Mcleod@data61.csiro.au>

elfloader-tool: Don't import elfloader on x86

This module is only used on Arm and RISC-V


# f6653609 02-May-2019 G. Branden Robinson <Branden.Robinson@data61.csiro.au>

elfloader: dynamically compute image start address

SELFOUR-1979. Stop hard-coding an address at which the ELF-loader will
be loaded into physical memory. Instead, dynamically compute where it
should go based on the size and locations of the payloads (kernel plus
rootserver) it will extract, and place the image just above their end.
Futhermore, for U-Boot images, pass the computed load address through to
the `mkimage` command instead of using a hard-coded one (for this format
the load address and entry address are identical).

To faciliate all of the above, add three new helper tools.

* elfloader-tool/CMakeLists.txt:
+ Interpose a new target, `image_start_addr.h`, between `archive.o`
(ELF-loader) and `linker.lds_pp` (preprocessed linker script for the
ELF-loader). `platform_info.h` #defines one symbol,
`IMAGE_START_ADDR`, the first location the ELF-loader will occupy.
+ Tell the compiler to look for this generated header file in the
appropriate build directory.

* elfloader-tool/src/arch-arm/linker.lds: #include this new header file,
and in the .start section, set the current location to the computed
value via the preprocessor symbol `IMAGE_START_ADDR`.

* cmake-tool/helpers/rootserver.cmake: Rename CMake variable
`PlatformEntryAddr` to `ImageStartAddr`. An entry address is generally
the address of an instruction, a valid target for a jump. The start of
our image is an ELF prologue.

* cmake-tool/helpers/elf_sift.py: New tool aids ELF image relocation.
Extract information of interest to the seL4 image build process from ELF
files. We extract the sizes of loadable ELF segments from the ELF files
given as operands and print their sum. If the "--align" flag is
specified, the space "after" each ELF file is aligned to the next 4KiB
boundary, increasing the total. `shoehorn`, described below, loads
`elf_sift` as a module and uses some of its methods.

* cmake-tool/helpers/shoehorn.py: New tool locates ELF-loader in memory.
This tool writes to standard output a physical memory address in
hexadecimal that fits the loadable segements of the `elf_file` argument
into the first sufficiently-large region described in `platform_file`.
For now the tool is simple but does some sanity checking on the contents
of the ELF object and YAML platform description it is given. Supports
`--load-rootservers-high` option. It defaults off, but if specified,
the search for an ELF-loader image load address stops once the the
kernel and DTB are accommodated. If we're asked to load rootservers
high but the only memory region into which the ELF-loader will fit is
the same one in which the rootservers are loaded (i.e., the last or only
region), notify the user that overlap may not be detected. The
ELF-loader itself should still detect the problem and halt. We could
add logic to detect the overlap here, but this seems like a pathological
case.

* cmake-tool/helpers/make-uimage: New tool uses objcopy, readelf (both
from GNU binutils), and mkimage (from the U-Boot tools) to extract the
entry point (start symbol) of an ELF executable and wrap the object in a
chain-loadable payload for use by the U-Boot boot loader.

* cmake-tool/helpers/rootserver.cmake: Simplify body of uimage-based
conditional by calling out to `make-uimage` tool.


# 0e736cf2 22-Jul-2019 Kent McLeod <Kent.Mcleod@data61.csiro.au>

trivial: Style CMakeLists.txt


# 3b543953 22-Jul-2019 Kent McLeod <Kent.Mcleod@data61.csiro.au>

CMake: Refactor riscv and arm roottask rules

Both architectures use the elfloader and support binary and elffile
outputs.


# 1688dd94 11-Jul-2019 Kent McLeod <Kent.Mcleod@data61.csiro.au>

elfloader: Fix hashing implementation

Fixes a bug in the parameters being given to the hash functions.


# cfd453aa 11-Jul-2019 Kent McLeod <Kent.Mcleod@data61.csiro.au>

elfloader: Support leaving aarch64 EL2 to aarch32

This allows aarch32 seL4 kernel configurations to be loaded from a
64bit entry point. When this setting is configured, an additonal
symbol, _start32, is created that is still a valid 32bit entry point.


# 059a672d 02-Jul-2019 Kent McLeod <Kent.Mcleod@data61.csiro.au>

Add support for the i.MX8M Mini Eval kit platform

This adds support for the 64-bit i.MX8M Mini Quad evaluation kit.
Currently only AArch64 EL1 is supported.


# 0d848ca3 18-Jul-2019 Yu Hou <Yu.Hou@data61.csiro.au>

replace kernel_autoconf with sel4_autoconf

since the mainline kernel's kernel_autoconf doesn't include
seL4/gen_config.h but sel4_autoconf does


# 6e71ed24 16-Jul-2019 Yu Hou <Yu.Hou@data61.csiro.au>

Trivial: style fix

make the style checker happy


# 65daeb20 19-May-2019 Yu Hou <Yu.Hou@data61.csiro.au>

elfloader-tool: explicitly link config libs

explicitly link kernel_autoconf and elfloader_Config
since the global config lib is going to be remove


# 9f842de4 10-Jul-2019 Oliver Scott <Oliver.Scott@data61.csiro.au>

trivial style

Fix cmake style.


# 10621bc9 08-Jul-2019 Oliver Scott <Oliver.Scott@data61.csiro.au>

Add support for rockpro64 Soc

64 bit aarch.


# 5c4db492 21-Mar-2019 Kent McLeod <Kent.Mcleod@data61.csiro.au>

Add support for the i.MX8MQ Eval kit platform

This adds support for the 64-bit i.MX8M Quad evaluation kit.
Currently only AArch64 EL1 is supported.


# 2df39b50 07-Jun-2019 Siwei Zhuang <siwei.zhuang@data61.csiro.au>

Trivial: Fix platform name

Use more accurate platform name.


# e3fca944 13-Jun-2019 Anna Lyons <Anna.Lyons@data61.csiro.au>

elfloader: add option to place the user image last

The user image size is not always deterministic. Add an option to place
the user image at the end of memory, so that we can determine the list
of untyped objects (excluding the last) offline without needing to
calculate the user image size.

NB this option is not available on platforms that use EFI as more
virtual memory scaffolding is required to write to high addresses.


# fe1f3ebc 18-Jun-2019 G. Branden Robinson <Branden.Robinson@data61.csiro.au>

elfloader-tool: fix CaMKes build on RISC-V

Some platforms (RISC-V) support the ELF-loader but not (yet) a platform
YAML description. Conditionalize generation of `platform_info.h` header
file on existence of platform YAML file from which we generate it.
Also, reference the existing `platform_yaml` CMake variable (set in the
kernel project) as our condition and also avoid hard-coding the path to
the file.


# caa4b9d0 13-Jun-2019 G. Branden Robinson <Branden.Robinson@data61.csiro.au>

platform_sift.py: add parser for platform_gen.yaml

cmake-tool/helpers/platform_sift.py: Report informatiom about memory
regions declared in input YAML file to standard output. Validate the
input and support optional emission of C syntax, with an example of
usage in the help message.

elfloader-tool/CMakeLists.txt: Invoke the above script and construct the
header file platform_info.h to house it. Add dependency on this file to
ensure it gets created. Anna Lyons contributed the placement of the
header file in the correct directory, some bits required to support
that, and made my CMake more idiomatic (less painful to read). Thanks,
Anna!


# 230709e9 12-May-2019 Siwei Zhuang <siwei.zhuang@data61.csiro.au>

RISCV: Use the same entry for added riscv platforms

Use the same address for all supported platforms.


# c1bf1c03 30-Apr-2019 Kent McLeod <Kent.Mcleod@data61.csiro.au>

elfloader: Explicitly import cpio CMake module

This provides the MakeCPIO build rule for creating targets that collect
files into a cpio archive that can be linked into a program.


# 612f188d 07-Apr-2019 Simon Shields <simon.shields@data61.csiro.au>

elfloader: support loading DTB from CPIO archive

On platforms where the bootloader does not provide a DTB,
we may still want to provide userspace with a DTB - allow including
it in the CPIO archive, named "kernel.dtb".


# 42be0363 18-Mar-2019 Simon Shields <simon.shields@data61.csiro.au>

elfloader: Add aarch32 EFI support

This makes the ELF loader relocatable on aarch32,
and generates the appropriate EFI header for aarch32 boards.


# a8950605 20-Mar-2019 Anna Lyons <Anna.Lyons@data61.csiro.au>

style: style cmake files consistently


# 1bc8a709 13-Feb-2019 Yanyan Shen <yanyan.shen@data61.csiro.au>

elfloader: Add Arm FVP support.


# f5fd7dab 09-Nov-2018 Nathan Studer <nathan.studer@dornerworks.com>

Make ARM_MONITOR_HOOK option accessible for iMX6


# 5039c3aa 15-Oct-2018 Peter Chubb <Peter.Chubb@data61.csiro.au>

TX2 initial port

- Copy most files from TX1
- Add new uImage support to elfloader as TX2 u-boot wants a uImage to boot from.


# fe1249d3 15-Oct-2018 Peter Chubb <Peter.Chubb@data61.csiro.au>

Revert "TX2 initial port"

This reverts commit e65661b96c8f08dcf238a9766812a85c75d02659.

Not yet ready for merging.


# e65661b9 15-Oct-2018 Peter Chubb <Peter.Chubb@data61.csiro.au>

TX2 initial port

Copy most files from TX1, but TX2 u-boot wants a uImage to boot from.


# 442909a8 09-Aug-2018 Adam Felizzi <Adam.Felizzi@data61.csiro.au>

elfloader: Removed CMake dependency for hash_none

Removed dependency on 'ElfloaderImageELF' for the hash_none
option (in the 'ElfloaderHashInstructions' CMake config). Non elf
images (binary and efi) would not define the HASH_NONE
config variable.


# 227c1dbb 06-Aug-2018 Adam Felizzi <Adam.Felizzi@data61.csiro.au>

CMake: Added Hash binarys for elfloader checks

Ported the Kbuild code that built kernel and rootserver hash sum
binaries for the elfloader to check during runtime. This change
introduces the creation of hash binaries in the CMake build
system that eventually gets packed into the CPIO archive.


# 94115847 08-Aug-2018 Adam Felizzi <Adam.Felizzi@data61.csiro.au>

elfloader: Added PlatformEntryAddr for zynqmp


# bd85105b 06-Jun-2018 Anna Lyons <Anna.Lyons@data61.csiro.au>

elfloader: add odroidc2


# 70153c95 12-Jul-2018 Adrian Danis <Adrian.Danis@data61.csiro.au>

elfloader: Build with -nostdlib

Links only against libgcc instead of all the default libraries, removing dependency upon the
cross compilers libc, which we do not want to be using.


# f71ec86c 03-Jun-2018 Sebastian Holzapfel <seb.holzapfel@data61.csiro.au>

elfloader: force general register usage on aarch64

NEON registers aren't necessarily initialized for use before elfloader
starts. Since the elfloader does not use these registers, prevent the
compiler from storing NEON register state in function pro/epilogues.

(This fixes an elfloader crash on rpi3/aarch64)


# ea487123 05-Apr-2018 Kent McLeod <Kent.Mcleod@data61.csiro.au>

RISC-V: Add CMake support


# 1f57b8aa 03-Apr-2018 Kent McLeod <Kent.Mcleod@data61.csiro.au>

elfloader: Remove ARM assumption

Rearranges the elfloader to place non ARM specific code into common locations and only
include ARM code if building for ARM. This enables the elfloader to be used for other
architectures in the future.


# abaf87b2 05-Feb-2018 Adrian Danis <Adrian.Danis@data61.csiro.au>

elfloader: Explicit start section

Introduces an explicit 'start' section for including the .text.start symbols and define this
section to be at the platform load address, instead of the .text section. This ensures that
the _start symbol is the first thing in the binary, which is necessary when converting the
elf into a binary file.


# 8b9770a7 04-Feb-2018 Kent McLeod <Kent.Mcleod@data61.csiro.au>

elfloader: Add KConfig imx7 address constants


# de799d07 04-Feb-2018 Adrian Danis <Adrian.Danis@data61.csiro.au>

elfloader: Avoid spurious error on x86

The elfloader does not get built if not on ARM so having an invalid platform does not matter


# 1a07022e 31-Jan-2018 Adrian Danis <Adrian.Danis@data61.csiro.au>

elfloader: Build as position independent and EFI

If loaded by EFI we will not be loaded at any particular address, rather we are expected
to be a relocatable object. This changes the compilation and linking to generate a position
independent binary in this case.


# a3aab30c 31-Jan-2018 Adrian Danis <Adrian.Danis@data61.csiro.au>

cmake: Elfloader responsible for its own building

This moves the logic for linking the elfloader into its final state (elfloader + CPIO archive)
into the elfloader CMakeLists file, instead of being done by custom commands in the common.cmake
file. Having the elfloader perform its own linking simplifies compilation as no intermediate
relinkable object needs to be generated, and custom XXX_LINK_EXECUTABLE definitions don't need
to be provided. Instead, with a few linker flags, cmake can build the elfloader as per normal.


# 2b293b9a 29-Jan-2018 Kent McLeod <Kent.Mcleod@data61.csiro.au>

tk1: Rename platform names from jetson to tk1

Jetson is ambiguous as TX1 is also a jetson board. This name is left
over from when we only supported jetson tk1.


# afe398cd 14-Nov-2017 Claudia Tu <claudia.tu@unsw.edu.au>

Fix typo


# 41b1e607 14-Nov-2017 Claudia Tu <claudia.tu@unsw.edu.au>

SELFOUR-1105 make ElfloaderMode restrictions reflect Kconfig


# 70eb394a 29-Mar-2017 Adrian Danis <Adrian.Danis@data61.csiro.au>

Add a common CMake based build tool/system

For details read the added cmake-tool/README.md