LoginSignup
3
4

More than 5 years have passed since last update.

Debian系(ubutun 15.10)におけるamd64環境下における32bitsバイナリ実行

Posted at

ベンダーが提供している一部のユーティリティが80386バイナリだったのでx86_64環境で動かす備忘録

発端

ADATAのSSDのファームウェアを更新しようとしていた時に下記のような症状が現れた。

bash
$ ./ADATA_SF_FieldUpdater_v136_Linux32
-bash: ./ADATA_SF_FieldUpdater_v136_Linux32: No such file or directory

$ file -s ADATA_SF_FieldUpdater_v136_Linux32
ADATA_SF_FieldUpdater_v136_Linux32: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=5aba1747cf5997db1af187ebf439462e20ecc46b, stripped

$ ldd ADATA_SF_FieldUpdater_v136_Linux32
        not a dynamic executable

ファイルがあるのに無いといわれる、動的リンクバイナリなのに動的リンクじゃないと言われてしまう。

Multiarchとは

  • Debian Wheezyから導入された複数環境用のバイナリを共存させる仕組み
    • 昔からi386とamd64の間はCPUが対応していたので特別なパッケージia32-libsなどを入れることで動かすことができた。
  • Multiarchのおかげでamd64環境でCPU非対応なARMやia64のバイナリを動かすことが出来る様になった。
bash
$  dpkg --print-architecture
amd64

$ dpkg --print-foreign-architectures
i386

$ dpkg -l | grep i386

おそらく、i386用パッケージ一式が存在しないので実行ファイルとして解釈することすらできなくなっていると思われる。

ほぼ全てで必要とされるi386版libc6パッケージをインストールする。

bash
$ apt-cache show libc6:i386
Package: libc6
Priority: required
Section: libs
Installed-Size: 9423
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: GNU Libc Maintainers <debian-glibc@lists.debian.org>
Architecture: i386
Source: glibc
Version: 2.21-0ubuntu4
Replaces: libc6-i386, libc6-xen
Provides: libc6-i686, libc6-xen
Depends: libgcc1
Suggests: glibc-doc, debconf | debconf-2.0, locales
Conflicts: libc6-xen, prelink (<= 0.0.20090311-1), tzdata (<< 2007k-1), tzdata-etch
Breaks: hurd (<< 1:0.5.git20140203-1), libtirpc1 (<< 0.2.3), nscd (<< 2.21)
Filename: pool/main/g/glibc/libc6_2.21-0ubuntu4_i386.deb
Size: 4093320
MD5sum: 8f702ab09fb6b3dc20c66ffec6a9972c
SHA1: 39c8d323e77b5bb80a2c2e9768b40e31bd656201
SHA256: e1cace9f2bbaba8f8ed94a08324b11bdcc3ebee80c4994dbf9f3fa8948a4a8f3
Description-en: GNU C Library: Shared libraries
 Contains the standard libraries that are used by nearly all programs on
 the system. This package includes shared versions of the standard C library
 and the standard math library, as well as many others.
Description-md5: fc3001b0b90a1c8e6690b283a619d57f
Multi-Arch: same
Homepage: http://www.gnu.org/software/libc/libc.html
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Origin: Ubuntu
Supported: 9m
Task: minimal

$ sudo apt-get install libc6:i386
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  gcc-5-base:i386 libgcc1:i386
Suggested packages:
  glibc-doc:i386 locales:i386
The following NEW packages will be installed:
  gcc-5-base:i386 libc6:i386 libgcc1:i386
0 upgraded, 3 newly installed, 0 to remove and 3 not upgraded.
Need to get 4,157 kB of archives.
After this operation, 9,844 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://jp.archive.ubuntu.com/ubuntu/ wily/main gcc-5-base i386 5.2.1-22ubu                                ntu2 [16.7 kB]
Get:2 http://jp.archive.ubuntu.com/ubuntu/ wily/main libgcc1 i386 1:5.2.1-22ubun                                tu2 [46.5 kB]
Get:3 http://jp.archive.ubuntu.com/ubuntu/ wily/main libc6 i386 2.21-0ubuntu4 [4                                ,093 kB]
Fetched 4,157 kB in 0s (7,087 kB/s)
Preconfiguring packages ...
Selecting previously unselected package gcc-5-base:i386.
(Reading database ... 60480 files and directories currently installed.)
Preparing to unpack .../gcc-5-base_5.2.1-22ubuntu2_i386.deb ...
Unpacking gcc-5-base:i386 (5.2.1-22ubuntu2) ...
Selecting previously unselected package libgcc1:i386.
Preparing to unpack .../libgcc1_1%3a5.2.1-22ubuntu2_i386.deb ...
Unpacking libgcc1:i386 (1:5.2.1-22ubuntu2) ...
Selecting previously unselected package libc6:i386.
Preparing to unpack .../libc6_2.21-0ubuntu4_i386.deb ...
Unpacking libc6:i386 (2.21-0ubuntu4) ...
Setting up gcc-5-base:i386 (5.2.1-22ubuntu2) ...
Setting up libgcc1:i386 (1:5.2.1-22ubuntu2) ...
Setting up libc6:i386 (2.21-0ubuntu4) ...
Processing triggers for libc-bin (2.21-0ubuntu4) ...

インストール後に改めてバイナリを確認すると

$ file ADATA_SF_FieldUpdater_v136_Linux32
ADATA_SF_FieldUpdater_v136_Linux32: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=5aba1747cf5997db1af187ebf439462e20ecc46b, stripped

$ ldd ADATA_SF_FieldUpdater_v136_Linux32
        linux-gate.so.1 =>  (0xf773c000)
        libSM.so.6 => not found
        libICE.so.6 => not found
        libXrender.so.1 => not found
        libfontconfig.so.1 => not found
        libfreetype.so.6 => not found
        libXext.so.6 => not found
        libX11.so.6 => not found
        libdl.so.2 => /lib/i386-linux-gnu/libdl.so.2 (0xf772a000)
        librt.so.1 => /lib/i386-linux-gnu/librt.so.1 (0xf7721000)
        libpthread.so.0 => /lib/i386-linux-gnu/libpthread.so.0 (0xf7704000)
        libstdc++.so.6 => not found
        libm.so.6 => /lib/i386-linux-gnu/libm.so.6 (0xf76b7000)
        libgcc_s.so.1 => /lib/i386-linux-gnu/libgcc_s.so.1 (0xf7698000)
        libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xf74dd000)
        /lib/ld-linux.so.2 (0x5662e000)

こいつ、X環境要求するのか。。。

環境汚染を防ぐためDocker上で実行するお話に移る。

3
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4