You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When adding more than one compilation unit to the same compartment and setting the -mno-relax flag when compiling these units, compilation and linking succeed. However, when trying to run the final elf file using the cheriot sail emulator a violation occurs as there is a wrong address derivation using the pair aupcc and jalr and the emulator jumps to that wrong address. Setting the flag -mrelax relaxes these two instructions into a single cjal instruction and the right address is derived. I believe that in the documentation it is mentioned that you rely on linker relaxation to optimise these relocations but should not the pair of aupcc and jalr still derive the right address even when that optimisation is not applied?
The issue can be replicated using the hello_world example. Simply add another file to the "hello" compartment. Let us say "other_compilation_unit.cc". Within this file, write the implementation of a simple function:
#include <debug.hh>
using Debug = ConditionalDebug<true, "Hello world compartment - Other compilation unit">;
void func_in_another_compilation_unit() {
Debug::log("func_in_another_compilation_unit");
}
Call this function within the file "hello.cc" "say_hello" function. The rest of the files in other compartments may be compiled as usual but you should set the flag -mno-relax flag when compiling the files "hello.cc" and "other_compilation_unit.cc". Finally, run the Sail emulator with reg and instr trace enable and you should be able to see that the when the emulator tries to use the pair aupcc and jalr to branch to func_in_another_compilation_unit, it jumps to a different address causing a CHERI BoundsViolation.
The text was updated successfully, but these errors were encountered:
When adding more than one compilation unit to the same compartment and setting the -mno-relax flag when compiling these units, compilation and linking succeed. However, when trying to run the final elf file using the cheriot sail emulator a violation occurs as there is a wrong address derivation using the pair aupcc and jalr and the emulator jumps to that wrong address. Setting the flag -mrelax relaxes these two instructions into a single cjal instruction and the right address is derived. I believe that in the documentation it is mentioned that you rely on linker relaxation to optimise these relocations but should not the pair of aupcc and jalr still derive the right address even when that optimisation is not applied?
The issue can be replicated using the hello_world example. Simply add another file to the "hello" compartment. Let us say "other_compilation_unit.cc". Within this file, write the implementation of a simple function:
Call this function within the file "hello.cc" "say_hello" function. The rest of the files in other compartments may be compiled as usual but you should set the flag -mno-relax flag when compiling the files "hello.cc" and "other_compilation_unit.cc". Finally, run the Sail emulator with reg and instr trace enable and you should be able to see that the when the emulator tries to use the pair aupcc and jalr to branch to func_in_another_compilation_unit, it jumps to a different address causing a CHERI BoundsViolation.
The text was updated successfully, but these errors were encountered: