作者:Ar0nW
原文地址:https://ar0n.wang/execute-32-bit-program-on-64-bit-linux/
在對linux上的程序進行調(diào)試時,使用file program_name查看這個可執(zhí)行文件的相關信息,可以看出可執(zhí)行文件是32位程序。
由于系統(tǒng)的環(huán)境是64位的,默認不支持運行32位程序牲蜀,所以需要安裝32位的支持庫以執(zhí)行32位程序。
ar0nw@box: ~$ file program_name
program_name:
ELF 32-bit LSB executable,
Intel 80386, version 1 (SYSV),
dynamically linked,
Interpreter /lib/ld-linux.so.2,
for GNU/Linux 2.6.18,
BuildID[sha1]=96997aacd6ee7889b99dc156d83c9d205eb58092,
stripped
通過uname -a命令可以得知系統(tǒng)是64位的
所以使用sudo apt-getinstall ia32-libs下載32位的lib庫
ar0nw@box:~$ sudo apt-get install lib32z1
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libc6-i386
The following NEW packages will be installed:
lib32z1 libc6-i386
0 upgraded, 2 newly installed, 0 to remove and 88 not upgraded.
Need to get 2,381 kB of archives.
After this operation, 10.6 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://mirrors.aliyun.com/ubuntu xenial-updates/main amd64 libc6-i386 amd64 2.23-0ubuntu5 [2,329 kB]
Get:2 http://mirrors.aliyun.com/ubuntu xenial/main amd64 lib32z1 amd64 1:1.2.8.dfsg-2ubuntu4 [52.2 kB]
Fetched 2,381 kB in 2s (988 kB/s)
Selecting previously unselected package libc6-i386.
(Reading database ... 180885 files and directories currently installed.)
Preparing to unpack .../libc6-i386_2.23-0ubuntu5_amd64.deb ...
Unpacking libc6-i386 (2.23-0ubuntu5) ...
Selecting previously unselected package lib32z1.
Preparing to unpack .../lib32z1_1%3a1.2.8.dfsg-2ubuntu4_amd64.deb ...
Unpacking lib32z1 (1:1.2.8.dfsg-2ubuntu4) ...
Processing triggers for libc-bin (2.23-0ubuntu5) ...
Setting up libc6-i386 (2.23-0ubuntu5) ...
Setting up lib32z1 (1:1.2.8.dfsg-2ubuntu4) ...
Processing triggers for libc-bin (2.23-0ubuntu5) ...
之后32位的可執(zhí)行程序即可在64位系統(tǒng)上執(zhí)行。