OpenSDE Packages Database (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
1.9 KiB

  1. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # Filename: package/.../musl/handle-aux-at_base.patch
  5. # Copyright (C) 2020 The OpenSDE Project
  6. #
  7. # More information can be found in the files COPYING and README.
  8. #
  9. # This patch file is dual-licensed. It is available under the license the
  10. # patched project is licensed under, as long as it is an OpenSource license
  11. # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
  12. # of the GNU General Public License as published by the Free Software
  13. # Foundation; either version 2 of the License, or (at your option) any later
  14. # version.
  15. # --- SDE-COPYRIGHT-NOTE-END ---
  16. This is required to make the gcompat ELF interpreter stub work with some
  17. packed binaries.
  18. diff --git a/src/env/__init_tls.c b/src/env/__init_tls.c
  19. index b125eb1..616c6a6 100644
  20. --- a/src/env/__init_tls.c
  21. +++ b/src/env/__init_tls.c
  22. @@ -66,8 +66,10 @@ void *__copy_tls(unsigned char *mem)
  23. }
  24. #if ULONG_MAX == 0xffffffff
  25. +typedef Elf32_Ehdr Ehdr;
  26. typedef Elf32_Phdr Phdr;
  27. #else
  28. +typedef Elf64_Ehdr Ehdr;
  29. typedef Elf64_Phdr Phdr;
  30. #endif
  31. @@ -77,15 +79,23 @@ extern const size_t _DYNAMIC[];
  32. static void static_init_tls(size_t *aux)
  33. {
  34. unsigned char *p;
  35. - size_t n;
  36. + size_t n, e;
  37. Phdr *phdr, *tls_phdr=0;
  38. size_t base = 0;
  39. void *mem;
  40. - for (p=(void *)aux[AT_PHDR],n=aux[AT_PHNUM]; n; n--,p+=aux[AT_PHENT]) {
  41. + if (aux[AT_BASE]) {
  42. + Ehdr *ehdr = (void *)aux[AT_BASE];
  43. + p = (unsigned char *)aux[AT_BASE] + ehdr->e_phoff;
  44. + n = ehdr->e_phnum;
  45. + e = ehdr->e_phentsize;
  46. + } else {
  47. + p = (void *)aux[AT_PHDR];
  48. + n = aux[AT_PHNUM];
  49. + e = aux[AT_PHENT];
  50. + }
  51. + for (; n; n--, p+=e) {
  52. phdr = (void *)p;
  53. - if (phdr->p_type == PT_PHDR)
  54. - base = aux[AT_PHDR] - phdr->p_vaddr;
  55. if (phdr->p_type == PT_DYNAMIC && _DYNAMIC)
  56. base = (size_t)_DYNAMIC - phdr->p_vaddr;
  57. if (phdr->p_type == PT_TLS)