mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-25 07:41:36 +02:00
MINOR: debug: make the mem_stats section aligned to void*
Not specifying the alignment will let the linker choose it, and it turns out that it will not necessarily be the same size as the one chosen for struct mem_stats, as can be seen if any new fields are added there. Let's enforce an alignment to void* both for the section and for the structure.
This commit is contained in:
parent
ba19acd822
commit
4bc37086b8
@ -245,12 +245,12 @@ struct mem_stats {
|
|||||||
const char *file;
|
const char *file;
|
||||||
int line;
|
int line;
|
||||||
int type;
|
int type;
|
||||||
};
|
} __attribute__((aligned(sizeof(void*))));
|
||||||
|
|
||||||
#undef calloc
|
#undef calloc
|
||||||
#define calloc(x,y) ({ \
|
#define calloc(x,y) ({ \
|
||||||
size_t __x = (x); size_t __y = (y); \
|
size_t __x = (x); size_t __y = (y); \
|
||||||
static struct mem_stats _ __attribute__((used,__section__("mem_stats"))) = { \
|
static struct mem_stats _ __attribute__((used,__section__("mem_stats"),__aligned__(sizeof(void*)))) = { \
|
||||||
.file = __FILE__, .line = __LINE__, \
|
.file = __FILE__, .line = __LINE__, \
|
||||||
.type = MEM_STATS_TYPE_CALLOC, \
|
.type = MEM_STATS_TYPE_CALLOC, \
|
||||||
}; \
|
}; \
|
||||||
@ -267,7 +267,7 @@ struct mem_stats {
|
|||||||
#undef __free
|
#undef __free
|
||||||
#define __free(x) ({ \
|
#define __free(x) ({ \
|
||||||
void *__x = (x); \
|
void *__x = (x); \
|
||||||
static struct mem_stats _ __attribute__((used,__section__("mem_stats"))) = { \
|
static struct mem_stats _ __attribute__((used,__section__("mem_stats"),__aligned__(sizeof(void*)))) = { \
|
||||||
.file = __FILE__, .line = __LINE__, \
|
.file = __FILE__, .line = __LINE__, \
|
||||||
.type = MEM_STATS_TYPE_FREE, \
|
.type = MEM_STATS_TYPE_FREE, \
|
||||||
}; \
|
}; \
|
||||||
@ -281,7 +281,7 @@ struct mem_stats {
|
|||||||
#undef ha_free
|
#undef ha_free
|
||||||
#define ha_free(x) ({ \
|
#define ha_free(x) ({ \
|
||||||
typeof(x) __x = (x); \
|
typeof(x) __x = (x); \
|
||||||
static struct mem_stats _ __attribute__((used,__section__("mem_stats"))) = { \
|
static struct mem_stats _ __attribute__((used,__section__("mem_stats"),__aligned__(sizeof(void*)))) = { \
|
||||||
.file = __FILE__, .line = __LINE__, \
|
.file = __FILE__, .line = __LINE__, \
|
||||||
.type = MEM_STATS_TYPE_FREE, \
|
.type = MEM_STATS_TYPE_FREE, \
|
||||||
}; \
|
}; \
|
||||||
@ -299,7 +299,7 @@ struct mem_stats {
|
|||||||
#undef malloc
|
#undef malloc
|
||||||
#define malloc(x) ({ \
|
#define malloc(x) ({ \
|
||||||
size_t __x = (x); \
|
size_t __x = (x); \
|
||||||
static struct mem_stats _ __attribute__((used,__section__("mem_stats"))) = { \
|
static struct mem_stats _ __attribute__((used,__section__("mem_stats"),__aligned__(sizeof(void*)))) = { \
|
||||||
.file = __FILE__, .line = __LINE__, \
|
.file = __FILE__, .line = __LINE__, \
|
||||||
.type = MEM_STATS_TYPE_MALLOC, \
|
.type = MEM_STATS_TYPE_MALLOC, \
|
||||||
}; \
|
}; \
|
||||||
@ -313,7 +313,7 @@ struct mem_stats {
|
|||||||
#undef realloc
|
#undef realloc
|
||||||
#define realloc(x,y) ({ \
|
#define realloc(x,y) ({ \
|
||||||
void *__x = (x); size_t __y = (y); \
|
void *__x = (x); size_t __y = (y); \
|
||||||
static struct mem_stats _ __attribute__((used,__section__("mem_stats"))) = { \
|
static struct mem_stats _ __attribute__((used,__section__("mem_stats"),__aligned__(sizeof(void*)))) = { \
|
||||||
.file = __FILE__, .line = __LINE__, \
|
.file = __FILE__, .line = __LINE__, \
|
||||||
.type = MEM_STATS_TYPE_REALLOC, \
|
.type = MEM_STATS_TYPE_REALLOC, \
|
||||||
}; \
|
}; \
|
||||||
@ -327,7 +327,7 @@ struct mem_stats {
|
|||||||
#undef strdup
|
#undef strdup
|
||||||
#define strdup(x) ({ \
|
#define strdup(x) ({ \
|
||||||
const char *__x = (x); size_t __y = strlen(__x); \
|
const char *__x = (x); size_t __y = strlen(__x); \
|
||||||
static struct mem_stats _ __attribute__((used,__section__("mem_stats"))) = { \
|
static struct mem_stats _ __attribute__((used,__section__("mem_stats"),__aligned__(sizeof(void*)))) = { \
|
||||||
.file = __FILE__, .line = __LINE__, \
|
.file = __FILE__, .line = __LINE__, \
|
||||||
.type = MEM_STATS_TYPE_STRDUP, \
|
.type = MEM_STATS_TYPE_STRDUP, \
|
||||||
}; \
|
}; \
|
||||||
|
@ -255,7 +255,7 @@ static inline void *pool_get_from_cache(struct pool_head *pool, const void *call
|
|||||||
#define pool_free(pool, ptr) ({ \
|
#define pool_free(pool, ptr) ({ \
|
||||||
struct pool_head *__pool = (pool); \
|
struct pool_head *__pool = (pool); \
|
||||||
typeof(ptr) __ptr = (ptr); \
|
typeof(ptr) __ptr = (ptr); \
|
||||||
static struct mem_stats _ __attribute__((used,__section__("mem_stats"))) = { \
|
static struct mem_stats _ __attribute__((used,__section__("mem_stats"),__aligned__(sizeof(void*)))) = { \
|
||||||
.file = __FILE__, .line = __LINE__, \
|
.file = __FILE__, .line = __LINE__, \
|
||||||
.type = MEM_STATS_TYPE_P_FREE, \
|
.type = MEM_STATS_TYPE_P_FREE, \
|
||||||
}; \
|
}; \
|
||||||
@ -271,7 +271,7 @@ static inline void *pool_get_from_cache(struct pool_head *pool, const void *call
|
|||||||
#define pool_alloc(pool) ({ \
|
#define pool_alloc(pool) ({ \
|
||||||
struct pool_head *__pool = (pool); \
|
struct pool_head *__pool = (pool); \
|
||||||
size_t __x = __pool->size; \
|
size_t __x = __pool->size; \
|
||||||
static struct mem_stats _ __attribute__((used,__section__("mem_stats"))) = { \
|
static struct mem_stats _ __attribute__((used,__section__("mem_stats"),__aligned__(sizeof(void*)))) = { \
|
||||||
.file = __FILE__, .line = __LINE__, \
|
.file = __FILE__, .line = __LINE__, \
|
||||||
.type = MEM_STATS_TYPE_P_ALLOC, \
|
.type = MEM_STATS_TYPE_P_ALLOC, \
|
||||||
}; \
|
}; \
|
||||||
@ -285,7 +285,7 @@ static inline void *pool_get_from_cache(struct pool_head *pool, const void *call
|
|||||||
#define pool_zalloc(pool) ({ \
|
#define pool_zalloc(pool) ({ \
|
||||||
struct pool_head *__pool = (pool); \
|
struct pool_head *__pool = (pool); \
|
||||||
size_t __x = __pool->size; \
|
size_t __x = __pool->size; \
|
||||||
static struct mem_stats _ __attribute__((used,__section__("mem_stats"))) = { \
|
static struct mem_stats _ __attribute__((used,__section__("mem_stats"),__aligned__(sizeof(void*)))) = { \
|
||||||
.file = __FILE__, .line = __LINE__, \
|
.file = __FILE__, .line = __LINE__, \
|
||||||
.type = MEM_STATS_TYPE_P_ALLOC, \
|
.type = MEM_STATS_TYPE_P_ALLOC, \
|
||||||
}; \
|
}; \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user