From nobody Mon Sep 19 10:49:27 2022 X-Original-To: soc-status@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4MWLzF4Zbrz4cSNQ for ; Mon, 19 Sep 2022 10:49:45 +0000 (UTC) (envelope-from kotty.0704@gmail.com) Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4MWLzF1jXYz42xV for ; Mon, 19 Sep 2022 10:49:45 +0000 (UTC) (envelope-from kotty.0704@gmail.com) Received: by mail-pl1-x634.google.com with SMTP id f23so11294864plr.6 for ; Mon, 19 Sep 2022 03:49:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date; bh=GuprdxhnTsVzr/aMYcMKh1yuWWO2y7bVwipUKs0zDtI=; b=J4rSJyAcL94hWbbXLK0mwbyASnApTyMMT1KTRF5XNNE2FcNcWnrp1OLjb0Hyf51j9E VO0ckktHyb5KK06tUQdUVNEUP60Gk8pxA6i/3pZdhjOOm3yOWGGZ83x5EOpX5dJjStdJ c44QHKuEQ47oHjmr+Ie4XMe2LGWCIKh8FHdKNpr5bDv7Td3zXjQzaNhOjdl7+eM3wye7 r3OqEnHfCWZMtgoIs/d5IXL8J/K94TAep2VToBLZRzLWJpf+gZebMsv2AF+jkf/Cnp1e bbXGClQ1eFR6EHPbZAMTrY89GgQq3S+U4lvllNui8cZmhwpCDq5WAlGZSYAdZGA3sKBO nhWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date; bh=GuprdxhnTsVzr/aMYcMKh1yuWWO2y7bVwipUKs0zDtI=; b=5iCpKv2KmjmMSJoa6ra8PDhYKLyNm32U+GjUdX35joqyn2+cGC/zEXx3lfYl9xesMl 5NtdsJtAzJIqGtKezhEbIbqrIYTZVHtZf2jJe2iemxMuquw2s0qQPQ6wunEOoBvDzu1c 75tWM8CNnUK2RoZj6CFsiIbfosB9Wz3UtlmyzeDWMkdhvzU6FlpKk8ZLbqZj1DjYce73 DVTzSWWmhnydF6BQf/9ou5vmLbHyuTDvJ6PTLKjejVXBbkhBp8dofYjgIQsFzPEu8evr IIP9fewaJY8xUMLgcKTwSuDGYgYi2by/HXMweVVQSae9I2QY0+/GpY6jUQxEDOFjtyJU amRA== X-Gm-Message-State: ACrzQf3eQNWpOTwzc7cvSdnRpHa/8QkVhiYinLmgJsprUqJLpR5fTvAA L/Uzzj5FGUqftWWDdilQNRVpTiC0nDmS+HYBqwqhiVadF0g= X-Google-Smtp-Source: AMsMyM6ZDQo5K9uTbD92EPPHHwkRQw1rteMfzussh3wsRlYU2YbSM1fO5z+3S3obpmSHY+jRoP1rGqAVSkJK7XYeoGU= X-Received: by 2002:a17:903:1248:b0:172:614b:234b with SMTP id u8-20020a170903124800b00172614b234bmr12403175plh.169.1663584584005; Mon, 19 Sep 2022 03:49:44 -0700 (PDT) List-Id: Summer of Code Status Reports and Discussion List-Archive: https://lists.freebsd.org/archives/soc-status List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-soc-status@freebsd.org X-BeenThere: soc-status@freebsd.org MIME-Version: 1.0 References: In-Reply-To: From: =?UTF-8?B?5LuK5LqV6Iiq5LiA?= Date: Mon, 19 Sep 2022 19:49:27 +0900 Message-ID: Subject: Fwd: [GSoC22 Weekly Status report #10&11] Fixed bug for supporting dynamically linked Linux binary: Koichi Imai To: soc-status@freebsd.org Content-Type: multipart/alternative; boundary="0000000000002effbb05e9057868" X-Rspamd-Queue-Id: 4MWLzF1jXYz42xV X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20210112 header.b=J4rSJyAc; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of kotty.0704@gmail.com designates 2607:f8b0:4864:20::634 as permitted sender) smtp.mailfrom=kotty.0704@gmail.com X-Spamd-Result: default: False [-3.23 / 15.00]; NEURAL_HAM_MEDIUM(-0.99)[-0.992]; NEURAL_HAM_LONG(-0.99)[-0.989]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; NEURAL_HAM_SHORT(-0.25)[-0.253]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20210112]; R_SPF_ALLOW(-0.20)[+ip6:2607:f8b0:4000::/36:c]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; RCPT_COUNT_ONE(0.00)[1]; RCVD_IN_DNSWL_NONE(0.00)[2607:f8b0:4864:20::634:from]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[soc-status@freebsd.org]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DWL_DNSWL_NONE(0.00)[gmail.com:dkim]; TAGGED_FROM(0.00)[]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; MID_RHS_MATCH_FROMTLD(0.00)[]; TO_DN_NONE(0.00)[]; FREEMAIL_FROM(0.00)[gmail.com]; MLMMJ_DEST(0.00)[soc-status@freebsd.org]; DKIM_TRACE(0.00)[gmail.com:+]; RCVD_TLS_LAST(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; MIME_TRACE(0.00)[0:+,1:+,2:~]; RCVD_COUNT_TWO(0.00)[2] X-ThisMailContainsUnwantedMimeParts: N --0000000000002effbb05e9057868 Content-Type: text/plain; charset="UTF-8" Hello, It appears that I was not able to send the previous email, so I will send the previous one. Shortly after this, I will also send you an email with the progress for the past few weeks. After I successfully ran the statically linked Linux binary that just returns in the main function last week, I verified that basic system calls such as write and read, and file system operations such as fwrite and fread work if they are statically linked. I've also tried to check if the dynamically linked binary works by $ chroot /compat/lg64 /bin/bash (I made the /compat/lg64 directory and opened the gentoo linux stage3 tarball here.) However, it failed because of a segmentation fault in the startup code. I tried to find out why but since there was no symbol found in libc.so.6 and ld64.so I had to get the one with debug symbols. Using gdb, I could finally figure out the cause and it was because the stack with argc, argv, and envp pushed was not being passed correctly. The static link seemed to pass them as registers, so I did not find the problem, but it seemed to have failed because the dynamic link passed them as stacks. I also added some code to support linux_mmap(not linux_mmap2) since it was failing at mmap syscall. However, it still fails with the error message as follows "linux: jid 0 pid 907 (bash): linux_ioctl_fallback fd=0, cmd=0x402c7413 ('t',19) is not implemented" To solve this I've looked around the source code of Linux and found that linux's ioctl-related macros are different on powerpc, and I think I can solve it by overriding them in /powerpc/linux/linux.h. Koichi --0000000000002effbb05e9057868 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello,

