this commit adds the facilities to extract eh_frame[_header]
sections and pass it to each process.
A bump is required to `std` to extract the passed parameters.
Sections of the MiniElf are now aligned as required by the
source ELF requirements. This is required for direct-mapping
with XIP.
the overhead is just a few bytes every couple of programs, so it's
a small price to pay for XIP.
figured out a way to modify the trait so that alignments
are 0 by default, and only set/reported for IniF,
on a per-process basis so if for some reason the alignments
change we should be OK.
Turns out, the pointing end of the stick for ELF sections don't start
at a page boundary. For example:
5 IniF: entrypoint @ 0001e42e, loaded from 000440f4. Sections:
Loaded from 000440f4 - Section .rodata 16924 bytes loading into 000100f4..00014310 flags: NONE
Loaded from 00048310 - Section .eh_frame_hdr 1772 bytes loading into 00014310..000149fc flags: NONE
Loaded from 000489fc - Section .eh_frame 6004 bytes loading into 000149fc..00016170 flags: NONE
Loaded from 0004a170 - Section .text 59876 bytes loading into 00017170..00025b54 flags: EXECUTE
Loaded from 00058b54 - Section .sdata 48 bytes loading into 00026b54..00026b84 flags: WRITE
Loaded from 00058b84 - Section .sbss 48 bytes loading into 00026b84..00026bb4 flags: WRITE | NOCOPY
Loaded from 00058bb4 - Section .bss 516 bytes loading into 00026bb8..00026dbc flags: WRITE | NOCOPY
Here you can see, the data is "loading into" 0x100f4, not
0x10000. The original PR would align things to a page, which means
you'd still have an offset mismatch if you tried to map these directly
over.
This patch causes IniF to insert extra padding to target
the offset necessary for the MiniElf to map 1:1.
An important assumption is the offset is constant across all
programs being linked. This seems to be the case, but, if this
assumption breaks, then the padding will also break.
GCC will set the text size to `0` in a certain case that `rust-lld` did
not. This causes the elf copier to add about 512 MB to the image which
it otherwise shouldn't be doing.
Add a workaround that appears to fix the issue.
Signed-off-by: Sean Cross <sean@xobs.io>
During the previous port, we only wrote the first 4096 bytes. Write the
remainder of the file to the destination.
Signed-off-by: Sean Cross <sean@xobs.io>
This experimental tool can be used to create all-in-one images based
on precomputed file lists. It generates "test images" using just the
bare minimum number of processes.
This program includes all the keys, kernel, and initial images required
to support a simple program.
Signed-off-by: Sean Cross <sean@xobs.io>
Instead of assuming everything is a file or a path, allow
loading ELF files from u8 slices. This will enable us to create
images with `include_bytes!()`.
Signed-off-by: Sean Cross <sean@xobs.io>
Move the code used to sign images into its own library file. This will
enable us to use the image signing functions from other code.
Signed-off-by: Sean Cross <sean@xobs.io>
the loader is a little funky, and requires some maintainer hand-holding
due to the split of the page ownership between the root-keys
crate and the graphics-server crate.
Improved docs so I don't forget this detail in the future.
this allows for a quick readout of the version of each of these
artifacts, inside a signed region, by just inspecting the last
few words of the binary object.
The `xmas-elf` crate doesn't deal with `raw_data()` of sections that are
`NO_COPY`. These sections may point to data that is outside of the file.
In order to avoid hitting this assert, don't call `raw_data()` on
sections that are marked `NO_COPY`.
Signed-off-by: Sean Cross <sean@xobs.io>
Add a Rust implementation of `sign-image`. This enables us to sign the
binary on any platform that can compile Rust.
Signed-off-by: Sean Cross <sean@xobs.io>
The `PNam` tag stores information in the kernel about process names.
This can be used at runtime to discover what process maps to what
program name.
Signed-off-by: Sean Cross <sean@xobs.io>
This issue was spotted when the kernel address was wrong. This fixed
the test, but was indicative of something else being wrong.
Signed-off-by: Sean Cross <sean@xobs.io>