0

net-tools-1.60のスタティックバイナリをビルドしようとしているので、どのシステムでも実行できます。 SourceForgeからnet-toolsのソースをダウンロードし、3つのパッチを適用しました。それから私はmake SHARED=0 CC='gcc -static'で正常にコンパイルします。コンパイルされたバイナリは「静的にリンクされている」と表示されますが、一部のものは「セグメンテーションフォルト」になります。主にarpおよびルートは機能しません。私もLDFLAGS="--static" make -j 4を試しましたが、結果として得られるバイナリは "動的にリンクされています"と表示されます。静的にリンクされたバイナリ - セグメンテーションフォールト

これは、4.4.0-64ジェネリックカーネルのUbuntu 16.04にあります。任意のアイデアは、どのようにこれを動作させるには?

警告

requires at runtime the shared libraries from the glibc version used for linking 
/home/user/Desktop/net-tools-1.60/lib/inet.c:404: warning: Using 'setprotoent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking 
/home/user/Desktop/net-tools-1.60/lib/inet.c:414: warning: Using 'endprotoent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking 
/home/user/Desktop/net-tools-1.60/lib/inet.c:386: warning: Using 'getservent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking 
/home/user/Desktop/net-tools-1.60/lib/inet.c:385: warning: Using 'setservent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking 
/home/user/Desktop/net-tools-1.60/lib/inet.c:403: warning: Using 'endservent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking 

クラッシュ

[email protected]:~/Desktop/net-tools-1.60$ file arp 
arp: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, for GNU/Linux 2.6.32, BuildID[sha1]=fc19dbe5121b2a3eb7aee3e6e0fc8de7490d6263, not stripped 
[email protected]:~/Desktop/net-tools-1.60$ ./arp 
Segmentation fault (core dumped) 

GDB

(gdb) run 
Starting program: /home/user/Desktop/net-tools-1.60/arp 
[Thread debugging using libthread_db enabled] 
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". 

Program received signal SIGSEGV, Segmentation fault. 
0x0000000000000000 in ??() 
(gdb) where 
#0 0x0000000000000000 in ??() 
#1 0x00007ffff6c83fa9 in __pthread_initialize_minimal_internal() at nptl-init.c:471 
#2 0x00007ffff6c83589 in _init() at ../sysdeps/x86_64/crti.S:72 
#3 0x00007ffff70a4670 in ??() from /lib/x86_64-linux-gnu/libnss_myhostname.so.2 
#4 0x00000000004acd5a in call_init.part() 
#5 0x00000000004acf15 in _dl_init() 
#6 0x00000000004999a5 in dl_open_worker() 
#7 0x0000000000497164 in _dl_catch_error() 
#8 0x0000000000499309 in _dl_open() 
#9 0x00000000004563d2 in do_dlopen() 
#10 0x0000000000497164 in _dl_catch_error() 
#11 0x00000000004565be in __libc_dlopen_mode() 
#12 0x0000000000451e6d in __nss_next2() 
#13 0x000000000044dbac in gethostbyaddr_r() 
#14 0x000000000044d9be in gethostbyaddr() 
#15 0x00000000004031f2 in INET_rresolve ([email protected]=0x6e68e0 <buff> "", sin=0x7fffffffd440, 
    numeric=<optimized out>, [email protected]=4294967040, len=128) at inet.c:200 
#16 0x0000000000403354 in INET_sprint (sap=<optimized out>, numeric=<optimized out>) at inet.c:246 
#17 0x0000000000401877 in arp_show (name=0x0) at arp.c:581 
#18 0x0000000000400b53 in main (argc=1, argv=0x7fffffffe008) at arp.c:768 
(gdb) 

更新 は、だから、僕は年上のUbuntu 11.10 32bit版のツールを構築しました。結果のバイナリは私のUbuntu 16.04 64bit上で正常に動作しています。私は16.04にバグがあるかもしれないと思う。

答えて

1

コンパイル済みのバイナリは以外のシステムに起こっているのクラッシュを想定した(これは期待結果である「静的にリンクされた」として表示され、いくつかの仕事が、一部は「セグメンテーション違反」を取得

彼らが建てられた場所)。人気の信念に反して

は、は完全にLinux上で -staticライブラリが動的にリンクされたものより少ない移植されています。

あなたはこのように見えるリンク時の警告を受けているはず

warning: Using 'getgrnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking 

Explanation

更新:

クラッシュは、プログラムが構築された同じシステム上で期待されていません。このクラッシュはGLIBC bugのように見えます。

最終結果は同じですが、静的にリンクしません。良いことは出てこない。

+0

はい、いくつかの警告があります。それは修正できますか?考えられるのは、実行されるシステムに触れることなく、外部ディスクからツールを実行することです。私が構築しているのと同じシステムでクラッシュが起きています。別のコンピュータで試したことがありません。 – user1781482

+1

@ user1781482 *同じ*システムでのクラッシュは予想されません。投稿を編集して、GDBからクラッシュスタックトレースを表示します。 –

+0

クラッシュスタックトレースの表示方法がわかりません。私はプロではない。それ、どうやったら出来るの?ありがとう。 – user1781482

関連する問題