पर ले जाता है मैं एक पुराने पुराने libc संस्करण के साथ एक एम्बेडेड सिस्टम के लिए किसी लाइब्रेरी निर्भरता (यहां तक कि libc) के बिना `curl का एक स्टैंडअलोन संस्करण बनाना चाहता हूं।स्टैंडअलोन कर्ल को segfault
वर्तमान कर्ल GitHub से, मैं इस आदेश के साथ संकलन कॉन्फ़िगर करें:
./configure --disable-shared --enable-static-nss --prefix=/tmp/curl LDFLAGS='-static -static-libgcc -Wl,-Bstatic -lc' LIBS='-lc -lssl -lcrypto -lz -ldl'
[...]
curl version: 7.50.2-DEV
Host setup: x86_64-pc-linux-gnu
Install prefix: /tmp/curl
Compiler: gcc
SSL support: enabled (OpenSSL)
SSH support: no (--with-libssh2)
zlib support: enabled
GSS-API support: no (--with-gssapi)
TLS-SRP support: enabled
resolver: default (--enable-ares/--enable-threaded-resolver)
IPv6 support: enabled
Unix sockets support: enabled
IDN support: no (--with-{libidn,winidn})
Build libcurl: Shared=no, Static=yes
Built-in manual: enabled
--libcurl option: enabled (--disable-libcurl-option)
Verbose errors: enabled (--disable-verbose)
SSPI support: no (--enable-sspi)
ca cert bundle: /etc/ssl/certs/ca-certificates.crt
ca cert path: no
ca fallback: no
LDAP support: no (--enable-ldap/--with-ldap-lib/--with-lber-lib)
LDAPS support: no (--enable-ldaps)
RTSP support: enabled
RTMP support: no (--with-librtmp)
metalink support: no (--with-libmetalink)
PSL support: no (libpsl not found)
HTTP2 support: disabled (--with-nghttp2)
Protocols: DICT FILE FTP FTPS GOPHER HTTP HTTPS IMAP IMAPS POP3 POP3S RTSP SMB SMBS SMTP SMTPS TELNET TFTP
फिर make
चरण के दौरान, मैं निम्नलिखित चेतावनी मिलती है:
curl-tool_homedir.o: In function `homedir':
tool_homedir.c:(.text+0x60): warning: Using 'getpwuid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
../lib/.libs/libcurl.a(libcurl_la-netrc.o): In function `Curl_parsenetrc':
netrc.c:(.text+0x3c3): warning: Using 'getpwuid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
../lib/.libs/libcurl.a(libcurl_la-curl_addrinfo.o): In function `Curl_getaddrinfo_ex':
curl_addrinfo.c:(.text+0x73): warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libcrypto.a(fips.o): In function `verify_checksums':
(.text+0x4e6): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
मैं जारी रखने और make install
प्रदर्शन कर सकते हैं अंतिम बाइनरी पाने के लिए।
द्विआधारी कोई निर्भरता है:
$ ldd /tmp/curl/bin/curl
not a dynamic executable
$ nm /tmp/curl/bin/curl | grep " U "
$
लेकिन द्विआधारी बिल्कुल काम नहीं कर रहा:
$ /tmp/curl/bin/curl -version
Segmentation fault (core dumped)
आप मूल कारण मुद्दे का कोई विचार है?
संपादित करें 1: GDB आउटपुट:
(gdb) run
Starting program: /tmp/curl/bin/curl
Program received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ??()
संपादित करें 2:
$ nm /tmp/curl/bin/curl | grep getpwuid
0000000000655770 T getpwuid
00000000006558f0 T __getpwuid_r
00000000006558f0 W getpwuid_r
00000000006558f0 T __new_getpwuid_r
0000000000663cf0 T __nscd_getpwuid_r
हो सकता है कि इस मुद्दे को W
से आता है:
डब्ल्यू प्रतीक एक है कमजोर प्रतीक था टी को विशेष रूप से को कमजोर ऑब्जेक्ट प्रतीक के रूप में टैग नहीं किया गया है। जब एक कमजोर परिभाषित प्रतीक सामान्य परिभाषित प्रतीक से जुड़ा होता है, तो सामान्य परिभाषित प्रतीक त्रुटि के साथ उपयोग किया जाता है। जब एक कमजोर अपरिभाषित प्रतीक जुड़ा होता है और प्रतीक परिभाषित नहीं होता है, कमजोर प्रतीक का मान शून्य के बिना शून्य हो जाता है।
संपादित करें 3: अगर मैं एसएसएल जोड़ने मैं getpwuid
के लिए एक ही चेतावनी मिल गया लेकिन द्विआधारी काम कर रहा है निकालें:
./configure --disable-shared --enable-static-nss --prefix=/tmp/curl LDFLAGS='-static -static-libgcc -Wl,-Bstatic,-lc'
ldd /tmp/curl/bin/curl
not a dynamic executable
/tmp/curl/bin/curl --version
curl 7.50.2-DEV (x86_64-pc-linux-gnu) libcurl/7.50.2-DEV zlib/1.2.8
Protocols: dict file ftp gopher http imap pop3 rtsp smtp telnet tftp
Features: IPv6 Largefile libz UnixSockets
nm /tmp/curl/bin/curl | grep getpwuid
00000000004f52d0 T getpwuid
00000000004f5450 T __getpwuid_r
00000000004f5450 W getpwuid_r
00000000004f5450 T __new_getpwuid_r
0000000000502cd0 T __nscd_getpwuid_r
लेकिन मैं HTTPS समर्थन के लिए एसएसएल जोड़ने के लिए इसलिए इस मुद्दे को जरूरत अभी भी खुला है
संपादित करें 4: मुद्दा सीधे nss
से जुड़ा हुआ है। अजीब बात यह है कि ./configure --prefix=/tmp/curl --disable-shared --enable-static-nss LDFLAGS='-static -static-libgcc -Wl,-Bstatic' LIBS='-ls'
एक कामकाजी स्टैंडअलोन निष्पादन योग्य बनाता है लेकिन एसएसएल के बिना। nss
समस्या एसएसएल लिंकिंग के कारण है।
इसे डीबग करने का प्रयास करें। आपको पता चल जाएगा कि क्या हो रहा है। –
खैर मुझे एक लिंक मुद्दा पर संदेह है लेकिन मैं डिबगिंग में गहराई से कैसे जा सकता हूं? – Julio
बस 'gdb/tmp/curl/bin/curl'। लेकिन आप सही हो सकते हैं। क्या आपके सिस्टम पर 1 से अधिक कंपाइलर हैं? –