qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] linux-user/elfload: Fix handling of pure BSS segments


From: Alex Bennée
Subject: Re: [PATCH] linux-user/elfload: Fix handling of pure BSS segments
Date: Wed, 02 Dec 2020 13:29:37 +0000
User-agent: mu4e 1.5.7; emacs 28.0.50

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]