100-musl-compat.patch 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. https://sourceware.org/bugzilla/show_bug.cgi?id=21002
  2. --- a/lib/system.h
  3. +++ b/lib/system.h
  4. @@ -30,7 +30,18 @@
  5. #define LIB_SYSTEM_H 1
  6. #include <errno.h>
  7. -#include <error.h>
  8. +#ifdef HAVE_ERROR_H
  9. +#include "error.h"
  10. +#else
  11. +#include "err.h"
  12. +#include <stdio.h>
  13. +#define error(status, errno, ...) \
  14. + do { \
  15. + fflush(stdout); \
  16. + warn(__VA_ARGS__); \
  17. + if (status) exit(status); \
  18. + } while(0)
  19. +#endif
  20. #include <stddef.h>
  21. #include <stdint.h>
  22. #include <sys/param.h>
  23. @@ -38,6 +49,10 @@
  24. #include <byteswap.h>
  25. #include <unistd.h>
  26. +#ifndef __GLIBC__
  27. +#define canonicalize_file_name(name) realpath(name,NULL)
  28. +#endif
  29. +
  30. #if __BYTE_ORDER == __LITTLE_ENDIAN
  31. # define LE32(n) (n)
  32. # define LE64(n) (n)
  33. --- a/libdw/libdw_alloc.c
  34. +++ b/libdw/libdw_alloc.c
  35. @@ -73,5 +73,5 @@ __attribute ((noreturn)) attribute_hidde
  36. __libdw_oom (void)
  37. {
  38. while (1)
  39. - error (EXIT_FAILURE, ENOMEM, "libdw");
  40. + error (EXIT_FAILURE, errno, gettext ("cannot allocate memory"));
  41. }
  42. --- a/libdwfl/dwfl_error.c
  43. +++ b/libdwfl/dwfl_error.c
  44. @@ -140,6 +140,7 @@ __libdwfl_seterrno (Dwfl_Error error)
  45. const char *
  46. dwfl_errmsg (int error)
  47. {
  48. + static __thread char s[64] = "";
  49. if (error == 0 || error == -1)
  50. {
  51. int last_error = global_error;
  52. @@ -154,7 +155,8 @@ dwfl_errmsg (int error)
  53. switch (error &~ 0xffff)
  54. {
  55. case OTHER_ERROR (ERRNO):
  56. - return strerror_r (error & 0xffff, "bad", 0);
  57. + strerror_r (error & 0xffff, s, sizeof(s));
  58. + return s;
  59. case OTHER_ERROR (LIBELF):
  60. return elf_errmsg (error & 0xffff);
  61. case OTHER_ERROR (LIBDW):