rtld: avoid division in __thr_map_stacks_exec()

The function is called by rtld with the rtld bind lock write-locked,
when fixing the stack permission during dso load.  Not every ARMv7 CPU
supports the div, which causes the recursive entry into rtld to resolve
the  __aeabi_uidiv symbol, causing self-lock.

Workaround the problem by using roundup2() instead of open-coding less
efficient formula.

Diagnosed by:	mmel
Based on submission by:	John F Carr <jfc@mit.edu>
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
This commit is contained in:
Konstantin Belousov 2024-07-24 13:17:55 +03:00
parent 860c4d94ac
commit 31f688a26d

View file

@ -126,10 +126,7 @@ static char *last_stack = NULL;
static inline size_t
round_up(size_t size)
{
if (size % _thr_page_size != 0)
size = ((size / _thr_page_size) + 1) *
_thr_page_size;
return size;
return (roundup2(size, _thr_page_size));
}
void