0003-musl-utils.patch 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. From 9b237f19f82d5ab1e0702637fece1866b1ef6681 Mon Sep 17 00:00:00 2001
  2. From: Hongxu Jia <hongxu.jia@windriver.com>
  3. Date: Fri, 23 Aug 2019 10:19:48 +0800
  4. Subject: [PATCH] musl-utils
  5. Provide missing defines which otherwise are available on glibc system headers
  6. Alter the error API to match posix version
  7. use qsort instead of qsort_r which is glibc specific API
  8. Signed-off-by: Khem Raj <raj.khem@gmail.com>
  9. Upstream-Status: Inappropriate [workaround for musl]
  10. Rebase to 0.177
  11. Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
  12. ---
  13. src/arlib.h | 6 ++++++
  14. src/elfcompress.c | 7 +++++++
  15. src/readelf.c | 20 ++++++++++++--------
  16. src/strip.c | 7 +++++++
  17. src/unstrip.c | 9 +++++++++
  18. 5 files changed, 41 insertions(+), 8 deletions(-)
  19. diff --git a/src/arlib.h b/src/arlib.h
  20. index e117166..8326f6c 100644
  21. --- a/src/arlib.h
  22. +++ b/src/arlib.h
  23. @@ -29,6 +29,12 @@
  24. #include <stdint.h>
  25. #include <sys/types.h>
  26. +#if !defined(ALLPERMS)
  27. +# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */
  28. +#endif
  29. +#if !defined(DEFFILEMODE)
  30. +# define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)/* 0666*/
  31. +#endif
  32. /* State of -D/-U flags. */
  33. extern bool arlib_deterministic_output;
  34. diff --git a/src/elfcompress.c b/src/elfcompress.c
  35. index 6ba6af4..0c7674b 100644
  36. --- a/src/elfcompress.c
  37. +++ b/src/elfcompress.c
  38. @@ -37,6 +37,13 @@
  39. #include "libeu.h"
  40. #include "printversion.h"
  41. +#if !defined(ALLPERMS)
  42. +# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */
  43. +#endif
  44. +#if !defined(FNM_EXTMATCH)
  45. +# define FNM_EXTMATCH (0)
  46. +#endif
  47. +
  48. /* Name and version of program. */
  49. ARGP_PROGRAM_VERSION_HOOK_DEF = print_version;
  50. diff --git a/src/readelf.c b/src/readelf.c
  51. index 685d0b1..a842b10 100644
  52. --- a/src/readelf.c
  53. +++ b/src/readelf.c
  54. @@ -4829,10 +4829,11 @@ listptr_base (struct listptr *p)
  55. return cudie_base (&cu);
  56. }
  57. +static const char *listptr_name;
  58. +
  59. static int
  60. -compare_listptr (const void *a, const void *b, void *arg)
  61. +compare_listptr (const void *a, const void *b)
  62. {
  63. - const char *name = arg;
  64. struct listptr *p1 = (void *) a;
  65. struct listptr *p2 = (void *) b;
  66. @@ -4848,21 +4849,21 @@ compare_listptr (const void *a, const void *b, void *arg)
  67. p1->warned = p2->warned = true;
  68. error (0, 0,
  69. gettext ("%s %#" PRIx64 " used with different address sizes"),
  70. - name, (uint64_t) p1->offset);
  71. + listptr_name, (uint64_t) p1->offset);
  72. }
  73. if (p1->dwarf64 != p2->dwarf64)
  74. {
  75. p1->warned = p2->warned = true;
  76. error (0, 0,
  77. gettext ("%s %#" PRIx64 " used with different offset sizes"),
  78. - name, (uint64_t) p1->offset);
  79. + listptr_name, (uint64_t) p1->offset);
  80. }
  81. if (listptr_base (p1) != listptr_base (p2))
  82. {
  83. p1->warned = p2->warned = true;
  84. error (0, 0,
  85. gettext ("%s %#" PRIx64 " used with different base addresses"),
  86. - name, (uint64_t) p1->offset);
  87. + listptr_name, (uint64_t) p1->offset);
  88. }
  89. if (p1->attr != p2 ->attr)
  90. {
  91. @@ -4870,7 +4871,7 @@ compare_listptr (const void *a, const void *b, void *arg)
  92. error (0, 0,
  93. gettext ("%s %#" PRIx64
  94. " used with different attribute %s and %s"),
  95. - name, (uint64_t) p1->offset, dwarf_attr_name (p2->attr),
  96. + listptr_name, (uint64_t) p1->offset, dwarf_attr_name (p2->attr),
  97. dwarf_attr_name (p2->attr));
  98. }
  99. }
  100. @@ -4942,8 +4943,11 @@ static void
  101. sort_listptr (struct listptr_table *table, const char *name)
  102. {
  103. if (table->n > 0)
  104. - qsort_r (table->table, table->n, sizeof table->table[0],
  105. - &compare_listptr, (void *) name);
  106. + {
  107. + listptr_name = name;
  108. + qsort (table->table, table->n, sizeof table->table[0],
  109. + &compare_listptr);
  110. + }
  111. }
  112. static bool
  113. diff --git a/src/strip.c b/src/strip.c
  114. index 48792a7..198a2e4 100644
  115. --- a/src/strip.c
  116. +++ b/src/strip.c
  117. @@ -46,6 +46,13 @@
  118. #include <system.h>
  119. #include <printversion.h>
  120. +#if !defined(ACCESSPERMS)
  121. +# define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */
  122. +#endif
  123. +#if !defined(FNM_EXTMATCH)
  124. +# define FNM_EXTMATCH (0)
  125. +#endif
  126. +
  127. typedef uint8_t GElf_Byte;
  128. /* Name and version of program. */
  129. diff --git a/src/unstrip.c b/src/unstrip.c
  130. index 9b8c09a..1fb5063 100644
  131. --- a/src/unstrip.c
  132. +++ b/src/unstrip.c
  133. @@ -56,6 +56,15 @@
  134. # define _(str) gettext (str)
  135. #endif
  136. +#ifndef strndupa
  137. +#define strndupa(s, n) \
  138. + ({const char *__in = (s); \
  139. + size_t __len = strnlen (__in, (n)) + 1; \
  140. + char *__out = (char *) alloca (__len); \
  141. + __out[__len-1] = '\0'; \
  142. + (char *) memcpy (__out, __in, __len-1);})
  143. +#endif
  144. +
  145. /* Name and version of program. */
  146. ARGP_PROGRAM_VERSION_HOOK_DEF = print_version;