aboutsummaryrefslogtreecommitdiff
path: root/support/support.h
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2021-03-10 12:26:29 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2021-07-08 13:48:06 -0300
commitae8c243d2473bdfc3c0f9c6b46e6dffb5a28725c (patch)
tree1c038848c39b2480fe61c8bf03c565e782e813f3 /support/support.h
parent79969f41a7caf9a503a04b78653db971918afa26 (diff)
downloadglibc-ae8c243d2473bdfc3c0f9c6b46e6dffb5a28725c.zip
glibc-ae8c243d2473bdfc3c0f9c6b46e6dffb5a28725c.tar.gz
glibc-ae8c243d2473bdfc3c0f9c6b46e6dffb5a28725c.tar.bz2
support: Add support_stack_alloc
The code to allocate a stack from xsigstack is refactored so it can be more generic. The new support_stack_alloc() also set PROT_EXEC if DEFAULT_STACK_PERMS has PF_X. This is required on some architectures (hppa for instance) and trying to access the rtld global from testsuite will require more intrusive refactoring in the ldsodefs.h header. Checked on x86_64-linux-gnu and i686-linux-gnu. I also ran tst-xsigstack on both hppa and ia64.
Diffstat (limited to 'support/support.h')
-rw-r--r--support/support.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/support/support.h b/support/support.h
index 9ec8ecb..dbd270c 100644
--- a/support/support.h
+++ b/support/support.h
@@ -164,6 +164,25 @@ timer_t support_create_timer (uint64_t sec, long int nsec, bool repeat,
/* Disable the timer TIMER. */
void support_delete_timer (timer_t timer);
+struct support_stack
+{
+ void *stack;
+ size_t size;
+ size_t guardsize;
+};
+
+/* Allocate stack suitable to used with xclone or sigaltstack call. The stack
+ will have a minimum size of SIZE + MINSIGSTKSZ bytes, rounded up to a whole
+ number of pages. There will be a large (at least 1 MiB) inaccessible guard
+ bands on either side of it.
+ The returned value on ALLOC_BASE and ALLOC_SIZE will be the usable stack
+ region, excluding the GUARD_SIZE allocated area.
+ It also terminates the process on error. */
+struct support_stack support_stack_alloc (size_t size);
+
+/* Deallocate the STACK. */
+void support_stack_free (struct support_stack *stack);
+
__END_DECLS
#endif /* SUPPORT_H */