On 8/25/21 10:16 AM, Assaf Gordon wrote:
Hello,

On 2021-08-24 2:39 a.m., Paul Eggert wrote:
However, I think it'll be a better use of our time for you to debug this one yourself. It doesn't sound like a Coreutils problem; it sounds like a problem in your virtual machine setup, and you're the best expert on that setup.

Few suggestions to check, that might help you and us to troubleshoot:

1. ensure the binaries are indeed for aarch64:

   file /newroot/usr/sbin/chroot
   file /newroot/usr/bin/env
   file /newroot/usr/bin/bash

it should say something like
  "ELF 64-bit LSB pie executable, ARM aarch64"
for all of them.


2. ensure each binary works by itself:

 qemu-aarch64 -L /newroot /newroot/usr/sbin/chroot --version
 qemu-aarch64 -L /newroot /newroot/usr/bin/env --version
 qemu-aarch64 -L /newroot /newroot/usr/bin/bash --version

(the actual version doesn't matter here, the main thing is that
the qemu user-mode emulator was able to run the binaries.)

On 2021-08-21 4:33 a.m., Frans de Boer wrote:

Running 'qemu-aarch64 -L /newroot /newroot/usr/bin/bash -c /usr/bin/env> --help' does show the env help text. So, I guess chroot
is to blame?
Note that the above command runs your *host's* /usr/bin/env
because chroot is not used - the binary under qemu
 (/newroot/usr/bin/bash) sees your host's file system.

Observe with:

  qemu-aarch64 -L /newroot /newroot/usr/bin/bash -c /bin/uname -m
  qemu-aarch64 -L /newroot /newroot/usr/bin/env /bin/uname -m

I'm guessing you will see "x86_64", not "aarch64".

3. What you should try is:

  qemu-aarch64 -L /newroot \
     /newroot/usr/bin/bash -c /newroot/usr/bin/env --version
and:
  qemu-aarch64 -L /newroot \
     /newroot/usr/bin/env /newroot/usr/bin/bash --version

In both cases, one aarch64 binary will try to execute another aach64 binary. Do these work for you, or are you seeing an error?



4. Use qemu's "-strace" to see the syscalls, hopefully
that will help pinpoint the cause:

  qemu-aarch64 -strace -L /newroot \
      /newroot/usr/sbin/chroot /newroot /usr/bin/env --version 2&1 \
          | tee log.txt

If the command results in an error, the "log.txt" file will show
more details about what failed.
If you're not familiar with 'strace' output, post it here as an email attachment.


Hope this helps,
 - assaf

P.S.

On 2021-08-24 2:39 a.m., Paul Eggert wrote:
A complete set of instructions for an outsider to reproduce the
problem from scratch.  Assume the outsider is running Fedora 34
x86-64 (since that's what I'm running :-).
I'm not familiar with Fedora, but on Debian/x86_64 the following works:

   apt-get qemu-user
   apt-get install crossbuild-essential-arm64 libc6-arm64-cross

   cd coreutils
   ./configure --host=aarch64-linux-gnu
   make

then:

    $ qemu-aarch64 -L /usr/aarch64-linux-gnu/ ./src/uname -m
    aarch64

Somewhat related:

    $ qemu-aarch64 -L /usr/aarch64-linux-gnu/ ./src/env ./src/uname -m
    /lib/ld-linux-aarch64.so.1: No such file or directory

This fails because once "inside" qemu, the aarch64 searches for
"/lib/ld-linux-aarch64.so.1" but the file is in
"/usr/aarch64-linux-gnu/lib/ld-linux-aarch64.so.1".
One possible work-around is to build static binaries.

I don't want to assume that is the culprit for Frans, so we'll wait for the logs...


@assaf: your suggestions no. 1 and 2, had the predicted results. Thus, suggestion no. 3 failed because of suggestion no.2. I followed then suggestion 4 and attached the strace output to this message. It seems that chroot is working as expected, only env seems to fail with an error.

I hope you have some clue of what is going wrong.

--- Frans.

--
A: Yes, just like that                            A: Ja, net zo
Q: Oh, Just like reading a book backwards         Q: Oh, net als een boek 
achterstevoren lezen
A: Because it upsets the natural flow of a story  A: Omdat het de natuurlijke 
gang uit het verhaal haalt
Q: Why is top-posting annoying?                   Q: Waarom is Top-posting zo 
irritant?

