Приветствую! Недавно, я решил собрать DPITunnel под архитектуру MIPS, для того чтобы поднять его на маршрутизаторе. Как я и ожидал - столкнулся с проблемами сборки (в моём случае, всё падает на этапе линковки). Они были связаны с отсутствием libssl под онную арху, из-за чего пришлось собрать эту библиотеку самому. Несмотря на то, что крашдамп заметно уменьшился, полностью он не исчез. На этот какая-то непонятная фигня. В гугле пишут, что нужно добавить флаг сборки -latomic
, который не помог мне решить эту проблему. Я также пробовал собрать с помощью шланга, но там ошибки ещё на этапе компиляции.
Собирал libssl с такими флагами: -shared -fPIC -Ofast -march=mips32r2 -mtune=mips32r2 -mfp32 -L/usr/lib/gcc-cross/mips-linux-gnu/12 -pthread -latomic
Флаги сборки DPITunnel: -L/usr/lib/gcc-cross/mips-linux-gnu/12/ -latomic -Ofast -pipe -fno-strict-aliasing -L/usr/lib/mips-linux-gnu -lssl -lcrypto -fpermissive -march=mips32r2 -mtune=mips32r2 -mfp32 -pthread
Крашдамп:
[ 5%] Building CXX object RawSocket/CMakeFiles/RawSocket.dir/CheckSum.cpp.o
[ 27%] Building CXX object dnslib/CMakeFiles/dnslib.dir/buffer.cpp.o
[ 27%] Building CXX object dnslib/CMakeFiles/dnslib.dir/rr.cpp.o
[ 27%] Building CXX object dnslib/CMakeFiles/dnslib.dir/message.cpp.o
[ 27%] Building CXX object dnslib/CMakeFiles/dnslib.dir/qs.cpp.o
[ 33%] Linking CXX static library libRawSocket.a
[ 33%] Built target RawSocket
[ 38%] Linking CXX static library libdnslib.a
[ 38%] Built target dnslib
[ 55%] Building CXX object CMakeFiles/dpitunnel.dir/netiface.cpp.o
[ 55%] Building CXX object CMakeFiles/dpitunnel.dir/autoconf.cpp.o
[ 55%] Building CXX object CMakeFiles/dpitunnel.dir/desync.cpp.o
[ 61%] Building CXX object CMakeFiles/dpitunnel.dir/profiles.cpp.o
[ 66%] Building CXX object CMakeFiles/dpitunnel.dir/packet.cpp.o
[ 77%] Building CXX object CMakeFiles/dpitunnel.dir/dpitunnel.cpp.o
[ 77%] Building CXX object CMakeFiles/dpitunnel.dir/utils.cpp.o
[ 83%] Building CXX object CMakeFiles/dpitunnel.dir/socket.cpp.o
[ 88%] Building CXX object CMakeFiles/dpitunnel.dir/dns.cpp.o
[ 94%] Building CXX object CMakeFiles/dpitunnel.dir/ssl.cpp.o
/home/skunk/DPITunnel/netiface.cpp: In function 'int get_scan_callback(nl_msg*, void*)':
/home/skunk/DPITunnel/netiface.cpp:276:10: warning: unused variable 'mac_addr' [-Wunused-variable]
276 | char mac_addr[18];
| ^~~~~~~~
/home/skunk/DPITunnel/utils.cpp: In function 'void daemonize()':
/home/skunk/DPITunnel/utils.cpp:200:9: warning: variable 'fd' set but not used [-Wunused-but-set-variable]
200 | int fd;
| ^~
/home/skunk/DPITunnel/autoconf.cpp: In function 'int check_https_response(int, std::string, std::string, int, int, const std::string&, SSL_CTX*, X509_STORE*)':
/home/skunk/DPITunnel/autoconf.cpp:96:45: warning: comparison of integer expressions of different signedness: 'unsigned int' and 'int' [-Wsign-compare]
96 | if (sni_start + sni_len > res || sni_start == 0 || sni_len == 0)
| ~~~~~~~~~~~~~~~~~~~~^~~~~
/home/skunk/DPITunnel/dpitunnel.cpp: In function 'int main(int, char**)':
/home/skunk/DPITunnel/dpitunnel.cpp:789:9: warning: ignoring return value of 'int pipe(int*)' declared with attribute 'warn_unused_result' [-Wunused-result]
789 | pipe(Interrupt_pipe);
| ~~~~^~~~~~~~~~~~~~~~
/home/skunk/DPITunnel/autoconf.cpp: In function 'int run_autoconf()':
/home/skunk/DPITunnel/autoconf.cpp:559:51: warning: 'ctx' may be used uninitialized [-Wmaybe-uninitialized]
559 | if (test_desync_attack_wrapper(host, ip, port, is_https, ctx, store) ==
| ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/skunk/DPITunnel/autoconf.cpp:470:14: note: 'ctx' was declared here
470 | SSL_CTX *ctx;
| ^~~
/home/skunk/DPITunnel/autoconf.cpp:559:51: warning: 'store' may be used uninitialized [-Wmaybe-uninitialized]
559 | if (test_desync_attack_wrapper(host, ip, port, is_https, ctx, store) ==
| ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/skunk/DPITunnel/autoconf.cpp:469:17: note: 'store' was declared here
469 | X509_STORE *store;
| ^~~~~
In file included from /home/skunk/DPITunnel/dns.cpp:23:
/home/skunk/DPITunnel/include/base64.h:25:20: warning: 'std::string base64_decode(const std::string&)' defined but not used [-Wunused-function]
25 | static std::string base64_decode(const std::string &in) {
| ^~~~~~~~~~~~~
[100%] Linking CXX executable dpitunnel
/usr/lib/gcc-cross/mips-linux-gnu/12/../../../../mips-linux-gnu/bin/ld: /usr/lib/mips-linux-gnu/libcrypto.a(libcrypto-lib-dso_dlfcn.o): in function `dlfcn_globallookup':
dso_dlfcn.c:(.text+0x10): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/gcc-cross/mips-linux-gnu/12/../../../../mips-linux-gnu/bin/ld: /usr/lib/mips-linux-gnu/libcrypto.a(libcrypto-lib-dso_dlfcn.o): note: the message above does not take linker garbage collection into account
/usr/lib/gcc-cross/mips-linux-gnu/12/../../../../mips-linux-gnu/bin/ld: CMakeFiles/dpitunnel.dir/dns.cpp.o: in function `httplib::detail::create_client_socket(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, int, bool, std::function<void (int)>, long long, long long, long long, long long, long long, long long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, httplib::Error&)::{lambda(int, addrinfo&)#1}::operator()(int, addrinfo&) const':
dns.cpp:(.text._ZZN7httplib6detail20create_client_socketERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES8_iibSt8functionIFviEExxxxxxS8_RNS_5ErrorEENKUliR8addrinfoE_clEiSF_[_ZZN7httplib6detail20create_client_socketERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES8_iibSt8functionIFviEExxxxxxS8_RNS_5ErrorEENKUliR8addrinfoE_clEiSF_]+0x244): warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/gcc-cross/mips-linux-gnu/12/../../../../mips-linux-gnu/bin/ld: CMakeFiles/dpitunnel.dir/dns.cpp.o: note: the message above does not take linker garbage collection into account
/usr/lib/gcc-cross/mips-linux-gnu/12/../../../../mips-linux-gnu/bin/ld: /usr/lib/mips-linux-gnu/libcrypto.a(libcrypto-lib-bio_sock.o): in function `BIO_gethostbyname':
bio_sock.c:(.text+0x428): warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/gcc-cross/mips-linux-gnu/12/../../../../mips-linux-gnu/bin/ld: /usr/lib/mips-linux-gnu/libcrypto.a(libcrypto-lib-bio_sock.o): note: the message above does not take linker garbage collection into account
/usr/lib/gcc-cross/mips-linux-gnu/12/../../../../mips-linux-gnu/bin/ld: /usr/lib/mips-linux-gnu/libnl-3.a(libnl_3_la-utils.o): in function `nl_getprotobynumber.localalias':
utils.c:(.text+0x844): warning: Using 'getprotobynumber_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/gcc-cross/mips-linux-gnu/12/../../../../mips-linux-gnu/bin/ld: /usr/lib/mips-linux-gnu/libnl-3.a(libnl_3_la-utils.o): note: the message above does not take linker garbage collection into account
/usr/lib/gcc-cross/mips-linux-gnu/12/../../../../mips-linux-gnu/bin/ld: /usr/lib/mips-linux-gnu/libnl-3.a(libnl_3_la-utils.o): in function `nl_getprotobyname.localalias':
utils.c:(.text+0x784): warning: Using 'getprotobyname_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/gcc-cross/mips-linux-gnu/12/../../../../mips-linux-gnu/bin/ld: /usr/lib/mips-linux-gnu/libnl-3.a(libnl_3_la-utils.o): note: the message above does not take linker garbage collection into account
/usr/lib/gcc-cross/mips-linux-gnu/12/../../../../mips-linux-gnu/bin/ld: /usr/lib/mips-linux-gnu/libcrypto.a(libcrypto-lib-threads_pthread.o): in function `ossl_rcu_read_lock':
threads_pthread.c:(.text+0x3a0): undefined reference to `__atomic_fetch_sub_8'
/usr/lib/gcc-cross/mips-linux-gnu/12/../../../../mips-linux-gnu/bin/ld: threads_pthread.c:(.text+0x3ac): undefined reference to `__atomic_fetch_sub_8'
/usr/lib/gcc-cross/mips-linux-gnu/12/../../../../mips-linux-gnu/bin/ld: threads_pthread.c:(.text+0x3c8): undefined reference to `__atomic_fetch_add_8'
/usr/lib/gcc-cross/mips-linux-gnu/12/../../../../mips-linux-gnu/bin/ld: threads_pthread.c:(.text+0x3d8): undefined reference to `__atomic_fetch_add_8'
/usr/lib/gcc-cross/mips-linux-gnu/12/../../../../mips-linux-gnu/bin/ld: /usr/lib/mips-linux-gnu/libcrypto.a(libcrypto-lib-threads_pthread.o): in function `ossl_rcu_read_unlock':
threads_pthread.c:(.text+0x78c): undefined reference to `__atomic_fetch_sub_8'
/usr/lib/gcc-cross/mips-linux-gnu/12/../../../../mips-linux-gnu/bin/ld: threads_pthread.c:(.text+0x7a0): undefined reference to `__atomic_fetch_sub_8'
/usr/lib/gcc-cross/mips-linux-gnu/12/../../../../mips-linux-gnu/bin/ld: /usr/lib/mips-linux-gnu/libcrypto.a(libcrypto-lib-threads_pthread.o): in function `ossl_synchronize_rcu.localalias':
threads_pthread.c:(.text+0x920): undefined reference to `__atomic_fetch_and_8'
/usr/lib/gcc-cross/mips-linux-gnu/12/../../../../mips-linux-gnu/bin/ld: threads_pthread.c:(.text+0x94c): undefined reference to `__atomic_fetch_and_8'
/usr/lib/gcc-cross/mips-linux-gnu/12/../../../../mips-linux-gnu/bin/ld: threads_pthread.c:(.text+0x968): undefined reference to `__atomic_fetch_or_8'
/usr/lib/gcc-cross/mips-linux-gnu/12/../../../../mips-linux-gnu/bin/ld: threads_pthread.c:(.text+0x96c): undefined reference to `__atomic_fetch_or_8'
/usr/lib/gcc-cross/mips-linux-gnu/12/../../../../mips-linux-gnu/bin/ld: threads_pthread.c:(.text+0x9b0): undefined reference to `__atomic_load_8'
/usr/lib/gcc-cross/mips-linux-gnu/12/../../../../mips-linux-gnu/bin/ld: threads_pthread.c:(.text+0x9b8): undefined reference to `__atomic_load_8'
/usr/lib/gcc-cross/mips-linux-gnu/12/../../../../mips-linux-gnu/bin/ld: /usr/lib/mips-linux-gnu/libcrypto.a(libcrypto-lib-threads_pthread.o): in function `CRYPTO_atomic_add64':
threads_pthread.c:(.text+0x1054): undefined reference to `__atomic_is_lock_free'
/usr/lib/gcc-cross/mips-linux-gnu/12/../../../../mips-linux-gnu/bin/ld: threads_pthread.c:(.text+0x108c): undefined reference to `__atomic_is_lock_free'
/usr/lib/gcc-cross/mips-linux-gnu/12/../../../../mips-linux-gnu/bin/ld: threads_pthread.c:(.text+0x1138): undefined reference to `__atomic_fetch_add_8'
/usr/lib/gcc-cross/mips-linux-gnu/12/../../../../mips-linux-gnu/bin/ld: threads_pthread.c:(.text+0x114c): undefined reference to `__atomic_fetch_add_8'
/usr/lib/gcc-cross/mips-linux-gnu/12/../../../../mips-linux-gnu/bin/ld: /usr/lib/mips-linux-gnu/libcrypto.a(libcrypto-lib-threads_pthread.o): in function `CRYPTO_atomic_and':
threads_pthread.c:(.text+0x11a4): undefined reference to `__atomic_is_lock_free'
/usr/lib/gcc-cross/mips-linux-gnu/12/../../../../mips-linux-gnu/bin/ld: threads_pthread.c:(.text+0x11dc): undefined reference to `__atomic_is_lock_free'
/usr/lib/gcc-cross/mips-linux-gnu/12/../../../../mips-linux-gnu/bin/ld: threads_pthread.c:(.text+0x1280): undefined reference to `__atomic_fetch_and_8'
/usr/lib/gcc-cross/mips-linux-gnu/12/../../../../mips-linux-gnu/bin/ld: threads_pthread.c:(.text+0x1294): undefined reference to `__atomic_fetch_and_8'
/usr/lib/gcc-cross/mips-linux-gnu/12/../../../../mips-linux-gnu/bin/ld: /usr/lib/mips-linux-gnu/libcrypto.a(libcrypto-lib-threads_pthread.o): in function `CRYPTO_atomic_or':
threads_pthread.c:(.text+0x12e4): undefined reference to `__atomic_is_lock_free'
/usr/lib/gcc-cross/mips-linux-gnu/12/../../../../mips-linux-gnu/bin/ld: threads_pthread.c:(.text+0x131c): undefined reference to `__atomic_is_lock_free'
/usr/lib/gcc-cross/mips-linux-gnu/12/../../../../mips-linux-gnu/bin/ld: threads_pthread.c:(.text+0x13c0): undefined reference to `__atomic_fetch_or_8'
/usr/lib/gcc-cross/mips-linux-gnu/12/../../../../mips-linux-gnu/bin/ld: threads_pthread.c:(.text+0x13d4): undefined reference to `__atomic_fetch_or_8'
/usr/lib/gcc-cross/mips-linux-gnu/12/../../../../mips-linux-gnu/bin/ld: /usr/lib/mips-linux-gnu/libcrypto.a(libcrypto-lib-threads_pthread.o): in function `CRYPTO_atomic_load':
threads_pthread.c:(.text+0x1424): undefined reference to `__atomic_is_lock_free'
/usr/lib/gcc-cross/mips-linux-gnu/12/../../../../mips-linux-gnu/bin/ld: threads_pthread.c:(.text+0x144c): undefined reference to `__atomic_is_lock_free'
/usr/lib/gcc-cross/mips-linux-gnu/12/../../../../mips-linux-gnu/bin/ld: threads_pthread.c:(.text+0x14d0): undefined reference to `__atomic_load_8'
/usr/lib/gcc-cross/mips-linux-gnu/12/../../../../mips-linux-gnu/bin/ld: threads_pthread.c:(.text+0x14d8): undefined reference to `__atomic_load_8'
/usr/lib/gcc-cross/mips-linux-gnu/12/../../../../mips-linux-gnu/bin/ld: /usr/lib/mips-linux-gnu/libcrypto.a(libcrypto-lib-threads_pthread.o): in function `CRYPTO_atomic_store':
threads_pthread.c:(.text+0x1518): undefined reference to `__atomic_is_lock_free'
/usr/lib/gcc-cross/mips-linux-gnu/12/../../../../mips-linux-gnu/bin/ld: threads_pthread.c:(.text+0x1548): undefined reference to `__atomic_is_lock_free'
/usr/lib/gcc-cross/mips-linux-gnu/12/../../../../mips-linux-gnu/bin/ld: threads_pthread.c:(.text+0x15c4): undefined reference to `__atomic_store_8'
/usr/lib/gcc-cross/mips-linux-gnu/12/../../../../mips-linux-gnu/bin/ld: threads_pthread.c:(.text+0x15d8): undefined reference to `__atomic_store_8'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/dpitunnel.dir/build.make:245: dpitunnel] Error 1
make[1]: *** [CMakeFiles/Makefile2:137: CMakeFiles/dpitunnel.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
Собираю из-под контейнера с самой последней убунтой. Версия GCC: mips-linux-gnu-gcc (Ubuntu 12.3.0-17ubuntu1) 12.3.0