knurling-rs / flip-link

Adds zero-cost stack overflow protection to your embedded programs
Apache License 2.0
279 stars 8 forks source link

CI: verify memory layout of test-app #25

Closed japaric closed 3 years ago

japaric commented 3 years ago

CI compiles the test-flip-link-app (binary) crate to the ARM Cortex-M architecture as an 'it links' test.

We should extend this test and also check that the memory layout of the output ELF is indeed "flipped".

Steps:

  1. use the object crate to parse the output ELF
  2. read the .vector_table linker section and extract the initial SP pointer value
  3. find the boundaries of static RAM (the .bss, .data and .uninit linker sections)
  4. initial SP pointer (2) should be lower/smaller than the lowest boundary of static RAM

These steps could be done in a test file in the root (e.g. test/verify.rs): the test function would build the test-app and then verify its memory layout. This cargo test will run the unit tests in src/main.rs as well as this new test.

Urhengulas commented 3 years ago

b. read the .vector_table linker section and extract the 'initial SP pointer' value

Hi @japaric, I am struggeling to figure out how to extract the initial stack pointer from the .vector_table. Can you please give me a pointer for this?

Answer: It is the first 32-bit word in that section. Documented in the ARMv6-M Architecture Reference Manual.