From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/13331 Path: news.gmane.org!.POSTED!not-for-mail From: "Jason A. Donenfeld" Newsgroups: gmane.linux.lib.musl.general Subject: broken shared executables on armeb (illegal instruction) Date: Sun, 30 Sep 2018 23:53:19 +0200 Message-ID: <20180930215317.GA11313@zx2c4.com> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1538344293 4290 195.159.176.226 (30 Sep 2018 21:51:33 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 30 Sep 2018 21:51:33 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-13347-gllmg-musl=m.gmane.org@lists.openwall.com Sun Sep 30 23:51:29 2018 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1g6jcb-0000vb-Kd for gllmg-musl@m.gmane.org; Sun, 30 Sep 2018 23:51:25 +0200 Original-Received: (qmail 28370 invoked by uid 550); 30 Sep 2018 21:53:33 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 28336 invoked from network); 30 Sep 2018 21:53:32 -0000 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=zx2c4.com; h=date:from:to :subject:message-id:mime-version:content-type :content-transfer-encoding; s=mail; bh=QzamjUW7ehzKXmK1q22feIBaz ss=; b=3ECPKKCWHsaluJfvwgDRSnABTdUew7gHuIT2IWXwKCXs7dltgTH+khr3m XkGH3Rq5iUKXFAncrcRVeXENRj3/f2fdJVvsVCkiIoutfScxSeKgnZnCdK7PgYXZ TjZdihcxxaoL5iqCj4Uxz5qVHU1s5lhOcITYYhPzMDGlv8J0bX1dL9aM/E3/Vgj5 Q8sJXCIdY1NaX829WUrRkxNT2hx498afkZkwAKI/KjVtiG4QxYaPaFg0/UZcVxi1 AMxrQbdp3xMjDodRAdb+pNnDqSXhmcGAJkurJjVqjcRqcSFn0r9GNqlyNfxk1DuH og2b6KFrh70OgpxD836UWYdfRHiYg== Content-Disposition: inline Xref: news.gmane.org gmane.linux.lib.musl.general:13331 Archived-At: Hello, There appears to be a problem with shared linking on big-endian ARM (armeb). First I'll show that static linking works correctly: $ armeb-pc-linux-gnueabi-gcc -v Using built-in specs. COLLECT_GCC=3Darmeb-pc-linux-gnueabi-gcc COLLECT_LTO_WRAPPER=3D/usr/libexec/gcc/armeb-pc-linux-gnueabi/8.2.0/lto-wra= pper Target: armeb-pc-linux-gnueabi Configured with: /var/tmp/portage/cross-armeb-pc-linux-gnueabi/gcc-8.2.0-r3= /work/gcc-8.2.0/configure --host=3Dx86_64-pc-linux-gnu --target=3Darmeb-pc-= linux-gnueabi --build=3Dx86_64-pc-linux-gnu --prefix=3D/usr --bindir=3D/usr= /x86_64-pc-linux-gnu/armeb-pc-linux-gnueabi/gcc-bin/8.2.0 --includedir=3D/u= sr/lib/gcc/armeb-pc-linux-gnueabi/8.2.0/include --datadir=3D/usr/share/gcc-= data/armeb-pc-linux-gnueabi/8.2.0 --mandir=3D/usr/share/gcc-data/armeb-pc-l= inux-gnueabi/8.2.0/man --infodir=3D/usr/share/gcc-data/armeb-pc-linux-gnuea= bi/8.2.0/info --with-gxx-include-dir=3D/usr/lib/gcc/armeb-pc-linux-gnueabi/= 8.2.0/include/g++-v8 --with-python-dir=3D/share/gcc-data/armeb-pc-linux-gnu= eabi/8.2.0/python --enable-languages=3Dc,c++,fortran --enable-obsolete --en= able-secureplt --disable-werror --with-system-zlib --enable-nls --without-i= ncluded-gettext --enable-checking=3Drelease --with-bugurl=3Dhttps://bugs.ge= ntoo.org/ --with-pkgversion=3D'Gentoo 8.2.0-r3 p1.3' --disable-esp --enable= -libstdcxx-time --enable-poison-system-directories --with-sysroot=3D/usr/ar= meb-pc-linux-gnueabi --disable-bootstrap --enable-__cxa_atexit --enable-clo= cale=3Dgnu --disable-multilib --disable-altivec --disable-fixed-point --wit= h-float=3Dsoft --enable-libgomp --disable-libmudflap --disable-libssp --dis= able-libmpx --disable-systemtap --enable-vtable-verify --enable-libvtv --en= able-lto --without-isl --enable-libsanitizer --enable-default-pie --enable-= default-ssp Thread model: posix gcc version 8.2.0 (Gentoo 8.2.0-r3 p1.3)=20 $ tar xf musl-1.1.20.tar.gz=20 $ cd musl-1.1.20/ $ export CFLAGS=3D"-O2 -march=3Darmv7-a -mtune=3Dcortex-a15 -mabi=3Daapcs-l= inux" $ CC=3Darmeb-pc-linux-gnueabi-gcc ./configure --prefix=3D$PWD/prefix --enab= le-static --disable-shared --build=3Darmeb-pc-linux-gnueabi [...] $ make -j$(nproc) [...] $ make install [...] $ cd prefix/ $ printf '#include \nint main(){puts("hello world");}' | bin/musl-= gcc -xc -o helloworld $CFLAGS - /usr/libexec/gcc/armeb-pc-linux-gnueabi/ld: /usr/lib/gcc/armeb-pc-linux-gnu= eabi/8.2.0/libgcc.a(_dvmd_lnx.o): in function `__aeabi_idiv0': /var/tmp/portage/cross-armeb-pc-linux-gnueabi/gcc-8.2.0-r3/work/gcc-8.2.0/l= ibgcc/config/arm/lib1funcs.S:1545: undefined reference to `raise' collect2: error: ld returned 1 exit status [This appears to be a well-known bug in some other mailing list post. Worki= ng around with the next command:] $ printf '#include \nint main(){puts("hello world");}' | bin/musl-= gcc -xc -o helloworld $CFLAGS -static - $ cp /usr/bin/qemu-armeb . $ sudo chroot $(readlink -f .) /qemu-armeb /helloworld hello world Now let's try with shared linking, and you'll see it generates a broken binary: $ tar xf musl-1.1.20.tar.gz=20 $ cd musl-1.1.20/ $ export CFLAGS=3D"-O2 -march=3Darmv7-a -mtune=3Dcortex-a15 -mabi=3Daapcs-l= inux" $ CC=3Darmeb-pc-linux-gnueabi-gcc ./configure --prefix=3D$PWD/prefix --disa= ble-static --enable-shared --build=3Darmeb-pc-linux-gnueabi [...] $ make -j$(nproc) [...] $ make install [...] $ cd prefix/ $ printf '#include \nint main(){puts("hello world");}' | bin/musl-= gcc -xc -o helloworld $CFLAGS - $ cd lib/ $ ln -s libc.so ld-musl-armeb.so.1 $ cd .. $ cp /usr/bin/qemu-armeb . $ sudo chroot $(readlink -f .) /qemu-armeb /helloworld Illegal instruction I've experienced similar failures when trying to boot with armeb executables as init with a real kernel that are generated this way. I've also experienced this with both my own toolchain (above) and with linaro's toolchain. I expect the commands above should result in an easily reproducable bug. Any idea what's up? Thanks, Jason