It appears that I was not able to send the previous = email, so I will send the previous one.=C2=A0Shortly after this, I will als= o send you an email with the progress for the past few weeks.

After I successfully ran the statically linked Linux binary= that just returns in the main function last week, I verified that basic sy= stem calls such as write and read, and file system operations such as fwrit= e and fread work if they are statically linked.

I&= #39;ve also tried to check if the dynamically linked binary works by=C2=A0<= /div>
$ chroot /compat/lg64 /bin/bash
(I made the /compat/lg6= 4 directory and opened the gentoo linux stage3 tarball here.)
How= ever, it failed because of a segmentation fault in the startup code. I trie= d to find out why but since there was no symbol found in libc.so.6 and ld64= .so I had to get the one with debug symbols.
Using gdb, I could f= inally figure out the cause and it was because the stack with argc, argv, a= nd envp pushed was not being passed correctly. The static link seemed to pa= ss them as registers, so I did not find the problem, but it seemed to have = failed because the dynamic link passed them as stacks.

=
I also added some code to support linux_mmap(not linux_mmap2) since it= was failing at mmap syscall. However, it still fails with the error messag= e as follows
"linux: jid 0 pid 907 (bash): linux_ioctl_fallb= ack fd=3D0, cmd=3D0x402c7413 ('t',19) is not implemented"=C2= =A0
To solve this I've looked around the=C2=A0source code of = Linux and found that linux's ioctl-related macros are different on powe= rpc, and I think I can solve it by overriding them in /powerpc/linux/linux.= h.

Koichi

--0000000000002effbb05e9057868--