diff options
author | Michael Meissner <meissner@linux.ibm.com> | 2021-04-23 18:16:03 -0400 |
---|---|---|
committer | Michael Meissner <meissner@linux.ibm.com> | 2021-04-23 18:16:03 -0400 |
commit | 9a30a3f06b908e4e781324c2e813cd1db87119df (patch) | |
tree | 93357bfdc221a25078eccb0652548b42f2711e7a /gcc | |
parent | 886b6c1e8af502b69e3f318b9830b73b88215878 (diff) | |
download | gcc-9a30a3f06b908e4e781324c2e813cd1db87119df.zip gcc-9a30a3f06b908e4e781324c2e813cd1db87119df.tar.gz gcc-9a30a3f06b908e4e781324c2e813cd1db87119df.tar.bz2 |
Fix logic error in 32-bit trampolines.
The test in the PowerPC 32-bit trampoline support is backwards. It aborts
if the trampoline size is greater than the expected size. It should abort
when the trampoline size is less than the expected size. I fixed the test
so the operands are reversed. I then folded the load immediate into the
compare instruction.
I verified this by creating a 32-bit trampoline program and manually
changing the size of the trampoline to be 48 instead of 40. The program
aborted with the larger size. I updated this code and ran the test again
and it passed.
I added a test case that runs on PowerPC 32-bit Linux systems and it calls
the __trampoline_setup function with a larger buffer size than the
compiler uses. The test is not run on 64-bit systems, since the function
__trampoline_setup is not called. I also limited the test to just Linux
systems, in case trampolines are handled differently in other systems.
libgcc/
2021-04-23 Michael Meissner <meissner@linux.ibm.com>
PR target/98952
* config/rs6000/tramp.S (__trampoline_setup, elfv1 #ifdef): Fix
trampoline size comparison in 32-bit by reversing test and
combining load immediate with compare.
(__trampoline_setup, elfv2 #ifdef): Fix trampoline size comparison
in 32-bit by reversing test and combining load immediate with
compare.
gcc/testsuite/
2021-04-23 Michael Meissner <meissner@linux.ibm.com>
PR target/98952
* gcc.target/powerpc/pr98952.c: New test.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/testsuite/gcc.target/powerpc/pr98952.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.target/powerpc/pr98952.c b/gcc/testsuite/gcc.target/powerpc/pr98952.c new file mode 100644 index 0000000..c487fbc --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr98952.c @@ -0,0 +1,28 @@ +/* { dg-do run { target { powerpc*-*-linux* && ilp32 } } } */ +/* { dg-options "-O2" } */ + +/* PR 96983 reported that the test in libgcc's tramp.S was backwards and it + would abort if the trampoline size passed to the function was greater than + the size the runtime was expecting (40). It should abort if the size is less + than 40, not greater than 40. This test creates a call to __trampoline_setup + with a much larger buffer to make sure the function does not abort. + + We do not run this test on 64-bit since __trampoline_setup is not present in + 64-bit systems. + + We only run the test under Linux in case the other systems have some + different variant for __trampoline_setup. */ + +#ifndef SIZE +#define SIZE 100 +#endif + +extern void __trampoline_setup (int *, unsigned, void *, void *); + +int main (void) +{ + int tramp[SIZE / sizeof (int)]; + + __trampoline_setup (tramp, SIZE, 0, 0); + return 0; +} |