#
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.
|