diff --git a/include/haproxy/bug.h b/include/haproxy/bug.h index 84dabd909..5db3f15b6 100644 --- a/include/haproxy/bug.h +++ b/include/haproxy/bug.h @@ -234,8 +234,8 @@ struct mem_stats { .file = __FILE__, .line = __LINE__, \ .type = MEM_STATS_TYPE_CALLOC, \ }; \ - HA_GLOBL("__start_mem_stats"); \ - HA_GLOBL("__stop_mem_stats"); \ + HA_WEAK("__start_mem_stats"); \ + HA_WEAK("__stop_mem_stats"); \ _HA_ATOMIC_INC(&_.calls); \ _HA_ATOMIC_ADD(&_.size, __x * __y); \ calloc(__x,__y); \ @@ -251,8 +251,8 @@ struct mem_stats { .file = __FILE__, .line = __LINE__, \ .type = MEM_STATS_TYPE_FREE, \ }; \ - HA_GLOBL("__start_mem_stats"); \ - HA_GLOBL("__stop_mem_stats"); \ + HA_WEAK("__start_mem_stats"); \ + HA_WEAK("__stop_mem_stats"); \ if (__x) \ _HA_ATOMIC_INC(&_.calls); \ free(__x); \ @@ -265,8 +265,8 @@ struct mem_stats { .file = __FILE__, .line = __LINE__, \ .type = MEM_STATS_TYPE_FREE, \ }; \ - HA_GLOBL("__start_mem_stats"); \ - HA_GLOBL("__stop_mem_stats"); \ + HA_WEAK("__start_mem_stats"); \ + HA_WEAK("__stop_mem_stats"); \ if (__builtin_constant_p((x)) || __builtin_constant_p(*(x))) { \ HA_LINK_ERROR(call_to_ha_free_attempts_to_free_a_constant); \ } \ @@ -283,8 +283,8 @@ struct mem_stats { .file = __FILE__, .line = __LINE__, \ .type = MEM_STATS_TYPE_MALLOC, \ }; \ - HA_GLOBL("__start_mem_stats"); \ - HA_GLOBL("__stop_mem_stats"); \ + HA_WEAK("__start_mem_stats"); \ + HA_WEAK("__stop_mem_stats"); \ _HA_ATOMIC_INC(&_.calls); \ _HA_ATOMIC_ADD(&_.size, __x); \ malloc(__x); \ @@ -297,8 +297,8 @@ struct mem_stats { .file = __FILE__, .line = __LINE__, \ .type = MEM_STATS_TYPE_REALLOC, \ }; \ - HA_GLOBL("__start_mem_stats"); \ - HA_GLOBL("__stop_mem_stats"); \ + HA_WEAK("__start_mem_stats"); \ + HA_WEAK("__stop_mem_stats"); \ _HA_ATOMIC_INC(&_.calls); \ _HA_ATOMIC_ADD(&_.size, __y); \ realloc(__x,__y); \ @@ -311,8 +311,8 @@ struct mem_stats { .file = __FILE__, .line = __LINE__, \ .type = MEM_STATS_TYPE_STRDUP, \ }; \ - HA_GLOBL("__start_mem_stats"); \ - HA_GLOBL("__stop_mem_stats"); \ + HA_WEAK("__start_mem_stats"); \ + HA_WEAK("__stop_mem_stats"); \ _HA_ATOMIC_INC(&_.calls); \ _HA_ATOMIC_ADD(&_.size, __y); \ strdup(__x); \ diff --git a/include/haproxy/compiler.h b/include/haproxy/compiler.h index 4859d1301..a23e62a21 100644 --- a/include/haproxy/compiler.h +++ b/include/haproxy/compiler.h @@ -88,7 +88,7 @@ #endif // USE_OBSOLETE_LINKER -/* Declare a symbol as global and if possible, as weak. Since we don't want to +/* Declare a symbol as weak if possible, otherwise global. Since we don't want to * error on multiple definitions, the symbol is declared weak. On MacOS ".weak" * does not exist and we must continue to use ".globl" instead. Note that * ".global" is to be avoided on other platforms as llvm complains about it @@ -97,11 +97,15 @@ * anyway (and most likely it will only work with !USE_OBSOLETE_LINKER). */ #if defined(__APPLE__) -# define __HA_GLOBL(sym) __asm__(".globl " #sym) +# define __HA_WEAK(sym) __asm__(".globl " #sym) #else -# define __HA_GLOBL(sym) __asm__(".weak " #sym) +# define __HA_WEAK(sym) __asm__(".weak " #sym) #endif -#define HA_GLOBL(sym) __HA_GLOBL(sym) +#define HA_WEAK(sym) __HA_WEAK(sym) + +/* declare a symbol as global */ +#define __HA_GLOBL(sym) __asm__(".globl " #sym) +#define HA_GLOBL(sym) __HA_GLOBL(sym) /* use this attribute on a variable to move it to the read_mostly section */ #if !defined(__read_mostly)