100-musl-compat.patch 1.5 KB

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