Commit graph

42 commits

Author SHA1 Message Date
eupn
8694eaa004
elf.rs: fix alignment edge case (take 2) 2023-03-27 18:41:45 +04:00
eupn
199ab0a73c
elf: fix a section alignment edge case 2023-03-27 16:29:07 +04:00
bunnie
08ae66a264 fix: #320
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.
2023-02-15 19:55:08 +08:00
bunnie
43c73c0d6c align sections of the MiniElf
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.
2023-02-12 01:13:30 +08:00
bunnie
68c9865072 fix the assumption about all alignments being identical
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.
2023-02-08 04:57:52 +08:00
bunnie
29f050a8ad fix alignment for IniF region so page mappings are 1:1
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.
2023-02-08 04:47:29 +08:00
bunnie
9889856ede page-align processes within the kernel image 2023-02-07 21:10:23 +08:00
Sean Cross
f861af7620 tools: elf: fix copy-elf when gcc links program
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>
2022-11-04 12:27:13 +08:00
Sean Cross
bad8ba5ea2 tools: sign-image: write remainder of file
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>
2022-10-26 23:40:09 +08:00
Sean Cross
22de2bc614 tools: sign_image: fix utterly broken git signing
The previous approach didn't work, for unknown reasons.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-10-26 22:32:24 +08:00
Sean Cross
2cf8ff12a6 tools: add make-renode-boot
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>
2022-10-26 22:22:31 +08:00
Sean Cross
2382d57dd6 tools: add sign_image.rs
Signed-off-by: Sean Cross <sean@xobs.io>
2022-10-26 22:22:18 +08:00
Sean Cross
46cd5e7098 tools: elf: allow loading files from &[u8]
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>
2022-10-26 22:21:24 +08:00
Sean Cross
c50314d4a8 tools: sign-image: break image signing into a library
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>
2022-10-26 22:20:33 +08:00
bunnie
86d2437f03 improve formatting so section alignments are easier to debug 2022-10-20 16:14:56 +08:00
Sean Cross
ff3f307a14 tools: read-tags: call output xous_presign.img
The use of the name `args.bin` is now deprecated.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-10-20 14:11:48 +08:00
bunnie
7248f47ca8 fix self-signing to reflect extra data for semvers
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.
2022-07-11 16:11:32 +08:00
bunnie
1256fcb411 add min version requirement and current version to kernel and loader 2022-07-08 18:56:05 +08:00
bunnie
40b16b3cdb inject current semver info into signature appendix on loader and kernel
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.
2022-07-08 04:08:37 +08:00
Sean Cross
aa436cbcc7 tools: elf: don't get raw_data for no_copy sections
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>
2022-06-10 16:52:57 +08:00
bunnie
421a3814d8 clean up some warnings before moving on to further integration 2022-01-02 15:07:48 +08:00
bunnie
8b59bcdf61 add indices to create_image output
makes it easier to figure out what IniE section corresponds
with which PID.
2021-11-06 21:03:28 +08:00
bunnie
c87acaeddc clarify a bit of rounding code in the create-image routine 2021-11-06 20:30:01 +08:00
bunnie
825322c730 add explicit .iter() for arrays so we still work with Rust 1.51 2021-07-18 16:04:22 +08:00
Sean Cross
aaa4407e21 sign-image: enable kernel image signing
Previously we only supported signing the loader. This also adds the
kernel as a thing that can be signed.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-07-15 16:39:35 +08:00
Sean Cross
31551a6227 tools: add sign-image
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>
2021-07-11 16:34:23 +08:00
Sean Cross
f7ae13da44 tools: run cargo fmt on pnam
Signed-off-by: Sean Cross <sean@xobs.io>
2021-05-19 14:20:22 +08:00
Sean Cross
2e4fb672ab arguments: document and add pnam tag
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>
2021-05-10 14:37:33 +08:00
Sean Cross
7b50d00eb8 repo: run cargo fmt
This reformats line endings to be consistent, and reinforces the
contents of `.gitattributes`.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-01-03 18:31:51 +08:00
Sean Cross
96df91f53b create-image: support generating an image from an svd
Now that we can parse svd files, support creating an image using an svd
instead of a csv file.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-10-05 11:37:44 +08:00
Sean
ba320184b0 tools: create-image: print out error when csr.csv can't be opened
Signed-off-by: Sean <xobs@ci.betrusted.io>
2020-10-03 20:32:31 +08:00
Sean Cross
10ecacd136 kernel: native: create process for initial processes
These all need to bootstrap themselves.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-08-09 23:08:54 +08:00
Sean Cross
09be029ad0 tools: refactor to make clippy happy
This fixes a lot of small clippy warnings.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-07-29 20:02:58 +08:00
Sean Cross
14bb1ac1e5 kernel: working on getting process termination functioning
Signed-off-by: Sean Cross <sean@xobs.io>
2020-06-22 17:42:24 +08:00
Sean Cross
973945fce2 tools: read-tags: fix bad pointer arithmetic
This removes raw pointer usage that could cause unaligned accesses.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-06-15 12:30:21 +08:00
Sean Cross
7da67f050a tools: fix most clippy warnings
Signed-off-by: Sean Cross <sean@xobs.io>
2020-06-15 12:04:23 +08:00
Sean Cross
5aa3358bc0 tools: generate byte addresses for mini elf files
Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-12 15:29:26 +08:00
Sean Cross
4645816674 tools: elf: add comment and dead code for alignment fixing
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>
2020-03-10 14:43:15 +08:00
Sean Cross
edf723e107 create-image: verify the kernel image address is sane
Rust inconsistently applies linker scripts.  Verify the image being
added has a script that makes sense.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-10 14:42:01 +08:00
Sean Cross
36dbc97a61 tools: pad inie and xkrn tags to 4-bytes
This fixes an issue where images were not word-aligned.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-10 13:12:27 +08:00
Sean Cross
6959b4ef77 tools: rename from xous-tools
Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-10 12:46:20 +08:00
Sean Cross
f50ec67553 initial commit
This pulls together many disparate repositories into one xous-core
repository.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-10 12:13:05 +08:00