0001-BUG-MEDIUM-tools-fix-build-with-static-only-toolchai.patch 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. From 311df83437c4d578e35e5faca30c10da28c30323 Mon Sep 17 00:00:00 2001
  2. Message-Id: <311df83437c4d578e35e5faca30c10da28c30323.1595566447.git.baruch@tkos.co.il>
  3. From: Baruch Siach <baruch@tkos.co.il>
  4. Date: Fri, 24 Jul 2020 07:44:59 +0300
  5. Subject: [PATCH] BUG/MEDIUM: tools: fix build with static only toolchains
  6. uClibc toolchains built with no dynamic library support don't provide
  7. the dlfcn.h header. That leads to build failure:
  8. CC src/tools.o
  9. src/tools.c:15:10: fatal error: dlfcn.h: No such file or directory
  10. #include <dlfcn.h>
  11. ^~~~~~~~~
  12. Enable dladdr only when USE_DL is defined.
  13. Signed-off-by: Baruch Siach <baruch@tkos.co.il>
  14. ---
  15. Upstream status:
  16. https://www.mail-archive.com/haproxy@formilux.org/msg37986.html
  17. src/tools.c | 12 ++++++------
  18. 1 file changed, 6 insertions(+), 6 deletions(-)
  19. diff --git a/src/tools.c b/src/tools.c
  20. index 1c664852ad73..0bd80f846d05 100644
  21. --- a/src/tools.c
  22. +++ b/src/tools.c
  23. @@ -10,7 +10,7 @@
  24. *
  25. */
  26. -#ifdef __ELF__
  27. +#if defined(__ELF__) && defined(USE_DL)
  28. #define _GNU_SOURCE
  29. #include <dlfcn.h>
  30. #include <link.h>
  31. @@ -4410,7 +4410,7 @@ const char *get_exec_path()
  32. return ret;
  33. }
  34. -#ifdef __ELF__
  35. +#if defined(__ELF__) && defined(USE_DL)
  36. /* calls dladdr() or dladdr1() on <addr> and <dli>. If dladdr1 is available,
  37. * also returns the symbol size in <size>, otherwise returns 0 there.
  38. */
  39. @@ -4444,7 +4444,7 @@ static int dladdr_and_size(const void *addr, Dl_info *dli, size_t *size)
  40. * The file name (lib or executable) is limited to what lies between the last
  41. * '/' and the first following '.'. An optional prefix <pfx> is prepended before
  42. * the output if not null. The file is not dumped when it's the same as the one
  43. - * that contains the "main" symbol, or when __ELF__ is not set.
  44. + * that contains the "main" symbol, or when __ELF__ && USE_DL are not set.
  45. *
  46. * The symbol's base address is returned, or NULL when unresolved, in order to
  47. * allow the caller to match it against known ones.
  48. @@ -4472,7 +4472,7 @@ const void *resolve_sym_name(struct buffer *buf, const char *pfx, void *addr)
  49. #endif
  50. };
  51. -#ifdef __ELF__
  52. +#if defined(__ELF__) && defined(USE_DL)
  53. Dl_info dli, dli_main;
  54. size_t size;
  55. const char *fname, *p;
  56. @@ -4489,7 +4489,7 @@ const void *resolve_sym_name(struct buffer *buf, const char *pfx, void *addr)
  57. }
  58. }
  59. -#ifdef __ELF__
  60. +#if defined(__ELF__) && defined(USE_DL)
  61. /* Now let's try to be smarter */
  62. if (!dladdr_and_size(addr, &dli, &size))
  63. goto unknown;
  64. @@ -4529,7 +4529,7 @@ const void *resolve_sym_name(struct buffer *buf, const char *pfx, void *addr)
  65. chunk_appendf(buf, "+%#lx", (long)(addr - dli.dli_fbase));
  66. return NULL;
  67. }
  68. -#endif /* __ELF__ */
  69. +#endif /* __ELF__ && USE_DL */
  70. unknown:
  71. /* unresolved symbol from the main file, report relative offset to main */
  72. if ((void*)addr < (void*)main)
  73. --
  74. 2.27.0