当前位置: 技术问答>linux和unix
不同Linux系统下同一个可执行文件执行问题
来源: 互联网 发布时间:2016-02-06
本文导语: ==>问题 把A Linux系统上的一个执行文件mytest拷贝B Linux系统上,chmod a+x mytest后执行出现如下问题: bash: ./mytest: 没有那个文件或目录 ==> 用file和ojdump查看mytest如下: >file mytest mytest: ELF 32-bit LSB executable, Intel 803...
==>问题
把A Linux系统上的一个执行文件mytest拷贝B Linux系统上,chmod a+x mytest后执行出现如下问题:
bash: ./mytest: 没有那个文件或目录
==>
用file和ojdump查看mytest如下:
>file mytest
mytest: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), stripped
>objdump -h mytest
mytest: 文件格式 elf32-i386
节:
Idx Name Size VMA LMA File off Algn
0 .interp 00000013 080480f4 080480f4 000000f4 2**0
CONTENTS, ALLOC, LOAD, READONLY, DATA
1 .hash 00000350 08048108 08048108 00000108 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
2 .dynsym 00000710 08048458 08048458 00000458 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
3 .dynstr 00000445 08048b68 08048b68 00000b68 2**0
CONTENTS, ALLOC, LOAD, READONLY, DATA
4 .rel.plt 00000308 08048fb0 08048fb0 00000fb0 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
5 .init 00000004 080492b8 080492b8 000012b8 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
6 .plt 00000620 080492bc 080492bc 000012bc 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
7 .text 00049780 080498dc 080498dc 000018dc 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
8 .fini 00000004 0809305c 0809305c 0004b05c 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
9 .data 00092260 08094060 08094060 0004b060 2**2
CONTENTS, ALLOC, LOAD, DATA
10 .got 00000190 081262c0 081262c0 000dd2c0 2**2
CONTENTS, ALLOC, LOAD, DATA
11 .dynamic 00000080 08126450 08126450 000dd450 2**2
CONTENTS, ALLOC, LOAD, DATA
12 .bss 000029f4 081264d0 081264d0 000dd4d0 2**2
ALLOC
13 .note 0000001c 00000000 00000000 000dd4d0 2**0
CONTENTS, READONLY
14 .comment 00005021 00000000 00000000 000dd570 2**2
CONTENTS, READONLY
>objdump -f mytest
mytest: 文件格式 elf32-i386
体系结构:i386,标志 0x00000112:
EXEC_P, HAS_SYMS, D_PAGED
起始地址 0x080498dc
==>
为了一步做比较,我用file和objdump查看B系统上的一个可执行文件new_mytest如下:
>file new_mytest
new_mytest: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.4, dynamically linked (uses shared libs), for GNU/Linux 2.6.4, not stripped
>objdump -h new_mytest
new_mytest: 文件格式 elf32-i386
节:
Idx Name Size VMA LMA File off Algn
0 .interp 00000013 08048154 08048154 00000154 2**0
CONTENTS, ALLOC, LOAD, READONLY, DATA
1 .note.ABI-tag 00000020 08048168 08048168 00000168 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
2 .note.SuSE 00000018 08048188 08048188 00000188 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
3 .hash 00000474 080481a0 080481a0 000001a0 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
4 .dynsym 00000980 08048614 08048614 00000614 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
5 .dynstr 00000600 08048f94 08048f94 00000f94 2**0
CONTENTS, ALLOC, LOAD, READONLY, DATA
6 .gnu.version 00000130 08049594 08049594 00001594 2**1
CONTENTS, ALLOC, LOAD, READONLY, DATA
7 .gnu.version_r 000000b0 080496c4 080496c4 000016c4 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
8 .rel.dyn 00000048 08049774 08049774 00001774 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
9 .rel.plt 00000440 080497bc 080497bc 000017bc 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
10 .init 00000017 08049bfc 08049bfc 00001bfc 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
11 .plt 00000890 08049c14 08049c14 00001c14 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
12 .text 000cb8ec 0804a4b0 0804a4b0 000024b0 2**4
CONTENTS, ALLOC, LOAD, READONLY, CODE
13 .fini 0000001c 08115d9c 08115d9c 000cdd9c 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
14 .rodata 0000816b 08115dc0 08115dc0 000cddc0 2**5
CONTENTS, ALLOC, LOAD, READONLY, DATA
15 .eh_frame_hdr 000031ac 0811df2c 0811df2c 000d5f2c 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
16 .eh_frame 0000cb84 081210d8 081210d8 000d90d8 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
17 .gcc_except_table 00007640 0812dc5c 0812dc5c 000e5c5c 2**0
CONTENTS, ALLOC, LOAD, READONLY, DATA
18 .ctors 00000020 08136000 08136000 000ee000 2**2
CONTENTS, ALLOC, LOAD, DATA
19 .dtors 00000008 08136020 08136020 000ee020 2**2
CONTENTS, ALLOC, LOAD, DATA
20 .jcr 00000004 08136028 08136028 000ee028 2**2
CONTENTS, ALLOC, LOAD, DATA
21 .dynamic 00000138 0813602c 0813602c 000ee02c 2**2
CONTENTS, ALLOC, LOAD, DATA
22 .got 00000004 08136164 08136164 000ee164 2**2
CONTENTS, ALLOC, LOAD, DATA
23 .got.plt 0000022c 08136168 08136168 000ee168 2**2
CONTENTS, ALLOC, LOAD, DATA
24 .data 000060d0 081363a0 081363a0 000ee3a0 2**5
CONTENTS, ALLOC, LOAD, DATA
25 .bss 00005a00 0813c480 0813c480 000f4470 2**5
ALLOC
26 .comment 000010d5 00000000 00000000 000f4470 2**0
CONTENTS, READONLY
27 .debug_aranges 00000058 00000000 00000000 000f5548 2**3
CONTENTS, READONLY, DEBUGGING
28 .debug_pubnames 00000025 00000000 00000000 000f55a0 2**0
CONTENTS, READONLY, DEBUGGING
29 .debug_info 00000191 00000000 00000000 000f55c5 2**0
CONTENTS, READONLY, DEBUGGING
30 .debug_abbrev 00000062 00000000 00000000 000f5756 2**0
CONTENTS, READONLY, DEBUGGING
31 .debug_line 00000137 00000000 00000000 000f57b8 2**0
CONTENTS, READONLY, DEBUGGING
32 .debug_str 000000a5 00000000 00000000 000f58ef 2**0
CONTENTS, READONLY, DEBUGGING
>objdump -f new_mytest
new_mytest: 文件格式 elf32-i386
体系结构:i386,标志 0x00000112:
EXEC_P, HAS_SYMS, D_PAGED
起始地址 0x0804a4b0
比较两个可执行文件的结果,看不出为什么会出现这个问题。各位CSDN的大虾们帮忙看看是什么问题导致mytest执行文件不能执行?
把A Linux系统上的一个执行文件mytest拷贝B Linux系统上,chmod a+x mytest后执行出现如下问题:
bash: ./mytest: 没有那个文件或目录
==>
用file和ojdump查看mytest如下:
>file mytest
mytest: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), stripped
>objdump -h mytest
mytest: 文件格式 elf32-i386
节:
Idx Name Size VMA LMA File off Algn
0 .interp 00000013 080480f4 080480f4 000000f4 2**0
CONTENTS, ALLOC, LOAD, READONLY, DATA
1 .hash 00000350 08048108 08048108 00000108 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
2 .dynsym 00000710 08048458 08048458 00000458 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
3 .dynstr 00000445 08048b68 08048b68 00000b68 2**0
CONTENTS, ALLOC, LOAD, READONLY, DATA
4 .rel.plt 00000308 08048fb0 08048fb0 00000fb0 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
5 .init 00000004 080492b8 080492b8 000012b8 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
6 .plt 00000620 080492bc 080492bc 000012bc 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
7 .text 00049780 080498dc 080498dc 000018dc 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
8 .fini 00000004 0809305c 0809305c 0004b05c 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
9 .data 00092260 08094060 08094060 0004b060 2**2
CONTENTS, ALLOC, LOAD, DATA
10 .got 00000190 081262c0 081262c0 000dd2c0 2**2
CONTENTS, ALLOC, LOAD, DATA
11 .dynamic 00000080 08126450 08126450 000dd450 2**2
CONTENTS, ALLOC, LOAD, DATA
12 .bss 000029f4 081264d0 081264d0 000dd4d0 2**2
ALLOC
13 .note 0000001c 00000000 00000000 000dd4d0 2**0
CONTENTS, READONLY
14 .comment 00005021 00000000 00000000 000dd570 2**2
CONTENTS, READONLY
>objdump -f mytest
mytest: 文件格式 elf32-i386
体系结构:i386,标志 0x00000112:
EXEC_P, HAS_SYMS, D_PAGED
起始地址 0x080498dc
==>
为了一步做比较,我用file和objdump查看B系统上的一个可执行文件new_mytest如下:
>file new_mytest
new_mytest: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.4, dynamically linked (uses shared libs), for GNU/Linux 2.6.4, not stripped
>objdump -h new_mytest
new_mytest: 文件格式 elf32-i386
节:
Idx Name Size VMA LMA File off Algn
0 .interp 00000013 08048154 08048154 00000154 2**0
CONTENTS, ALLOC, LOAD, READONLY, DATA
1 .note.ABI-tag 00000020 08048168 08048168 00000168 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
2 .note.SuSE 00000018 08048188 08048188 00000188 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
3 .hash 00000474 080481a0 080481a0 000001a0 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
4 .dynsym 00000980 08048614 08048614 00000614 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
5 .dynstr 00000600 08048f94 08048f94 00000f94 2**0
CONTENTS, ALLOC, LOAD, READONLY, DATA
6 .gnu.version 00000130 08049594 08049594 00001594 2**1
CONTENTS, ALLOC, LOAD, READONLY, DATA
7 .gnu.version_r 000000b0 080496c4 080496c4 000016c4 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
8 .rel.dyn 00000048 08049774 08049774 00001774 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
9 .rel.plt 00000440 080497bc 080497bc 000017bc 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
10 .init 00000017 08049bfc 08049bfc 00001bfc 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
11 .plt 00000890 08049c14 08049c14 00001c14 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
12 .text 000cb8ec 0804a4b0 0804a4b0 000024b0 2**4
CONTENTS, ALLOC, LOAD, READONLY, CODE
13 .fini 0000001c 08115d9c 08115d9c 000cdd9c 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
14 .rodata 0000816b 08115dc0 08115dc0 000cddc0 2**5
CONTENTS, ALLOC, LOAD, READONLY, DATA
15 .eh_frame_hdr 000031ac 0811df2c 0811df2c 000d5f2c 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
16 .eh_frame 0000cb84 081210d8 081210d8 000d90d8 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
17 .gcc_except_table 00007640 0812dc5c 0812dc5c 000e5c5c 2**0
CONTENTS, ALLOC, LOAD, READONLY, DATA
18 .ctors 00000020 08136000 08136000 000ee000 2**2
CONTENTS, ALLOC, LOAD, DATA
19 .dtors 00000008 08136020 08136020 000ee020 2**2
CONTENTS, ALLOC, LOAD, DATA
20 .jcr 00000004 08136028 08136028 000ee028 2**2
CONTENTS, ALLOC, LOAD, DATA
21 .dynamic 00000138 0813602c 0813602c 000ee02c 2**2
CONTENTS, ALLOC, LOAD, DATA
22 .got 00000004 08136164 08136164 000ee164 2**2
CONTENTS, ALLOC, LOAD, DATA
23 .got.plt 0000022c 08136168 08136168 000ee168 2**2
CONTENTS, ALLOC, LOAD, DATA
24 .data 000060d0 081363a0 081363a0 000ee3a0 2**5
CONTENTS, ALLOC, LOAD, DATA
25 .bss 00005a00 0813c480 0813c480 000f4470 2**5
ALLOC
26 .comment 000010d5 00000000 00000000 000f4470 2**0
CONTENTS, READONLY
27 .debug_aranges 00000058 00000000 00000000 000f5548 2**3
CONTENTS, READONLY, DEBUGGING
28 .debug_pubnames 00000025 00000000 00000000 000f55a0 2**0
CONTENTS, READONLY, DEBUGGING
29 .debug_info 00000191 00000000 00000000 000f55c5 2**0
CONTENTS, READONLY, DEBUGGING
30 .debug_abbrev 00000062 00000000 00000000 000f5756 2**0
CONTENTS, READONLY, DEBUGGING
31 .debug_line 00000137 00000000 00000000 000f57b8 2**0
CONTENTS, READONLY, DEBUGGING
32 .debug_str 000000a5 00000000 00000000 000f58ef 2**0
CONTENTS, READONLY, DEBUGGING
>objdump -f new_mytest
new_mytest: 文件格式 elf32-i386
体系结构:i386,标志 0x00000112:
EXEC_P, HAS_SYMS, D_PAGED
起始地址 0x0804a4b0
比较两个可执行文件的结果,看不出为什么会出现这个问题。各位CSDN的大虾们帮忙看看是什么问题导致mytest执行文件不能执行?
|
ldd: /lib/ld-linux.so.2 exited with unknown exit code (139)
这样就是缺少共享库了.
正常的
[root@shwhg test]# ldd a.out
libc.so.6 => /lib/tls/libc.so.6 (0x4eb26000)
/lib/ld-linux.so.2 (0x4eb0d000)
静态编译的
[root@shwhg test]# ldd a.out
not a dynamic executable
你在原来的机器上改成静态编译看看.
这样就是缺少共享库了.
正常的
[root@shwhg test]# ldd a.out
libc.so.6 => /lib/tls/libc.so.6 (0x4eb26000)
/lib/ld-linux.so.2 (0x4eb0d000)
静态编译的
[root@shwhg test]# ldd a.out
not a dynamic executable
你在原来的机器上改成静态编译看看.
|
导致不能执行的原因多半是动态库的问题
用ldd看看
用ldd看看
|
mytest: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), stripped
new_mytest: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.4, dynamically linked (uses shared libs), for GNU/Linux 2.6.4, not stripped
这能说明什么? 为什么一个有kernel版本而另一个没有?
new_mytest: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.4, dynamically linked (uses shared libs), for GNU/Linux 2.6.4, not stripped
这能说明什么? 为什么一个有kernel版本而另一个没有?
|
加个.sh后缀,用sh mytest.sh试试
|
也可能是路径的问题,你用绝对路径执行一下.
|
关注