logo

live-bootstrap

Mirror of <https://github.com/fosslinux/live-bootstrap>

avoid_set_thread_area.patch (1749B)


  1. # SPDX-FileCopyrightText: 2023 Richard Masters <grick23@gmail.com>
  2. # SPDX-License-Identifier: MIT
  3. diff -r -u musl-1.2.3.orig/arch/i386/pthread_arch.h musl-1.2.3/arch/i386/pthread_arch.h
  4. --- musl-1.2.4/arch/i386/pthread_arch.h 2022-04-07 17:12:40.000000000 +0000
  5. +++ musl-1.2.4/arch/i386/pthread_arch.h 2023-04-07 12:07:07.929132587 +0000
  6. @@ -1,8 +1,7 @@
  7. +extern uintptr_t g_pthread;
  8. static inline uintptr_t __get_tp()
  9. {
  10. - uintptr_t tp;
  11. - __asm__ ("movl %%gs:0,%0" : "=r" (tp) );
  12. - return tp;
  13. + return g_pthread;
  14. }
  15. #define MC_PC gregs[REG_EIP]
  16. diff -r -u musl-1.2.3.orig/arch/i386/syscall_arch.h musl-1.2.3/arch/i386/syscall_arch.h
  17. --- musl-1.2.4/arch/i386/syscall_arch.h 2022-04-07 17:12:40.000000000 +0000
  18. +++ musl-1.2.4/arch/i386/syscall_arch.h 2022-12-20 17:28:21.734839560 +0000
  19. @@ -1,3 +1,4 @@
  20. +#define SYSCALL_NO_TLS 1
  21. #define __SYSCALL_LL_E(x) \
  22. ((union { long long ll; long l[2]; }){ .ll = x }).l[0], \
  23. ((union { long long ll; long l[2]; }){ .ll = x }).l[1]
  24. diff -r -u musl-1.2.3.orig/src/env/__init_tls.c musl-1.2.3/src/env/__init_tls.c
  25. --- musl-1.2.4/src/env/__init_tls.c 2022-04-07 17:12:40.000000000 +0000
  26. +++ musl-1.2.4/src/env/__init_tls.c 2023-04-07 12:07:38.677133193 +0000
  27. @@ -10,20 +10,19 @@
  28. #include "syscall.h"
  29. volatile int __thread_list_lock;
  30. +uintptr_t g_pthread;
  31. int __init_tp(void *p)
  32. {
  33. pthread_t td = p;
  34. td->self = td;
  35. - int r = __set_thread_area(TP_ADJ(p));
  36. - if (r < 0) return -1;
  37. - if (!r) libc.can_do_threads = 1;
  38. td->detach_state = DT_JOINABLE;
  39. td->tid = __syscall(SYS_set_tid_address, &__thread_list_lock);
  40. td->locale = &libc.global_locale;
  41. td->robust_list.head = &td->robust_list.head;
  42. td->sysinfo = __sysinfo;
  43. td->next = td->prev = td;
  44. + g_pthread = (uintptr_t) td;
  45. return 0;
  46. }