From: Olivier Houchard Date: Wed, 28 Oct 2026 17:51:13 +0000 (+0100) Subject: MINOR: sym: use the symbol table to resolve a DSO name X-Git-Tag: v3.5-dev11~93 X-Git-Url: https://git.kaiwu.me/?a=commitdiff_plain;h=e596dcdca89c04cd8ed53d4f8c4004aa824fb3b2;p=haproxy.git MINOR: sym: use the symbol table to resolve a DSO name resolve_dso_name() only used dladdr() to find the object containing an address. Our in-process symbol table also knows the owning object, is lock-free and async-signal-safe, and also works on static builds where dladdr() may not. Try it first and keep dladdr() as a fallback for addresses that are not covered by any symbol, or when the table has not been built yet. --- diff --git a/src/sym.c b/src/sym.c index a3fe65d48..412c82caf 100644 --- a/src/sym.c +++ b/src/sym.c @@ -1854,21 +1854,29 @@ const void *resolve_sym_name(struct buffer *buf, const char *pfx, const void *ad */ const void *resolve_dso_name(struct buffer *buf, const char *pfx, const void *addr) { + struct sym_lookup sl; + + if (sym_resolve(addr, &sl) && sl.file) { + if (pfx) + chunk_appendf(buf, "%s", pfx); + append_obj_name(buf, sl.file); + return addr; + } + #if (defined(__ELF__) && !defined(__linux__)) || defined(USE_DL) - Dl_info dli; - size_t size; + { + Dl_info dli; + size_t size; - /* Now let's try to be smarter */ - if (!dladdr_and_size(addr, &dli, &size)) - goto unknown; + /* Now let's try to be smarter */ + if (!dladdr_and_size(addr, &dli, &size)) + goto unknown; - if (pfx) { - chunk_appendf(buf, "%s", pfx); - pfx = NULL; + if (pfx) + chunk_appendf(buf, "%s", pfx); + append_obj_name(buf, dli.dli_fname); + return addr; } - - append_obj_name(buf, dli.dli_fname); - return addr; unknown: #endif /* __ELF__ && !__linux__ || USE_DL */