1388 brk(NULL) = 0x000000000041b000
1388 uname(0x55007ff6b8) = 0
1388 faccessat(AT_FDCWD,"/etc/ld.so.preload",R_OK,AT_EACCESS|0x34cc8) = -1 
errno=2 (No such file or directory)
1388 openat(AT_FDCWD,"/etc/ld.so.cache",O_RDONLY|O_CLOEXEC) = 3
1388 newfstatat(3,"",0x00000055007fec90,0x1000) = 0
1388 mmap(NULL,78408,PROT_READ,MAP_PRIVATE,3,0) = 0x0000005500839000
1388 close(3) = 0
1388 
openat(AT_FDCWD,"/usr/lib/tls/aarch64/atomics/libc.so.6",O_RDONLY|O_CLOEXEC) = 
-1 errno=2 (No such file or directory)
1388 newfstatat(AT_FDCWD,"/usr/lib/tls/aarch64/atomics",0x00000055007fecc0,0) = 
-1 errno=2 (No such file or directory)
1388 openat(AT_FDCWD,"/usr/lib/tls/aarch64/libc.so.6",O_RDONLY|O_CLOEXEC) = -1 
errno=2 (No such file or directory)
1388 newfstatat(AT_FDCWD,"/usr/lib/tls/aarch64",0x00000055007fecc0,0) = -1 
errno=2 (No such file or directory)
1388 openat(AT_FDCWD,"/usr/lib/tls/atomics/libc.so.6",O_RDONLY|O_CLOEXEC) = -1 
errno=2 (No such file or directory)
1388 newfstatat(AT_FDCWD,"/usr/lib/tls/atomics",0x00000055007fecc0,0) = -1 
errno=2 (No such file or directory)
1388 openat(AT_FDCWD,"/usr/lib/tls/libc.so.6",O_RDONLY|O_CLOEXEC) = -1 errno=2 
(No such file or directory)
1388 newfstatat(AT_FDCWD,"/usr/lib/tls",0x00000055007fecc0,0) = -1 errno=2 (No 
such file or directory)
1388 openat(AT_FDCWD,"/usr/lib/aarch64/atomics/libc.so.6",O_RDONLY|O_CLOEXEC) = 
-1 errno=2 (No such file or directory)
1388 newfstatat(AT_FDCWD,"/usr/lib/aarch64/atomics",0x00000055007fecc0,0) = -1 
errno=2 (No such file or directory)
1388 openat(AT_FDCWD,"/usr/lib/aarch64/libc.so.6",O_RDONLY|O_CLOEXEC) = -1 
errno=2 (No such file or directory)
1388 newfstatat(AT_FDCWD,"/usr/lib/aarch64",0x00000055007fecc0,0) = -1 errno=2 
(No such file or directory)
1388 openat(AT_FDCWD,"/usr/lib/atomics/libc.so.6",O_RDONLY|O_CLOEXEC) = -1 
errno=2 (No such file or directory)
1388 newfstatat(AT_FDCWD,"/usr/lib/atomics",0x00000055007fecc0,0) = -1 errno=2 
(No such file or directory)
1388 openat(AT_FDCWD,"/usr/lib/libc.so.6",O_RDONLY|O_CLOEXEC) = 3
1388 read(3,0x7fee20,832) = 832
1388 newfstatat(3,"",0x00000055007fecc0,0x1000) = 0
1388 mmap(NULL,1691192,PROT_EXEC|PROT_READ,MAP_PRIVATE|MAP_DENYWRITE,3,0) = 
0x000000550084d000
1388 mprotect(0x00000055009c9000,61440,PROT_NONE) = 0
1388 
mmap(0x00000055009d8000,24576,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_DENYWRITE|MAP_FIXED,3,0x17b000)
 = 0x00000055009d8000
1388 
mmap(0x00000055009de000,48696,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANONYMOUS|MAP_FIXED,-1,0)
 = 0x00000055009de000
1388 close(3) = 0
1388 mmap(NULL,8192,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANONYMOUS,-1,0) = 
0x00000055009ea000
1388 
set_tid_address(365082617648,365082619376,365082617440,365080834112,365082617632,365080838368)
 = 1388
1388 set_robust_list(365082617664,24,365082617440,365082617712,365082617664,1) 
= -1 errno=38 (Function not implemented)
1388 mprotect(0x00000055009d8000,16384,PROT_READ) = 0
1388 mprotect(0x0000000000419000,4096,PROT_READ) = 0
1388 mprotect(0x0000005500835000,8192,PROT_READ) = 0
1388 prlimit64(0,3,0,365080606768,365082143416,40) = 0
1388 munmap(0x0000005500839000,78408) = 0
1388 getrandom(365082585408,8,1,365082617440,0,365080611539) = 8
1388 brk(NULL) = 0x000000000041b000
1388 brk(0x000000000043c000) = 0x000000000043c000
1388 openat(AT_FDCWD,"/usr/lib/locale/locale-archive",O_RDONLY|O_CLOEXEC) = -1 
errno=2 (No such file or directory)
1388 openat(AT_FDCWD,"/usr/share/locale/locale.alias",O_RDONLY|O_CLOEXEC) = 3
1388 newfstatat(3,"",0x00000055007ff430,0x1000) = 0
1388 read(3,0x41b4a0,4096) = 2998
1388 read(3,0x41b4a0,4096) = 0
1388 close(3) = 0
1388 
openat(AT_FDCWD,"/usr/lib/locale/en_US.UTF-8/LC_IDENTIFICATION",O_RDONLY|O_CLOEXEC)
 = -1 errno=2 (No such file or directory)
1388 
openat(AT_FDCWD,"/usr/lib/locale/en_US.utf8/LC_IDENTIFICATION",O_RDONLY|O_CLOEXEC)
 = 3
1388 newfstatat(3,"",0x00000055007ff7f0,0x1000) = 0
1388 mmap(NULL,369,PROT_READ,MAP_PRIVATE,3,0) = 0x00000055009ec000
1388 close(3) = 0
1388 openat(AT_FDCWD,"/usr/lib/gconv/gconv-modules.cache",O_RDONLY) = -1 
errno=2 (No such file or directory)
1388 openat(AT_FDCWD,"/usr/lib/gconv/gconv-modules",O_RDONLY|O_CLOEXEC) = 3
1388 newfstatat(3,"",0x00000055007ff470,0x1000) = 0
1388 read(3,0x41d310,4096) = 3808
1388 read(3,0x41d310,4096) = 0
1388 close(3) = 0
1388 
openat(AT_FDCWD,"/usr/lib/gconv/gconv-modules.d",O_RDONLY|O_DIRECTORY|O_NONBLOCK|O_CLOEXEC)
 = 3
1388 newfstatat(3,"",0x00000055007ff5d0,0x1000) = 0
1388 getdents64(3,4321280,32768,2147483647,4,3) = 96
1388 
openat(AT_FDCWD,"/usr/lib/gconv/gconv-modules.d/gconv-modules-extra.conf",O_RDONLY|O_CLOEXEC)
 = 4
1388 newfstatat(4,"",0x00000055007ff470,0x1000) = 0
1388 read(4,0x427010,4096) = 4096
1388 read(4,0x427010,4096) = 4096
1388 read(4,0x427010,4096) = 4096
1388 read(4,0x427010,4096) = 4096
1388 read(4,0x427010,4096) = 4096
1388 read(4,0x427010,4096) = 4096
1388 read(4,0x427010,4096) = 4096
1388 read(4,0x427010,4096) = 4096
1388 read(4,0x427010,4096) = 4096
1388 brk(0x000000000045d000) = 0x000000000045d000
1388 read(4,0x427010,4096) = 4096
1388 read(4,0x427010,4096) = 4096
1388 read(4,0x427010,4096) = 4096
1388 read(4,0x427010,4096) = 4096
1388 read(4,0x427010,4096) = 726
1388 read(4,0x427010,4096) = 0
1388 close(4) = 0
1388 getdents64(3,4321280,32768,2147483647,4,7) = 0
1388 close(3) = 0
1388 
futex(0x00000055009dd874,FUTEX_PRIVATE_FLAG|FUTEX_WAKE,2147483647,NULL,0x0000000000000026,38)
 = 0
1388 
openat(AT_FDCWD,"/usr/lib/locale/nl_NL.UTF-8/LC_MEASUREMENT",O_RDONLY|O_CLOEXEC)
 = -1 errno=2 (No such file or directory)
