mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-10 09:07:02 +02:00
BUILD: tools: rely on __ELF__ not USE_DL to enable use of dladdr()
The approach was wrong. USE_DL is for the makefile to know if it's required to append -ldl at link time. Some platforms do not need it (and in fact do not have it) yet they have a working dladdr(). The real condition is related to ELF. Given that due to Lua, all platforms that require -ldl already have USE_DL set, let's replace USE_DL with __ELF__ here and consider that dladdr is always needed on ELF, which basically is already the case.
This commit is contained in:
parent
9133e48f2a
commit
109201fc5c
@ -10,7 +10,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(USE_DL)
|
#ifdef __ELF__
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
#include <link.h>
|
#include <link.h>
|
||||||
@ -4335,7 +4335,7 @@ void debug_hexdump(FILE *out, const char *pfx, const char *buf,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_DL
|
#ifdef __ELF__
|
||||||
/* calls dladdr() or dladdr1() on <addr> and <dli>. If dladdr1 is available,
|
/* calls dladdr() or dladdr1() on <addr> and <dli>. If dladdr1 is available,
|
||||||
* also returns the symbol size in <size>, otherwise returns 0 there.
|
* also returns the symbol size in <size>, otherwise returns 0 there.
|
||||||
*/
|
*/
|
||||||
@ -4369,7 +4369,7 @@ static int dladdr_and_size(const void *addr, Dl_info *dli, size_t *size)
|
|||||||
* The file name (lib or executable) is limited to what lies between the last
|
* The file name (lib or executable) is limited to what lies between the last
|
||||||
* '/' and the first following '.'. An optional prefix <pfx> is prepended before
|
* '/' and the first following '.'. An optional prefix <pfx> is prepended before
|
||||||
* the output if not null. The file is not dumped when it's the same as the one
|
* the output if not null. The file is not dumped when it's the same as the one
|
||||||
* that contains the "main" symbol, or when USE_DL is not set.
|
* that contains the "main" symbol, or when __ELF__ is not set.
|
||||||
*
|
*
|
||||||
* The symbol's base address is returned, or NULL when unresolved, in order to
|
* The symbol's base address is returned, or NULL when unresolved, in order to
|
||||||
* allow the caller to match it against known ones.
|
* allow the caller to match it against known ones.
|
||||||
@ -4397,7 +4397,7 @@ void *resolve_sym_name(struct buffer *buf, const char *pfx, void *addr)
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef USE_DL
|
#ifdef __ELF__
|
||||||
Dl_info dli, dli_main;
|
Dl_info dli, dli_main;
|
||||||
size_t size;
|
size_t size;
|
||||||
const char *fname, *p;
|
const char *fname, *p;
|
||||||
@ -4414,7 +4414,7 @@ void *resolve_sym_name(struct buffer *buf, const char *pfx, void *addr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_DL
|
#ifdef __ELF__
|
||||||
/* Now let's try to be smarter */
|
/* Now let's try to be smarter */
|
||||||
if (!dladdr_and_size(addr, &dli, &size))
|
if (!dladdr_and_size(addr, &dli, &size))
|
||||||
goto unknown;
|
goto unknown;
|
||||||
@ -4454,7 +4454,7 @@ void *resolve_sym_name(struct buffer *buf, const char *pfx, void *addr)
|
|||||||
chunk_appendf(buf, "+%#lx", (long)(addr - dli.dli_fbase));
|
chunk_appendf(buf, "+%#lx", (long)(addr - dli.dli_fbase));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#endif /* USE_DL */
|
#endif /* __ELF__ */
|
||||||
unknown:
|
unknown:
|
||||||
/* unresolved symbol from the main file, report relative offset to main */
|
/* unresolved symbol from the main file, report relative offset to main */
|
||||||
if ((void*)addr < (void*)main)
|
if ((void*)addr < (void*)main)
|
||||||
|
Loading…
Reference in New Issue
Block a user