selftests/x86/sigreturn: Fix error: variably modified 'altstack_data' at file scope
PATCH 1/1 selftests/x86/sigreturn: Fix error: variably modified 'altstack_data' at file scope
Based on glibc 2.33 -> 2.34, there is one new feature:
NEWS for version 2.34
=====================
Major new features:
* Add _SC_MINSIGSTKSZ and _SC_SIGSTKSZ. When _DYNAMIC_STACK_SIZE_SOURCE or _GNU_SOURCE are defined, MINSIGSTKSZ and SIGSTKSZ are no longer constant on Linux. MINSIGSTKSZ is redefined to sysconf(_SC_MINSIGSTKSZ) and SIGSTKSZ is redefined to sysconf (_SC_SIGSTKSZ). This supports dynamic sized register sets for modern architectural features like Arm SVE.
Build error with the GNU C Library 2.34:
DEBUG: | sigreturn.c:150:13: error: variably modified 'altstack_data' at file scope
| sigreturn.c:150:13: error: variably modified 'altstack_data' at file scope
DEBUG: | 150 | static char altstack_data[SIGSTKSZ];
| 150 | static char altstack_data[SIGSTKSZ]; DEBUG: | | ^~~~~~~~~~~~~
--- tools/testing/selftests/x86/sigreturn.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
tools/testing/selftests/x86/sigreturn.c +3 -4
@@ -138,9 +138,6 @@ static unsigned short LDT3(int idx)return (idx <<3 ) |7 ; } -/* Our sigaltstack scratch space. */ -static char altstack_data[SIGSTKSZ ]; -static void sethandler (int sig,void (*handler)(int ,siginfo_t *,void *),int flags) {
@@ -771,7 +768,8 @@ int main()setup_ldt ();stack_t stack = { - .ss_sp = altstack_data, +/* Our sigaltstack scratch space. */ + .ss_sp =malloc (sizeof (char ) *SIGSTKSZ ), .ss_size =SIGSTKSZ , };if (sigaltstack (&stack,NULL ) !=0 )
@@ -872,5 +870,6 @@ int main() total_nerrs +=test_nonstrict_ss ();#endif +free (stack.ss_sp);return total_nerrs ?1 :0 ; }
Signature · 1 line
2.32.0
Shuah Khan
maintainerQuoted 51 lines · Jun Miao
Based on glibc 2.33 -> 2.34, there is one new feature:
NEWS for version 2.34
=====================Major new features:
* Add_SC_MINSIGSTKSZand_SC_SIGSTKSZ. When_DYNAMIC_STACK_SIZE_SOURCEor_GNU_SOURCEare defined, MINSIGSTKSZ and SIGSTKSZ are no longer constant on Linux. MINSIGSTKSZ is redefined tosysconf(_SC_MINSIGSTKSZ)and SIGSTKSZ is redefined to sysconf (_SC_SIGSTKSZ). This supports dynamic sized register sets for modern architectural features like Arm SVE.Build error with the GNU C Library 2.34:
DEBUG: | sigreturn.c:150:13: error: variably modified 'altstack_data' at file scope
| sigreturn.c:150:13: error: variably modified 'altstack_data' at file scope
DEBUG: | 150 | static char altstack_data[SIGSTKSZ];| 150 | static char altstack_data[SIGSTKSZ]; DEBUG: | | ^~~~~~~~~~~~~Signed-off-by Jun Miao <[email protected]>--- tools/testing/selftests/x86/sigreturn.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)tools/testing/selftests/x86/sigreturn.c +2
-4@@ -138,9 +138,6 @@ static unsigned short LDT3(int idx)return (idx <<3 ) |7 ; } -/* Our sigaltstack scratch space. */ -static char altstack_data[SIGSTKSZ ]; -static void sethandler (int sig,void (*handler)(int ,siginfo_t *,void *),int flags) {@@ -771,7 +768,8 @@ int main()setup_ldt ();stack_t stack = { - .ss_sp = altstack_data, +/* Our sigaltstack scratch space. */ + .ss_sp =malloc (sizeof (char ) *SIGSTKSZ ), .ss_size =SIGSTKSZ , };if (sigaltstack (&stack,NULL ) !=0 )
tools/testing/selftests/x86/sigreturn.c int main() · line 875
Quoted 6 lines
tools/testing/selftests/x86/sigreturn.c +1
-0@@ -872,5 +870,6 @@ int main() total_nerrs +=test_nonstrict_ss ();#endif +free (stack.ss_sp);return total_nerrs ?1 :0 ; }
Please see comments on your v2 that includes this change.
thanks,
-- Shuah