1388 
openat(AT_FDCWD,"/usr/lib/locale/nl_NL.utf8/LC_MEASUREMENT",O_RDONLY|O_CLOEXEC) 
= 3
1388 newfstatat(3,"",0x00000055007ff7f0,0x1000) = 0
1388 mmap(NULL,23,PROT_READ,MAP_PRIVATE,3,0) = 0x00000055009ed000
1388 close(3) = 0
1388 
openat(AT_FDCWD,"/usr/lib/locale/en_US.UTF-8/LC_TELEPHONE",O_RDONLY|O_CLOEXEC) 
= -1 errno=2 (No such file or directory)
1388 
openat(AT_FDCWD,"/usr/lib/locale/en_US.utf8/LC_TELEPHONE",O_RDONLY|O_CLOEXEC) = 
3
1388 newfstatat(3,"",0x00000055007ff7f0,0x1000) = 0
1388 mmap(NULL,59,PROT_READ,MAP_PRIVATE,3,0) = 0x00000055009ee000
1388 close(3) = 0
1388 
openat(AT_FDCWD,"/usr/lib/locale/en_US.UTF-8/LC_ADDRESS",O_RDONLY|O_CLOEXEC) = 
-1 errno=2 (No such file or directory)
1388 
openat(AT_FDCWD,"/usr/lib/locale/en_US.utf8/LC_ADDRESS",O_RDONLY|O_CLOEXEC) = 3
1388 newfstatat(3,"",0x00000055007ff7f0,0x1000) = 0
1388 mmap(NULL,167,PROT_READ,MAP_PRIVATE,3,0) = 0x00000055009ef000
1388 close(3) = 0
1388 openat(AT_FDCWD,"/usr/lib/locale/en_US.UTF-8/LC_NAME",O_RDONLY|O_CLOEXEC) 
= -1 errno=2 (No such file or directory)
1388 openat(AT_FDCWD,"/usr/lib/locale/en_US.utf8/LC_NAME",O_RDONLY|O_CLOEXEC) = 
3
1388 newfstatat(3,"",0x00000055007ff7f0,0x1000) = 0
1388 mmap(NULL,77,PROT_READ,MAP_PRIVATE,3,0) = 0x00000055009f0000
1388 close(3) = 0
1388 openat(AT_FDCWD,"/usr/lib/locale/en_US.UTF-8/LC_PAPER",O_RDONLY|O_CLOEXEC) 
= -1 errno=2 (No such file or directory)
1388 openat(AT_FDCWD,"/usr/lib/locale/en_US.utf8/LC_PAPER",O_RDONLY|O_CLOEXEC) 
= 3
1388 newfstatat(3,"",0x00000055007ff7f0,0x1000) = 0
1388 mmap(NULL,34,PROT_READ,MAP_PRIVATE,3,0) = 0x00000055009f1000
1388 close(3) = 0
1388 
openat(AT_FDCWD,"/usr/lib/locale/en_US.UTF-8/LC_MESSAGES",O_RDONLY|O_CLOEXEC) = 
-1 errno=2 (No such file or directory)
1388 
openat(AT_FDCWD,"/usr/lib/locale/en_US.utf8/LC_MESSAGES",O_RDONLY|O_CLOEXEC) = 3
1388 newfstatat(3,"",0x00000055007ff7f0,0x1000) = 0
1388 close(3) = 0
1388 
openat(AT_FDCWD,"/usr/lib/locale/en_US.utf8/LC_MESSAGES/SYS_LC_MESSAGES",O_RDONLY|O_CLOEXEC)
 = 3
1388 newfstatat(3,"",0x00000055007ff7f0,0x1000) = 0
1388 mmap(NULL,57,PROT_READ,MAP_PRIVATE,3,0) = 0x00000055009f2000
1388 close(3) = 0
1388 
openat(AT_FDCWD,"/usr/lib/locale/en_NL.UTF-8/LC_MONETARY",O_RDONLY|O_CLOEXEC) = 
-1 errno=2 (No such file or directory)
1388 
openat(AT_FDCWD,"/usr/lib/locale/en_NL.utf8/LC_MONETARY",O_RDONLY|O_CLOEXEC) = 
-1 errno=2 (No such file or directory)
1388 openat(AT_FDCWD,"/usr/lib/locale/en_NL/LC_MONETARY",O_RDONLY|O_CLOEXEC) = 
-1 errno=2 (No such file or directory)
1388 openat(AT_FDCWD,"/usr/lib/locale/en.UTF-8/LC_MONETARY",O_RDONLY|O_CLOEXEC) 
= -1 errno=2 (No such file or directory)
1388 openat(AT_FDCWD,"/usr/lib/locale/en.utf8/LC_MONETARY",O_RDONLY|O_CLOEXEC) 
= -1 errno=2 (No such file or directory)
1388 openat(AT_FDCWD,"/usr/lib/locale/en/LC_MONETARY",O_RDONLY|O_CLOEXEC) = -1 
errno=2 (No such file or directory)
1388 readlinkat(AT_FDCWD,"/mnt",0x00000055007ff260,1023) = -1 errno=22 (Invalid 
argument)
1388 readlinkat(AT_FDCWD,"/mnt/lfs",0x00000055007ff260,1023) = -1 errno=22 
(Invalid argument)
1388 chroot("/mnt/lfs") = 0
1388 chdir("/") = 0
1388 execve("/usr/bin/env",{"/usr/bin/env","--version",NULL}) = -1 errno=8 
(Exec format error)
1388 execve("/bin/sh",{"/bin/sh","/usr/bin/env","--version",NULL}) = -1 errno=8 
(Exec format error)
/mnt/lfs/usr/sbin/chroot: 1388 write(2,0x7fd170,26) = 26
failed to run command '/usr/bin/env'1388 write(2,0x7fd220,36) = 36
: Exec format error1388 write(2,0x7fcd10,19) = 19

1388 write(2,0x7fd120,1) = 1
1388 close(1) = 0

Reply via email to