Add an assembly snippet for `mips_option_tests' to verify that instructions executed on the target board may freely access executable sections.
Depending on target board's execution environment, which may map executable pages with the Read Inhibit (RI) bit set in the TLB or may have a split SPRAM memory which directs instruction fetch and data read accesses to different parts of the memory, code may or may not be able to access parts of executable sections as data. Therefore verify that data reads from executable sections both complete successfully and that correct data is retrieved (though with a small probability of a false positive). Use MIPS16 execution to access data required as the `-mcode-readable=yes' option only affects MIPS16 code generation anyway, which however simplifies handling a little bit as PC-relative addressing can be used to calculate the location of data required, avoiding any issues if using the PIE or PIC code generation model. Use the BREAK instruction to trap on a comparison check failure so that the effect is immediate and there is no need to wait for the test program to time out; resort to an infinite loop though in the unlikely event a Bp exception handler resumes execution beyond the trapping instruction. NB there is no need to explicitly align data emitted with the `.word' pseudo-op, which is self-aligning. gcc/testsuite/ * gcc.target/mips/mips.exp (mips_option_tests): Add `-mcode-readable=yes' array element. --- OK to apply? Maciej gcc-mips-test-option-tests-mcode-readable-yes.diff Index: gcc/gcc/testsuite/gcc.target/mips/mips.exp =================================================================== --- gcc.orig/gcc/testsuite/gcc.target/mips/mips.exp 2016-11-09 18:56:48.283197623 +0000 +++ gcc/gcc/testsuite/gcc.target/mips/mips.exp 2016-11-11 08:49:53.345912380 +0000 @@ -401,6 +401,27 @@ set mips_option_tests(-mdspr2) { .set dspr2 prepend $2,$3,11 } +set mips_option_tests(-mcode-readable=yes) { + move $2,$31 + bal 1f + .set mips16 + la $3,0f + lw $3,($3) + jr $31 +0: + .word 0xfacebead + .set nomips16 + .align 2 +1: + ori $3,$31,1 + jalr $3 + li $4,0xfacebead + beq $3,$4,2f + break + b . +2: + move $31,$2 +} # Canonicalize command-line option OPTION. proc mips_canonicalize_option { option } {