From: "Alex Bennée" <alex.bennee@linaro.org>
To: Stephen Long <steplong@quicinc.com>
Cc: peter.maydell@linaro.org, richard.henderson@linaro.org,
mjt@tls.msk.ru, laurent@vivier.eu, qemu-devel@nongnu.org,
philippe.mathieu.daude@gmail.com, ben@decadent.org.uk
Subject: Re: [PATCH] linux-user/elfload: Fix handling of pure BSS segments
Date: Wed, 02 Dec 2020 13:29:37 +0000 [thread overview]
Message-ID: <87mtyws5dq.fsf@linaro.org> (raw)
In-Reply-To: <20201201200939.19823-1-steplong@quicinc.com>
Stephen Long <steplong@quicinc.com> writes:
> Alex Bennee <alex.bennee@linaro.org> writes:
>
>>> Apologies for the unclear commit msg. I was also seeing a SIGSEGV in
>>> zero_bss() with the binaries I was generating. I was using LLD to generate
>>> the binaries. The binaries all had LOAD segments with a file size of
>>> 0.
>>
>> How hairy is the generation of these binaries? If it's all doable with
>> standard gcc/ldd command lines it would be useful to add them as a
>> tcg/multiarch test case.
>
> We are linking with an old version of musl. I was able to produce an
> ELF with a LOAD segment just for the BSS with the following:
>
> volatile int num;
>
> int main(void) {
> return num;
> }
>
> and compiling it with just aarch64-linux-gnu-gcc -fuse-ld=lld -static and
> linking with cross compiled musl v1.1.9 on Ubuntu. I tried it with glibc and
> it has a bunch of non-BSS variables, so the data section gets created.
Hmm I tried the following patch but evidently there is more to be done
to convince it:
13:26:24 [alex@zen:~/l/q/b/arm.all] virtio/vhost-user-rpmb-v2|✚4…(+6/-3) 2 + make build-tcg-tests-aarch64-linux-user -j9 V=1
make -f /home/alex/lsrc/qemu.git/tests/tcg/Makefile.qemu SRC_PATH=/home/alex/lsrc/qemu.git V="1" TARGET="aarch64-linux-user" guest-tests
make[1]: Entering directory '/home/alex/lsrc/qemu.git/builds/arm.all'
(mkdir -p tests/tcg/aarch64-linux-user && cd tests/tcg/aarch64-linux-user && make -f ../Makefile.target TARGET="aarch64-linux-user" CC="aarch64-linux-gnu-gcc" SRC_PATH="/home/alex/lsrc/qemu.git" BUILD_STATIC=y EXTRA_CFLAGS="")
make[2]: Entering directory '/home/alex/lsrc/qemu.git/builds/arm.all/tests/tcg/aarch64-linux-user'
aarch64-linux-gnu-gcc -Wall -O0 -g -fno-strict-aliasing /home/alex/lsrc/qemu.git/tests/tcg/aarch64/zero-bss.c -o zero-bss -static -fuse-ld=lld
collect2: fatal error: cannot find 'ld'
compilation terminated.
make[2]: *** [../Makefile.target:103: zero-bss] Error 1
make[2]: Leaving directory '/home/alex/lsrc/qemu.git/builds/arm.all/tests/tcg/aarch64-linux-user'
make[1]: *** [/home/alex/lsrc/qemu.git/tests/tcg/Makefile.qemu:42: cross-build-guest-tests] Error 2
make[1]: Leaving directory '/home/alex/lsrc/qemu.git/builds/arm.all'
make: *** [/home/alex/lsrc/qemu.git/tests/Makefile.include:54: build-tcg-tests-aarch64-linux-user] Error 2
--8<---------------cut here---------------start------------->8---
tests/tcg: try and add a zero-bss test case (WIP)
3 files changed, 17 insertions(+), 1 deletion(-)
tests/tcg/aarch64/zero-bss.c | 13 +++++++++++++
tests/docker/dockerfiles/debian-arm64-test-cross.docker | 2 +-
tests/tcg/aarch64/Makefile.target | 3 +++
new file tests/tcg/aarch64/zero-bss.c
@@ -0,0 +1,13 @@
+/*
+ * Zero BSS Test case
+ *
+ * Copyright (c) 2020 Linaro Ltd
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+volatile int num;
+
+int main(void) {
+ return num;
+}
modified tests/docker/dockerfiles/debian-arm64-test-cross.docker
@@ -10,4 +10,4 @@ RUN dpkg --add-architecture arm64
RUN apt update && \
DEBIAN_FRONTEND=noninteractive eatmydata \
apt install -y --no-install-recommends \
- crossbuild-essential-arm64 gcc-10-aarch64-linux-gnu
+ crossbuild-essential-arm64 gcc-10-aarch64-linux-gnu musl-dev:arm64
modified tests/tcg/aarch64/Makefile.target
@@ -84,4 +84,7 @@ endif
endif
+AARCH64_TESTS += zero-bss
+zero-bss: LDFLAGS+=-fuse-ld=lld
+
TESTS += $(AARCH64_TESTS)
--8<---------------cut here---------------end--------------->8---
--
Alex Bennée
next prev parent reply other threads:[~2020-12-02 13:33 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-18 16:52 [PATCH] linux-user/elfload: Fix handling of pure BSS segments Stephen Long
2020-11-24 17:32 ` Richard Henderson
2020-11-24 17:38 ` Peter Maydell
2020-11-24 18:47 ` Stephen Long
2020-11-25 9:39 ` Alex Bennée
2020-12-02 17:44 ` Peter Maydell
2020-12-01 20:09 ` Stephen Long
2020-12-02 13:29 ` Alex Bennée [this message]
2020-12-02 17:14 ` Stephen Long
2020-12-17 9:41 ` Laurent Vivier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87mtyws5dq.fsf@linaro.org \
--to=alex.bennee@linaro.org \
--cc=ben@decadent.org.uk \
--cc=laurent@vivier.eu \
--cc=mjt@tls.msk.ru \
--cc=peter.maydell@linaro.org \
--cc=philippe.mathieu.daude@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=steplong@quicinc.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).