zephyr/tests/kernel/mem_protect/mem_map
Daniel Leung af37e9d999 tests: mem_map: fix execution test for x86_64 with coverage
When coverage is enabled on x86_64, GCC uses relative addressing
to increment the gcov counters. The generated code of the test
function assumes execution is in the same location where
the linker places the test function. This does not work with
the execution test as it copies the function into another part
of memory and tries to execute from there. When the copied
function starts to run, the instruction pointer is at the newly
copied function. So any relative addressing with regard to
the instruction pointer now is invalid. Instead of
<generated code RIP + offset> for gcov counter as it should be,
now the copied code is trying to access the counter at
<copied code RIP + offset>, which points to incorrect
memory location (and possibly invalid/non-mapped memory).
To fix this, we need to tell GCC not to use relative addressing.
This can be accomplished by telling GCC to use the large memory
model. This is only used for this test as this option increases
code size quite a bit, and should not be used in general.

Fixes #30434

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-02-02 13:59:41 -05:00
..
src tests: mem_map: fix execution test for x86_64 with coverage 2021-02-02 13:59:41 -05:00
CMakeLists.txt tests: mem_map: put transplanted_function into its own section 2021-02-02 13:59:41 -05:00
custom-sections.ld tests: mem_map: put transplanted_function into its own section 2021-02-02 13:59:41 -05:00
prj_x86_64_coverage_exec.conf tests: mem_map: fix execution test for x86_64 with coverage 2021-02-02 13:59:41 -05:00
prj.conf tests: add k_mem_map() tests 2020-08-25 15:49:59 -04:00
testcase.yaml tests: mem_map: fix execution test for x86_64 with coverage 2021-02-02 13:59:41 -05:00