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