Skip to content

Commit dcb154e

Browse files
committed
Merge #13177: GCC-7 and glibc-2.27 back compat code
253f592 Add stdin, stdout, stderr to ignored export list (Chun Kuan Lee) fc6a9f2 Use IN6ADDR_ANY_INIT instead of in6addr_any (Cory Fields) 908c1d7 GCC-7 and glibc-2.27 compat code (Chun Kuan Lee) Pull request description: The `__divmoddi4` code was modified from https://github.com/gcc-mirror/gcc/blob/master/libgcc/libgcc2.c . I manually find the older glibc version of log2f by objdump, use `.symver` to specify the certain version. Tree-SHA512: e8d875652003618c73e019ccc420e7a25d46f4eaff1c7a1a6bfc1770b3b46f074b368b2cb14df541b5ab124cca41dede4e28fe863a670589b834ef6b8713f9c4
2 parents 9b638c7 + 253f592 commit dcb154e

File tree

5 files changed

+51
-2
lines changed

5 files changed

+51
-2
lines changed

configure.ac

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,8 @@ if test x$use_glibc_compat != xno; then
651651
[ fdelt_type="long int"])
652652
AC_MSG_RESULT($fdelt_type)
653653
AC_DEFINE_UNQUOTED(FDELT_TYPE, $fdelt_type,[parameter and return value type for __fdelt_chk])
654+
AX_CHECK_LINK_FLAG([[-Wl,--wrap=__divmoddi4]], [COMPAT_LDFLAGS="$COMPAT_LDFLAGS -Wl,--wrap=__divmoddi4"])
655+
AX_CHECK_LINK_FLAG([[-Wl,--wrap=log2f]], [COMPAT_LDFLAGS="$COMPAT_LDFLAGS -Wl,--wrap=log2f"])
654656
else
655657
AC_SEARCH_LIBS([clock_gettime],[rt])
656658
fi
@@ -1351,6 +1353,7 @@ AC_SUBST(DEBUG_CPPFLAGS)
13511353
AC_SUBST(WARN_CXXFLAGS)
13521354
AC_SUBST(NOWARN_CXXFLAGS)
13531355
AC_SUBST(DEBUG_CXXFLAGS)
1356+
AC_SUBST(COMPAT_LDFLAGS)
13541357
AC_SUBST(ERROR_CXXFLAGS)
13551358
AC_SUBST(GPROF_CXXFLAGS)
13561359
AC_SUBST(GPROF_LDFLAGS)

contrib/devtools/symbol-check.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646

4747
# Ignore symbols that are exported as part of every executable
4848
IGNORE_EXPORTS = {
49-
'_edata', '_end', '_init', '__bss_start', '_fini', '_IO_stdin_used'
49+
'_edata', '_end', '_init', '__bss_start', '_fini', '_IO_stdin_used', 'stdin', 'stdout', 'stderr'
5050
}
5151
READELF_CMD = os.getenv('READELF', '/usr/bin/readelf')
5252
CPPFILT_CMD = os.getenv('CPPFILT', '/usr/bin/c++filt')

src/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,7 @@ libbitcoin_util_a_SOURCES = \
418418

419419
if GLIBC_BACK_COMPAT
420420
libbitcoin_util_a_SOURCES += compat/glibc_compat.cpp
421+
AM_LDFLAGS += $(COMPAT_LDFLAGS)
421422
endif
422423

423424
# cli: shared between bitcoin-cli and bitcoin-qt

src/compat/glibc_compat.cpp

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#endif
88

99
#include <cstddef>
10+
#include <cstdint>
1011

1112
#if defined(HAVE_SYS_SELECT_H)
1213
#include <sys/select.h>
@@ -27,3 +28,47 @@ extern "C" FDELT_TYPE __fdelt_warn(FDELT_TYPE a)
2728
return a / __NFDBITS;
2829
}
2930
extern "C" FDELT_TYPE __fdelt_chk(FDELT_TYPE) __attribute__((weak, alias("__fdelt_warn")));
31+
32+
#if defined(__i386__) || defined(__arm__)
33+
34+
extern "C" int64_t __udivmoddi4(uint64_t u, uint64_t v, uint64_t* rp);
35+
36+
extern "C" int64_t __wrap___divmoddi4(int64_t u, int64_t v, int64_t* rp)
37+
{
38+
int32_t c1 = 0, c2 = 0;
39+
int64_t uu = u, vv = v;
40+
int64_t w;
41+
int64_t r;
42+
43+
if (uu < 0) {
44+
c1 = ~c1, c2 = ~c2, uu = -uu;
45+
}
46+
if (vv < 0) {
47+
c1 = ~c1, vv = -vv;
48+
}
49+
50+
w = __udivmoddi4(uu, vv, (uint64_t*)&r);
51+
if (c1)
52+
w = -w;
53+
if (c2)
54+
r = -r;
55+
56+
*rp = r;
57+
return w;
58+
}
59+
#endif
60+
61+
extern "C" float log2f_old(float x);
62+
#ifdef __i386__
63+
__asm(".symver log2f_old,log2f@GLIBC_2.1");
64+
#elif defined(__amd64__)
65+
__asm(".symver log2f_old,log2f@GLIBC_2.2.5");
66+
#elif defined(__arm__)
67+
__asm(".symver log2f_old,log2f@GLIBC_2.4");
68+
#elif defined(__aarch64__)
69+
__asm(".symver log2f_old,log2f@GLIBC_2.17");
70+
#endif
71+
extern "C" float __wrap_log2f(float x)
72+
{
73+
return log2f_old(x);
74+
}

src/net.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2254,7 +2254,7 @@ bool CConnman::InitBinds(const std::vector<CService>& binds, const std::vector<C
22542254
if (binds.empty() && whiteBinds.empty()) {
22552255
struct in_addr inaddr_any;
22562256
inaddr_any.s_addr = INADDR_ANY;
2257-
fBound |= Bind(CService(in6addr_any, GetListenPort()), BF_NONE);
2257+
fBound |= Bind(CService((in6_addr)IN6ADDR_ANY_INIT, GetListenPort()), BF_NONE);
22582258
fBound |= Bind(CService(inaddr_any, GetListenPort()), !fBound ? BF_REPORT_ERROR : BF_NONE);
22592259
}
22602260
return fBound;

0 commit comments

Comments
 (0)