可执行文件是在Debian上编译的,拿到Ubuntu上不能运行,报如下错误
bash: ./dummysm: No such file or directory
ldd
查看依赖正常
使用readelf查看信息
readelf -a dummysm
ELF Header:
Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
Class: ELF64
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: DYN (Shared object file)
Machine: Advanced Micro Devices X86-64
Version: 0x1
Entry point address: 0x1130
Start of program headers: 64 (bytes into file)
Start of section headers: 108176 (bytes into file)
Flags: 0x0
Size of this header: 64 (bytes)
Size of program headers: 56 (bytes)
Number of program headers: 11
Size of section headers: 64 (bytes)
Number of section headers: 36
Section header string table index: 35
Section Headers:
[Nr] Name Type Address Offset
Size EntSize Flags Link Info Align
[ 0] NULL 0000000000000000 00000000
0000000000000000 0000000000000000 0 0 0
[ 1] .interp PROGBITS 00000000000002a8 000002a8
000000000000001a 0000000000000000 A 0 0 1
[ 2] .note.gnu.build-i NOTE 00000000000002c4 000002c4
0000000000000024 0000000000000000 A 0 0 4
[ 3] .note.ABI-tag NOTE 00000000000002e8 000002e8
0000000000000020 0000000000000000 A 0 0 4
[ 4] .gnu.hash GNU_HASH 0000000000000308 00000308
0000000000000028 0000000000000000 A 5 0 8
[ 5] .dynsym DYNSYM 0000000000000330 00000330
0000000000000150 0000000000000018 A 6 1 8
[ 6] .dynstr STRTAB 0000000000000480 00000480
00000000000001e1 0000000000000000 A 0 0 1
[ 7] .gnu.version VERSYM 0000000000000662 00000662
000000000000001c 0000000000000002 A 5 0 2
[ 8] .gnu.version_r VERNEED 0000000000000680 00000680
0000000000000040 0000000000000000 A 6 2 8
[ 9] .rela.dyn RELA 00000000000006c0 000006c0
0000000000000108 0000000000000018 A 5 0 8
[10] .rela.plt RELA 00000000000007c8 000007c8
0000000000000078 0000000000000018 AI 5 22 8
[11] .init PROGBITS 0000000000001000 00001000
0000000000000017 0000000000000000 AX 0 0 4
[12] .plt PROGBITS 0000000000001020 00001020
0000000000000060 0000000000000010 AX 0 0 16
[13] .plt.got PROGBITS 0000000000001080 00001080
0000000000000008 0000000000000008 AX 0 0 8
[14] .text PROGBITS 0000000000001090 00001090
0000000000000231 0000000000000000 AX 0 0 16
[15] .fini PROGBITS 00000000000012c4 000012c4
0000000000000009 0000000000000000 AX 0 0 4
[16] .rodata PROGBITS 0000000000002000 00002000
00000000000000bd 0000000000000000 A 0 0 8
[17] .eh_frame_hdr PROGBITS 00000000000020c0 000020c0
000000000000004c 0000000000000000 A 0 0 4
[18] .eh_frame PROGBITS 0000000000002110 00002110
0000000000000128 0000000000000000 A 0 0 8
[19] .init_array INIT_ARRAY 0000000000003d50 00002d50
0000000000000010 0000000000000008 WA 0 0 8
[20] .fini_array FINI_ARRAY 0000000000003d60 00002d60
0000000000000008 0000000000000008 WA 0 0 8
[21] .dynamic DYNAMIC 0000000000003d68 00002d68
0000000000000220 0000000000000010 WA 6 0 8
[22] .got PROGBITS 0000000000003f88 00002f88
0000000000000078 0000000000000008 WA 0 0 8
[23] .data PROGBITS 0000000000004000 00003000
0000000000000010 0000000000000000 WA 0 0 8
[24] .bss NOBITS 0000000000004010 00003010
0000000000000028 0000000000000000 WA 0 0 16
[25] .comment PROGBITS 0000000000000000 00003010
0000000000000011 0000000000000001 MS 0 0 1
[26] .debug_aranges PROGBITS 0000000000000000 00003030
0000000000000150 0000000000000000 0 0 16
[27] .debug_info PROGBITS 0000000000000000 00003180
0000000000008d32 0000000000000000 0 0 1
[28] .debug_abbrev PROGBITS 0000000000000000 0000beb2
0000000000000f7a 0000000000000000 0 0 1
[29] .debug_line PROGBITS 0000000000000000 0000ce2c
0000000000001346 0000000000000000 0 0 1
[30] .debug_str PROGBITS 0000000000000000 0000e172
000000000000b307 0000000000000001 MS 0 0 1
[31] .debug_loc PROGBITS 0000000000000000 00019479
0000000000000418 0000000000000000 0 0 1
[32] .debug_ranges PROGBITS 0000000000000000 000198a0
0000000000000160 0000000000000000 0 0 16
[33] .symtab SYMTAB 0000000000000000 00019a00
00000000000007c8 0000000000000018 34 56 8
[34] .strtab STRTAB 0000000000000000 0001a1c8
0000000000000370 0000000000000000 0 0 1
[35] .shstrtab STRTAB 0000000000000000 0001a538
0000000000000157 0000000000000000 0 0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
L (link order), O (extra OS processing required), G (group), T (TLS),
C (compressed), x (unknown), o (OS specific), E (exclude),
l (large), p (processor specific)
There are no section groups in this file.
Program Headers:
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flags Align
PHDR 0x0000000000000040 0x0000000000000040 0x0000000000000040
0x0000000000000268 0x0000000000000268 R 0x8
INTERP 0x00000000000002a8 0x00000000000002a8 0x00000000000002a8
0x000000000000001a 0x000000000000001a R 0x1
[Requesting program interpreter: /lib/ld-linux-x86-64.so.2]
LOAD 0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000840 0x0000000000000840 R 0x1000
LOAD 0x0000000000001000 0x0000000000001000 0x0000000000001000
0x00000000000002cd 0x00000000000002cd R E 0x1000
LOAD 0x0000000000002000 0x0000000000002000 0x0000000000002000
0x0000000000000238 0x0000000000000238 R 0x1000
LOAD 0x0000000000002d50 0x0000000000003d50 0x0000000000003d50
0x00000000000002c0 0x00000000000002e8 RW 0x1000
DYNAMIC 0x0000000000002d68 0x0000000000003d68 0x0000000000003d68
0x0000000000000220 0x0000000000000220 RW 0x8
NOTE 0x00000000000002c4 0x00000000000002c4 0x00000000000002c4
0x0000000000000044 0x0000000000000044 R 0x4
GNU_EH_FRAME 0x00000000000020c0 0x00000000000020c0 0x00000000000020c0
0x000000000000004c 0x000000000000004c R 0x4
GNU_STACK 0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 RW 0x10
GNU_RELRO 0x0000000000002d50 0x0000000000003d50 0x0000000000003d50
0x00000000000002b0 0x00000000000002b0 R 0x1
其中有一条信息如下,Linux装载器路径如下
[Requesting program interpreter: /lib/ld-linux-x86-64.so.2]
关于装载器的信息
但去/lib
下查看没有这个文件
搜索一下
sudo find / -name ld-linux-x86-64* #ls -l ld-linux-x86-64*
查找结果有以下几条
/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2
/usr/lib/ld-linux-x86-64.so.2
/usr/lib64/ld-linux-x86-64.so.2
切换到/lib目录下,创建软链接
sudo ln -s /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 ld-linux-x86-64.so.2
问题解决。
实际上 ldd
命令已经将链接器的路径打印出来
/lib/ld-linux-x86-64.so.2 => /lib64/ld-linux-x86-64.so.2 (0x00007f9db55eb000)
librt.so.1 => /usr/lib/x86_64-linux-gnu/librt.so.1 (0x00007f9db4cd6000)
libm.so.6 => /usr/lib/x86_64-linux-gnu/libm.so.6 (0x00007f9db4b87000)
但在执行时却出了问题。