mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-30 08:18:30 +00:00
Get cosmo_dlopen() working better on System Five
Imported functions are now aspected with a trampoline that blocks signals and changes the thread-local storage register. This means bigger more complicated libraries can now be imported even though the whole technique remains fundamentally unsafe.
This commit is contained in:
parent
3a470ed356
commit
e4584ace81
6 changed files with 304 additions and 190 deletions
|
@ -16,6 +16,9 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "ape/sections.internal.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/runtime/memtrack.internal.h"
|
||||
#include "libc/runtime/stack.h"
|
||||
#include "libc/thread/posixthread.internal.h"
|
||||
#include "libc/thread/tls.h"
|
||||
|
@ -33,6 +36,11 @@ privileged long __get_safe_size(long want, long extraspace) {
|
|||
if (!__tls_enabled) return want;
|
||||
struct PosixThread *pt;
|
||||
struct CosmoTib *tib = __get_tls_privileged();
|
||||
if (!IsAutoFrame((uintptr_t)tib >> 16) &&
|
||||
!(__executable_start <= (const unsigned char *)tib &&
|
||||
(const unsigned char *)tib < _end)) {
|
||||
return want;
|
||||
}
|
||||
long bottom, sp = GetStackPointer();
|
||||
if ((char *)sp >= tib->tib_sigstack_addr &&
|
||||
(char *)sp <= tib->tib_sigstack_addr + tib->tib_sigstack_size) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue