1. 程式人生 > >linux 執行程式時,提示not found問題分析

linux 執行程式時,提示not found問題分析

sh: ./test: not found

通常可以通過readelf檢視該程序檔案所以依賴的執行環境,檢查相關路徑是否存在對應的檔案,

注意

1. interpreter是絕對路徑,設定LD_LIBRARY_PATH指向對應目錄對於部分系統則無效

2. Shared library可以是相對路徑,設定LD_LIBRARY_PATH即可

 

$ readelf -l test

Elf file type is DYN (Shared object file)
Entry point 0x786a4
There are 10 program headers, starting at offset 52

Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
PHDR 0x000034 0x00000034 0x00000034 0x00140 0x00140 R 0x4
INTERP 0x000174 0x00000174 0x00000174 0x00013 0x00013 R 0x1
[Requesting program interpreter: /lib/ld-linux.so.3]
LOAD 0x000000 0x00000000 0x00000000 0x491b6c 0x491b6c R E 0x1000
LOAD 0x491d20 0x00492d20 0x00492d20 0x06880 0x186c0 RW 0x1000
DYNAMIC 0x495ec0 0x00496ec0 0x00496ec0 0x00140 0x00140 RW 0x4
NOTE 0x000188 0x00000188 0x00000188 0x00044 0x00044 R 0x4
GNU_EH_FRAME 0x491b64 0x00491b64 0x00491b64 0x00008 0x00008 R 0x4
GNU_STACK 0x000000 0x00000000 0x00000000 0x00000 0x00000 RWE 0x10
EXIDX 0x48da50 0x0048da50 0x0048da50 0x04110 0x04110 R 0x4
GNU_RELRO 0x491d20 0x00492d20 0x00492d20 0x042e0 0x042e0 RW 0x8

Section to Segment mapping:
Segment Sections...
00
01 .interp
02 .interp .note.ABI-tag .note.gnu.build-id .dynsym .dynstr .gnu.hash .gnu.version .gnu.version_r .rel.dyn .rel.plt .init .plt .text .fini .rodata .ARM.extab .ARM.exidx .eh_frame .eh_frame_hdr
03 .data.rel.ro.local .jcr .fini_array .init_array .data.rel.ro .dynamic .data .tm_clone_table .got .bss
04 .dynamic
05 .note.ABI-tag .note.gnu.build-id
06 .eh_frame_hdr
07
08 .ARM.exidx
09 .data.rel.ro.local .jcr .fini_array .init_array .data.rel.ro .dynamic

 

$ readelf -d test

Dynamic section at offset 0x495ec0 contains 34 entries:
Tag Type Name/Value
0x00000003 (PLTGOT) 0x4990e8
0x00000002 (PLTRELSZ) 2392 (bytes)
0x00000017 (JMPREL) 0x6a16c
0x00000014 (PLTREL) REL
0x00000011 (REL) 0x63e2c
0x00000012 (RELSZ) 25408 (bytes)
0x00000013 (RELENT) 8 (bytes)
0x6ffffffa (RELCOUNT) 3154
0x00000015 (DEBUG) 0x0
0x00000006 (SYMTAB) 0x1cc
0x0000000b (SYMENT) 16 (bytes)
0x00000005 (STRTAB) 0x17b5c
0x0000000a (STRSZ) 256100 (bytes)
0x6ffffef5 (GNU_HASH) 0x563c0
0x00000001 (NEEDED) Shared library: [libpthread.so.0]
0x00000001 (NEEDED) Shared library: [libglib-2.0.so.0]
0x00000001 (NEEDED) Shared library: [librt.so.1]
0x00000001 (NEEDED) Shared library: [libstdc++.so.6]
0x00000001 (NEEDED) Shared library: [libm.so.6]
0x00000001 (NEEDED) Shared library: [libgcc_s.so.1]
0x00000001 (NEEDED) Shared library: [libc.so.6]
0x00000001 (NEEDED) Shared library: [ld-linux-armhf.so.3]
0x0000000c (INIT) 0x6aac4
0x0000000d (FINI) 0x3baff8
0x0000001a (FINI_ARRAY) 0x49605c
0x0000001c (FINI_ARRAYSZ) 4 (bytes)
0x00000019 (INIT_ARRAY) 0x496060
0x0000001b (INIT_ARRAYSZ) 264 (bytes)
0x6ffffff0 (VERSYM) 0x60d68
0x6ffffffe (VERNEED) 0x63c9c
0x6fffffff (VERNEEDNUM) 7
0x00000000 (NULL) 0x0