"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/tools.c" between
haproxy-2.2.1.tar.gz and haproxy-2.2.2.tar.gz

About: HAProxy is a TCP/HTTP reverse proxy which is particularly suited for high availability environments.

tools.c  (haproxy-2.2.1):tools.c  (haproxy-2.2.2)
skipping to change at line 13 skipping to change at line 13
* *
* Copyright 2000-2010 Willy Tarreau <w@1wt.eu> * Copyright 2000-2010 Willy Tarreau <w@1wt.eu>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version * as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version. * 2 of the License, or (at your option) any later version.
* *
*/ */
#ifdef __ELF__ #if (defined(__ELF__) && !defined(__linux__)) || defined(USE_DL)
#define _GNU_SOURCE #define _GNU_SOURCE
#include <dlfcn.h> #include <dlfcn.h>
#include <link.h> #include <link.h>
#endif #endif
#if (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 16)) #if (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 16))
#include <sys/auxv.h> #include <sys/auxv.h>
#endif #endif
#include <ctype.h> #include <ctype.h>
skipping to change at line 4384 skipping to change at line 4384
#if (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 16)) #if (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 16))
long execfn = getauxval(AT_EXECFN); long execfn = getauxval(AT_EXECFN);
if (execfn && execfn != ENOENT) if (execfn && execfn != ENOENT)
ret = (const char *)execfn; ret = (const char *)execfn;
#endif #endif
return ret; return ret;
} }
#ifdef __ELF__ #if (defined(__ELF__) && !defined(__linux__)) || defined(USE_DL)
/* 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.
*/ */
static int dladdr_and_size(const void *addr, Dl_info *dli, size_t *size) static int dladdr_and_size(const void *addr, Dl_info *dli, size_t *size)
{ {
int ret; int ret;
#if (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) // most detailed one #if (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) // most detailed one
const ElfW(Sym) *sym; const ElfW(Sym) *sym;
ret = dladdr1(addr, dli, (void **)&sym, RTLD_DL_SYMENT); ret = dladdr1(addr, dli, (void **)&sym, RTLD_DL_SYMENT);
skipping to change at line 4418 skipping to change at line 4418
* main+0xoffset (unresolvable address from main (+/-)) * main+0xoffset (unresolvable address from main (+/-))
* lib:main+0xoffset (unresolvable lib address from main (+/-)) * lib:main+0xoffset (unresolvable lib address from main (+/-))
* name (resolved exact exec address) * name (resolved exact exec address)
* lib:name (resolved exact lib address) * lib:name (resolved exact lib address)
* name+0xoffset/0xsize (resolved address within exec symbol) * name+0xoffset/0xsize (resolved address within exec symbol)
* lib:name+0xoffset/0xsize (resolved address within lib symbol) * lib:name+0xoffset/0xsize (resolved address within lib symbol)
* *
* 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 __ELF__ is not set. * that contains the "main" symbol, or when __ELF__ && USE_DL are 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.
*/ */
const void *resolve_sym_name(struct buffer *buf, const char *pfx, void *addr) const void *resolve_sym_name(struct buffer *buf, const char *pfx, void *addr)
{ {
const struct { const struct {
const void *func; const void *func;
const char *name; const char *name;
} fcts[] = { } fcts[] = {
skipping to change at line 4446 skipping to change at line 4446
{ .func = mworker_accept_wrapper, .name = "mworker_accept_wrapper " }, { .func = mworker_accept_wrapper, .name = "mworker_accept_wrapper " },
#ifdef USE_LUA #ifdef USE_LUA
{ .func = hlua_process_task, .name = "hlua_process_task" }, { .func = hlua_process_task, .name = "hlua_process_task" },
#endif #endif
#if defined(USE_OPENSSL) && (HA_OPENSSL_VERSION_NUMBER >= 0x1010000fL) && !defin ed(OPENSSL_NO_ASYNC) #if defined(USE_OPENSSL) && (HA_OPENSSL_VERSION_NUMBER >= 0x1010000fL) && !defin ed(OPENSSL_NO_ASYNC)
{ .func = ssl_async_fd_free, .name = "ssl_async_fd_free" }, { .func = ssl_async_fd_free, .name = "ssl_async_fd_free" },
{ .func = ssl_async_fd_handler, .name = "ssl_async_fd_handler" }, { .func = ssl_async_fd_handler, .name = "ssl_async_fd_handler" },
#endif #endif
}; };
#ifdef __ELF__ #if (defined(__ELF__) && !defined(__linux__)) || defined(USE_DL)
Dl_info dli, dli_main; Dl_info dli, dli_main;
size_t size; size_t size;
const char *fname, *p; const char *fname, *p;
#endif #endif
int i; int i;
if (pfx) if (pfx)
chunk_appendf(buf, "%s", pfx); chunk_appendf(buf, "%s", pfx);
for (i = 0; i < sizeof(fcts) / sizeof(fcts[0]); i++) { for (i = 0; i < sizeof(fcts) / sizeof(fcts[0]); i++) {
if (addr == fcts[i].func) { if (addr == fcts[i].func) {
chunk_appendf(buf, "%s", fcts[i].name); chunk_appendf(buf, "%s", fcts[i].name);
return addr; return addr;
} }
} }
#ifdef __ELF__ #if (defined(__ELF__) && !defined(__linux__)) || defined(USE_DL)
/* 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;
/* 1. prefix the library name if it's not the same object as the one /* 1. prefix the library name if it's not the same object as the one
* that contains the main function. The name is picked between last '/' * that contains the main function. The name is picked between last '/'
* and first following '.'. * and first following '.'.
*/ */
if (!dladdr(main, &dli_main)) if (!dladdr(main, &dli_main))
dli_main.dli_fbase = NULL; dli_main.dli_fbase = NULL;
skipping to change at line 4503 skipping to change at line 4503
if (size) if (size)
chunk_appendf(buf, "/%#lx", (long)size); chunk_appendf(buf, "/%#lx", (long)size);
} }
return dli.dli_saddr; return dli.dli_saddr;
} }
else if (dli_main.dli_fbase != dli.dli_fbase) { else if (dli_main.dli_fbase != dli.dli_fbase) {
/* unresolved symbol from a known library, report relative offset */ /* unresolved symbol from a known library, report relative offset */
chunk_appendf(buf, "+%#lx", (long)(addr - dli.dli_fbase)); chunk_appendf(buf, "+%#lx", (long)(addr - dli.dli_fbase));
return NULL; return NULL;
} }
#endif /* __ELF__ */ #endif /* __ELF__ && !__linux__ || USE_DL */
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)
chunk_appendf(buf, "main-%#lx", (long)((void*)main - addr)); chunk_appendf(buf, "main-%#lx", (long)((void*)main - addr));
else else
chunk_appendf(buf, "main+%#lx", (long)(addr - (void*)main)); chunk_appendf(buf, "main+%#lx", (long)(addr - (void*)main));
return NULL; return NULL;
} }
/* /*
 End of changes. 6 change blocks. 
6 lines changed or deleted 6 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)