1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-08-05 19:35:52 +03:00

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.
This commit is contained in:
Adhemerval Zanella
2021-03-10 12:26:29 -03:00
parent 79969f41a7
commit ae8c243d24
4 changed files with 107 additions and 38 deletions

View File

@@ -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 */