Добрый день! Удалось почти победить кросс-сборку nmap под arm тулчейном gcc+uClibc. Одако на самом последнем этапе - линковке возникли проблемы. nmap загружаю из svn.
Вот строка конфигурации:
./configure --host=arm-android-linux-uclibcgnueabi CC="arm-android-linux-uclibcgnueabi-gcc" \
CXX="arm-android-linux-uclibcgnueabi-g++" STRIP="arm-android-linux-uclibcgnueabi-strip" \
AR="arm-android-linux-uclibcgnueabi-ar" AS="arm-android-linux-uclibcgnueabi-as" \
CPP="arm-android-linux-uclibcgnueabi-cpp" LD="arm-android-linux-uclibcgnueabi-ld" \
RANLIB="arm-android-linux-uclibcgnueabi-ranlib" OBJDUMP="arm-android-linux-uclibcgnueabi-objdump" \
NM="arm-android-linux-uclibcgnueabi-nm" CROSS_COMPILE="arm-android-linux-uclibcgnueabi-" \
CFLAGS=" -nodefaultlibs -nostdlib -fPIC -static $_XXFLAGS -DHAVE_GETADDRINFO -DHAVE_USLEEP -DHAVE_GETTIMEOFDAY \
-DHAVE_SNPRINTF -DHAVE_VSNPRINTF -DHAVE_STRERROR -Dsys_nerr=_sys_nerr -Dsys_errlist=_sys_errlist" \
CXXFLAGS=" -c -nodefaultlibs -nostdlib -fPIC -static $_XXFLAGS -DHAVE_GETADDRINFO -DHAVE_USLEEP -DHAVE_GETTIMEOFDAY \
-DHAVE_SNPRINTF -DHAVE_VSNPRINTF -DHAVE_STRERROR -Dsys_nerr=_sys_nerr -Dsys_errlist=_sys_errlist" \
CPPFLAGS=" -I$HOME/build/cross/sys-root/usr/include" \
LDFLAGS=" -nodefaultlibs -nostdlib -fPIC -static -s -L$HOME/build/cross/sys-root/usr/lib -zmuldefs" \
LIBS=" -lm -lc -lgcc -liberty -lgcc_eh -lstdc++" \
--prefix="$HOME/build/cross/sys-root/usr" --with-liblua=included --with-libpcre=included \
--with-libdnet=included --without-ncat --with-libpcap=included --with-pcap=linux ac_cv_linux_vers=2.6.29
Все проходит нормально, но возникли трудности при линковке конечного бинарника:
.arm-android-linux-uclibcgnueabi-g++: unrecognized option '-zmuldefs'
/home/xvilka/build/cross/sys-root/usr/lib/libc.a(memcmp.os): In function `__GI_memcmp':
(.text+0x0): multiple definition of `memcmp'
libdnet-stripped/src/.libs/libdnet.a(memcmp.o):memcmp.c:(.text+0x0): first defined here
/home/xvilka/build/x-tools/arm-android-linux-uclibcgnueabi/lib/gcc/arm-android-linux-uclibcgnueabi/4.4.3/../../../../arm-android-linux-uclibcgnueabi/bin/ld: warning: cannot find entry symbol _start; defaulting to 00008100
main.o: In function `__static_initialization_and_destruction_0(int, int)':
main.cc:(.text+0x106c): undefined reference to `__dso_handle'
nmap.o: In function `__static_initialization_and_destruction_0(int, int)':
nmap.cc:(.text+0xb96c): undefined reference to `__dso_handle'
targets.o: In function `__static_initialization_and_destruction_0(int, int)':
targets.cc:(.text+0x234c): undefined reference to `__dso_handle'
tcpip.o: In function `__static_initialization_and_destruction_0(int, int)':
tcpip.cc:(.text+0xb938): undefined reference to `__dso_handle'
nmap_error.o: In function `__static_initialization_and_destruction_0(int, int)':
nmap_error.cc:(.text+0x3dc): undefined reference to `__dso_handle'
utils.o:utils.cc:(.text+0x2c70): more undefined references to `__dso_handle' follow
/home/xvilka/build/cross/sys-root/usr/lib/libstdc++.a(locale-inst.o): In function `int std::__int_to_char<char, unsigned long long>(char*, unsigned long long, char const*, std::_Ios_Fmtflags, bool)':
/home/xvilka/build/toolchain-android/targets/arm-android-linux-uclibcgnueabi/build/build-cc/arm-android-linux-uclibcgnueabi/libstdc++-v3/include/bits/locale_facets.tcc:783: undefined reference to `__aeabi_uldivmod'
/home/xvilka/build/toolchain-android/targets/arm-android-linux-uclibcgnueabi/build/build-cc/arm-android-linux-uclibcgnueabi/libstdc++-v3/include/bits/locale_facets.tcc:784: undefined reference to `__aeabi_uldivmod'
/home/xvilka/build/cross/sys-root/usr/lib/libstdc++.a(locale-inst.o): In function `std::__convert_from_v(int* const&, char*, int, char const*, ...)':
/home/xvilka/build/toolchain-android/targets/arm-android-linux-uclibcgnueabi/build/build-cc/arm-android-linux-uclibcgnueabi/libstdc++-v3/include/arm-android-linux-uclibcgnueabi/bits/c++locale.h:76: undefined reference to `vsprintf'
/home/xvilka/build/cross/sys-root/usr/lib/libstdc++.a(locale-inst.o): In function `std::istreambuf_iterator<char, std::char_traits<char> > std::num_get<char, std::istreambuf_iterator<char, std::char_traits<char> > >::_M_extract_int<unsigned long long>(std::istreambuf_iterator<char, std::char_traits<char> >, std::istreambuf_iterator<char, std::char_traits<char> >, std::ios_base&, std::_Ios_Iostate&, unsigned long long&) const':
/home/xvilka/build/toolchain-android/targets/arm-android-linux-uclibcgnueabi/build/build-cc/arm-android-linux-uclibcgnueabi/libstdc++-v3/include/bits/locale_facets.tcc:455: undefined reference to `__aeabi_uldivmod'
/home/xvilka/build/cross/sys-root/usr/lib/libstdc++.a(locale-inst.o): In function `std::istreambuf_iterator<char, std::char_traits<char> > std::num_get<char, std::istreambuf_iterator<char, std::char_traits<char> > >::_M_extract_int<long long>(std::istreambuf_iterator<char, std::char_traits<char> >, std::istreambuf_iterator<char, std::char_traits<char> >, std::ios_base&, std::_Ios_Iostate&, long long&) const':
/home/xvilka/build/toolchain-android/targets/arm-android-linux-uclibcgnueabi/build/build-cc/arm-android-linux-uclibcgnueabi/libstdc++-v3/include/bits/locale_facets.tcc:455: undefined reference to `__aeabi_uldivmod'
/home/xvilka/build/cross/sys-root/usr/lib/libstdc++.a(basic_file.o): In function `std::__basic_file<char>::showmanyc()':
/home/xvilka/build/toolchain-android/targets/arm-android-linux-uclibcgnueabi/build/build-cc/arm-android-linux-uclibcgnueabi/libstdc++-v3/src/basic_file.cc:362: undefined reference to `fstat64'
/home/xvilka/build/cross/sys-root/usr/lib/libstdc++.a(basic_file.o): In function `xwritev':
/home/xvilka/build/toolchain-android/targets/arm-android-linux-uclibcgnueabi/build/build-cc/arm-android-linux-uclibcgnueabi/libstdc++-v3/src/basic_file.cc:155: undefined reference to `writev'
/home/xvilka/build/cross/sys-root/usr/lib/libstdc++.a(c++locale.o): In function `void std::__convert_to_v<long double>(char const*, long double&, std::_Ios_Iostate&, int* const&)':
/home/xvilka/build/toolchain-android/targets/arm-android-linux-uclibcgnueabi/build/build-cc/arm-android-linux-uclibcgnueabi/libstdc++-v3/src/c++locale.cc:175: undefined reference to `strtold'
/home/xvilka/build/cross/sys-root/usr/lib/libstdc++.a(c++locale.o): In function `void std::__convert_to_v<float>(char const*, float&, std::_Ios_Iostate&, int* const&)':
/home/xvilka/build/toolchain-android/targets/arm-android-linux-uclibcgnueabi/build/build-cc/arm-android-linux-uclibcgnueabi/libstdc++-v3/src/c++locale.cc:66: undefined reference to `strtof'
/home/xvilka/build/cross/sys-root/usr/lib/libstdc++.a(eh_globals.o): In function `__static_initialization_and_destruction_0':
/home/xvilka/build/toolchain-android/targets/src/gcc-4.4.3/libstdc++-v3/libsupc++/eh_globals.cc:110: undefined reference to `__dso_handle'
collect2: ld returned 1 exit status
make[1]: *** [nmap] Error 1
make: *** [all] Error 2
А вот какой строчкой он собственно линкует:
arm-android-linux-uclibcgnueabi-g++ -Llibpcap -Wl,-E -nodefaultlibs -nostdlib -fPIC -static -s -L/home/xvilka/build/cross/sys-root/usr/lib -zmuldefs -Lnbase -Lnsock/src/ -o nmap main.o nmap.o targets.o tcpip.o nmap_error.o utils.o idle_scan.o osscan.o osscan2.o output.o payload.o scan_engine.o timing.o charpool.o services.o protocols.o nmap_rpc.o portlist.o NmapOps.o TargetGroup.o Target.o FingerPrintResults.o service_scan.o NmapOutputTable.o MACLookup.o nmap_tty.o nmap_dns.o traceroute.o portreasons.o nse_main.o nse_nsock.o nse_fs.o nse_nmaplib.o nse_debug.o nse_pcrelib.o nse_binlib.o nse_bit.o -lnbase -lnsock libpcre/libpcre.a -lpcap libdnet-stripped/src/.libs/libdnet.a liblua/liblua.a -ldl -lm -lc -lgcc -liberty -lgcc_eh -lstdc++
Уже почти вчера весь вечер бился над исходниками nmap и ничего не вижу - нужен взгляд со стороны. Спасибо!