JonathonReinhart / staticx

Create static executable from dynamic executable
https://staticx.readthedocs.io/
Other
345 stars 37 forks source link

Older objcopy mangles bootloader built with musl #205

Open JonathonReinhart opened 3 years ago

JonathonReinhart commented 3 years ago

Long stories (#198, #203) very short: objcopy on CentOS 7 mangles the program headers of a bootloader built with musl-gcc on Debian bullseye.

Built on: Debian bulseye, gcc 10.2.1, musl-tools 1.2.2-1

Distro objcopy Status
CentOS 7 2.27-44.base.el7 :x: Fail
Debian 9 2.28 :x: Fail
Ubuntu 18.04 2.30 :x: Fail
Debian 10 2.31.1 :x: Fail
Debian 11 2.35.2 :heavy_check_mark: OK

Workaround

Don't install the published wheels:

pip install --no-binary=staticx staticx

Test data

CentOS 7 ``` $ docker run --rm -it centos:7-python3 [root@84d569a38121 /]# objcopy --version GNU objcopy version 2.27-44.base.el7 ... [root@84d569a38121 /]# pip3 install staticx==0.13.3 ... [root@84d569a38121 /]# staticx $(which date) date.sx [root@84d569a38121 /]# ./date.sx Segmentation fault ```
Debian 9 ``` $ docker run --rm -it debian:9 root@74d70c11f933:/# apt update && apt install -y --no-install-recommends python3-pip python3-wheel python3-pkg-resources python3-setuptools binutils patchelf ... root@74d70c11f933:/# pip3 install staticx==0.13.3 root@74d70c11f933:/# objcopy --version GNU objcopy (GNU Binutils for Debian) 2.28 root@74d70c11f933:/# staticx $(which date) date.sx root@74d70c11f933:/# ./date.sx ```
Ubuntu 18.04 ``` $ docker run --rm -it ubuntu:18.04 root@4ade3afa85e7:/# objcopy --version GNU objcopy (GNU Binutils for Ubuntu) 2.30 root@4ade3afa85e7:/# apt update && apt install -y --no-install-recommends python3-pip python3-wheel python3-pkg-resources python3-setuptools binutils patchelf ... root@4ade3afa85e7:/# pip3 install staticx==0.13.3 ... root@4ade3afa85e7:/# staticx $(which date) date.sx root@4ade3afa85e7:/# ./date.sx Segmentation fault ```
Debian 10 ``` $ docker run --rm -it debian:10 root@15dface5550b:/# apt update && apt install -y --no-install-recommends python3-pip python3-wheel python3-pkg-resources python3-setuptools binutils patchelf ... root@15dface5550b:/# objcopy --version GNU objcopy (GNU Binutils for Debian) 2.31.1 root@15dface5550b:/# pip3 install staticx ... root@15dface5550b:/# staticx $(which date) date.sx root@15dface5550b:/# ./date.sx Segmentation fault ```
Debian 11 ``` $ objcopy --version GNU objcopy (GNU Binutils for Debian) 2.35.2 $ pip3 install staticx ... $ staticx $(which date) date.sx $ ./date.sx Thu 14 Oct 2021 03:54:46 AM EDT ```
Andrwe commented 2 years ago

Just for your information. The install of staticx from source worked to solve segfaulting binaries generated within docker container based on official python:3 image. To get the installation running I had to install scons within the container first.