musl-qsort_r.patch 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. --- src/readelf.c
  2. +++ src/readelf.c
  3. @@ -4773,10 +4773,11 @@ listptr_base (struct listptr *p)
  4. return cudie_base (&cu);
  5. }
  6. +static const char *listptr_name;
  7. +
  8. static int
  9. -compare_listptr (const void *a, const void *b, void *arg)
  10. +compare_listptr (const void *a, const void *b)
  11. {
  12. - const char *name = arg;
  13. struct listptr *p1 = (void *) a;
  14. struct listptr *p2 = (void *) b;
  15. @@ -4792,21 +4793,21 @@ compare_listptr (const void *a, const void *b, void *arg)
  16. p1->warned = p2->warned = true;
  17. error (0, 0,
  18. gettext ("%s %#" PRIx64 " used with different address sizes"),
  19. - name, (uint64_t) p1->offset);
  20. + listptr_name, (uint64_t) p1->offset);
  21. }
  22. if (p1->dwarf64 != p2->dwarf64)
  23. {
  24. p1->warned = p2->warned = true;
  25. error (0, 0,
  26. gettext ("%s %#" PRIx64 " used with different offset sizes"),
  27. - name, (uint64_t) p1->offset);
  28. + listptr_name, (uint64_t) p1->offset);
  29. }
  30. if (listptr_base (p1) != listptr_base (p2))
  31. {
  32. p1->warned = p2->warned = true;
  33. error (0, 0,
  34. gettext ("%s %#" PRIx64 " used with different base addresses"),
  35. - name, (uint64_t) p1->offset);
  36. + listptr_name, (uint64_t) p1->offset);
  37. }
  38. if (p1->attr != p2 ->attr)
  39. {
  40. @@ -4814,7 +4815,7 @@ compare_listptr (const void *a, const void *b, void *arg)
  41. error (0, 0,
  42. gettext ("%s %#" PRIx64
  43. " used with different attribute %s and %s"),
  44. - name, (uint64_t) p1->offset, dwarf_attr_name (p2->attr),
  45. + listptr_name, (uint64_t) p1->offset, dwarf_attr_name (p2->attr),
  46. dwarf_attr_name (p2->attr));
  47. }
  48. }
  49. @@ -4885,9 +4886,11 @@ notice_listptr (enum section_e section, struct listptr_table *table,
  50. static void
  51. sort_listptr (struct listptr_table *table, const char *name)
  52. {
  53. - if (table->n > 0)
  54. - qsort_r (table->table, table->n, sizeof table->table[0],
  55. - &compare_listptr, (void *) name);
  56. + if (table->n > 0) {
  57. + listptr_name = name;
  58. + qsort (table->table, table->n, sizeof table->table[0],
  59. + &compare_listptr);
  60. + }
  61. }
  62. static bool