| 12 Nov 2025 |
Tristan Ross | roma@mu-gundam:~/nixpkgs$ strace /nix/store/95y6xmfgcvgxjmba9xm6ccxxnf6i61pw-bootstrap-tools/bin
execve("/nix/store/95y6xmfgcvgxjmba9xm6ccxxnf6i61pw-bootstrap-tools/bin", ["/nix/store/95y6xmfgcvgxjmba9xm6c"...], 0x7fffe5cec8b0 /* 30 vars */) = -1 EACCES (Permission denied)
strace: exec: Permission denied
+++ exited with 1 +++
So confusing...
| 05:46:18 |
Tristan Ross | * roma@mu-gundam:~/nixpkgs$ strace /nix/store/95y6xmfgcvgxjmba9xm6ccxxnf6i61pw-bootstrap-tools/bin/gcc
execve("/nix/store/95y6xmfgcvgxjmba9xm6ccxxnf6i61pw-bootstrap-tools/bin/gcc", ["/nix/store/95y6xmfgcvgxjmba9xm6c"...], 0x7fffe09ae8a0 /* 30 vars */) = -1 EPERM (Operation not p)
+++ killed by SIGSEGV +++
Segmentation fault (core dumped)
So confusing...
| 05:46:55 |
Mic92 | @rosscomputerguy:matrix.org: is your ld.so broken potentially? | 05:49:44 |
Tristan Ross | Idk | 05:49:56 |
Tristan Ross | It would mean bootstrap-tools's is broken, right? | 05:50:17 |
Tristan Ross | roma@mu-gundam:~/nixpkgs$ /nix/store/kg61gdq4svvph0c4pcsf867r8nkbiqs7-bootstrap-tools/lib/ld-linux-riscv64-lp64d.so.1 /nix/store/kg61gdq4svvph0c4pcsf867r8nkbiqs7-bootstrap-toolc/gcc
/nix/store/kg61gdq4svvph0c4pcsf867r8nkbiqs7-bootstrap-tools/bin/gcc: error while loading shared libraries: /nix/store/kg61gdq4svvph0c4pcsf867r8nkbiqs7-bootstrap-tools/bin/gcc: failed to map segment from shared object
| 05:50:54 |
Tristan Ross | * roma@mu-gundam:~/nixpkgs$ /nix/store/kg61gdq4svvph0c4pcsf867r8nkbiqs7-bootstrap-tools/lib/ld-linux-riscv64-lp64d.so.1 /nix/store/kg61gdq4svvph0c4pcsf867r8nkbiqs7-bootstrap-toolc/bin/gcc
/nix/store/kg61gdq4svvph0c4pcsf867r8nkbiqs7-bootstrap-tools/bin/gcc: error while loading shared libraries: /nix/store/kg61gdq4svvph0c4pcsf867r8nkbiqs7-bootstrap-tools/bin/gcc: failed to map segment from shared object
| 05:51:04 |
Tristan Ross | I get the same error if I try using Ubuntu's ld.so on GCC. | 05:52:22 |
Mic92 | Try LD_DEBUG=all | 05:53:35 |
Tristan Ross | I get 1 extra line:
6557: file=/nix/store/kg61gdq4svvph0c4pcsf867r8nkbiqs7-bootstrap-tools/bin/gcc [0]; generating link map
| 05:54:01 |
Mic92 | Strace on your ld.so? | 05:54:44 |
Mic92 | I think there might be something your gcc tries to map to an fixed address space adress that the kernel even before staring ld.so outrightly refuses | 05:55:56 |
Mic92 | * I think there might be something your gcc tries to map to an fixed address space adress that the kernel even before starting ld.so outrightly refuses | 05:56:15 |
Tristan Ross | roma@mu-gundam:~/nixpkgs$ strace -E LD_DEBUG=all /nix/store/kg61gdq4svvph0c4pcsf867r8nkbiqs7-bootstrap-tools/lib/ld-linux-riscv64-lp64d.so.1 /nix/store/kg61gdq4svvph0c4pcsf867rc
execve("/nix/store/kg61gdq4svvph0c4pcsf867r8nkbiqs7-bootstrap-tools/lib/ld-linux-riscv64-lp64d.so.1", ["/nix/store/kg61gdq4svvph0c4pcsf8"..., "/nix/store/kg61gdq4svvph0c4pcsf8"0
brk(NULL) = 0x7fff84224000
openat(AT_FDCWD, "/nix/store/kg61gdq4svvph0c4pcsf867r8nkbiqs7-bootstrap-tools/bin/gcc", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\2\0\363\0\1\0\0\0\230\312\2\0\0\0\0\0"..., 832) = 832
getpid() = 6665
writev(2, [{iov_base=" 6665:\t", iov_len=12}, {iov_base="file=", iov_len=5}, {iov_base="/nix/store/kg61gdq4svvph0c4pcsf8"..., iov_len=67}, {iov_base=" [", iov_len=2}, {iovp
) = 111
mmap(0xf000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0) = -1 EPERM (Operation not permitted)
close(3) = 0
writev(2, [{iov_base="/nix/store/kg61gdq4svvph0c4pcsf8"..., iov_len=67}, {iov_base=": ", iov_len=2}, {iov_base="error while loading shared libra"..., iov_len=36}, {iov_base=": t
) = 217
exit_group(127) = ?
+++ exited with 127 +++
| 05:56:34 |
Tristan Ross | Best I can get out of the UART atm | 05:56:46 |
Mic92 |
mmap(0xf000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0) = -1 EPERM (Operation not permitted) | 05:57:53 |
Mic92 | Now do readelf and look for suspicious addresses. | 05:58:18 |
Mic92 | 0xf000 | 05:58:33 |
Mic92 | But might not exactly the same | 05:58:49 |
Mic92 | Potentially it applied an offset already | 05:59:09 |
Tristan Ross | Program Headers:
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flags Align
PHDR 0x0000000000000040 0x000000000000f040 0x000000000000f040
0x00000000000002a0 0x00000000000002a0 R 0x8
RISCV_ATTRIBUT 0x0000000000219e92 0x0000000000000000 0x0000000000000000
0x0000000000000057 0x0000000000000000 R 0x1
GNU_STACK 0x0000000000001000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 RW 0x10
LOAD 0x0000000000000000 0x000000000000f000 0x000000000000f000
0x0000000000001000 0x0000000000001000 RW 0x1000
LOAD 0x0000000000001000 0x0000000000010000 0x0000000000010000
0x000000000020ded0 0x000000000020ded0 R E 0x1000
INTERP 0x00000000000142d0 0x00000000000232d0 0x00000000000232d0
0x000000000000005c 0x000000000000005c R 0x1
[Requesting program interpreter: /nix/store/kg61gdq4svvph0c4pcsf867r8nkbiqs7-bootstrap-tools/lib/ld-linux-riscv64-lp64d.so.1]
NOTE 0x0000000000014330 0x0000000000023330 0x0000000000023330
0x0000000000000020 0x0000000000000020 R 0x4
GNU_EH_FRAME 0x00000000001c41d8 0x00000000001d31d8 0x00000000001d31d8
0x000000000000967c 0x000000000000967c R 0x4
LOAD 0x000000000020ef58 0x000000000021ef58 0x000000000021ef58
0x000000000000af28 0x00000000000103b8 RW 0x1000
TLS 0x000000000020ef58 0x000000000021ef58 0x000000000021ef58
0x0000000000000000 0x0000000000000010 R 0x8
GNU_RELRO 0x000000000020ef58 0x000000000021ef58 0x000000000021ef58
0x00000000000080a8 0x00000000000080a8 R 0x1
DYNAMIC 0x0000000000216dd0 0x0000000000226dd0 0x0000000000226dd0
0x0000000000000230 0x0000000000000230 RW 0x8
| 05:59:14 |
Mic92 | VirtAddr looks suspicious | 06:00:09 |
Tristan Ross | Of the PHDR? | 06:01:03 |
Tristan Ross | ls works so presumably, it should look like this:
Program Headers:
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flags Align
PHDR 0x0000000000000040 0x0000000000010040 0x0000000000010040
0x0000000000000230 0x0000000000000230 R 0x8
RISCV_ATTRIBUT 0x000000000012b89a 0x0000000000000000 0x0000000000000000
0x0000000000000057 0x0000000000000000 R 0x1
GNU_STACK 0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 RW 0x10
LOAD 0x0000000000000000 0x0000000000010000 0x0000000000010000
0x000000000011c610 0x000000000011c610 R E 0x1000
INTERP 0x0000000000000270 0x0000000000010270 0x0000000000010270
0x000000000000005c 0x000000000000005c R 0x1
[Requesting program interpreter: /nix/store/kg61gdq4svvph0c4pcsf867r8nkbiqs7-bootstrap-tools/lib/ld-linux-riscv64-lp64d.so.1]
NOTE 0x00000000000002e4 0x00000000000102e4 0x00000000000102e4
0x0000000000000044 0x0000000000000044 R 0x4
GNU_EH_FRAME 0x00000000001015b0 0x00000000001115b0 0x00000000001115b0
0x00000000000030bc 0x00000000000030bc R 0x4
LOAD 0x000000000011cf68 0x000000000012df68 0x000000000012df68
0x000000000000e920 0x0000000000023ba0 RW 0x1000
GNU_RELRO 0x000000000011cf68 0x000000000012df68 0x000000000012df68
0x000000000000a098 0x000000000000a098 R 0x1
DYNAMIC 0x0000000000126dd0 0x0000000000137dd0 0x0000000000137dd0
0x0000000000000230 0x0000000000000230 RW 0x8
| 06:01:56 |
Mic92 | But i am not super familiar with virtual addresses on RISC-V to be honest. So i don't which adresses are acceptable on that architecture. You should consult the RISC-V os spec | 06:02:33 |
Tristan Ross | Oh... | 06:02:44 |
Mic92 | Maybe for now compare it with other binaries | 06:03:16 |
Mic92 | And it's also hard to read for me. You want to look at what load addresses are requested | 06:05:14 |
Mic92 | Is riscv 4k page aligned. Usually the first page should not be mapped in userspace | 06:06:27 |
Tristan Ross | When I updated bootstrap-tools on my clone, I got awk to work and it works with this:
Program Headers:
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flags Align
PHDR 0x0000000000000040 0x0000000000000040 0x0000000000000040
0x00000000000002a0 0x00000000000002a0 R 0x8
RISCV_ATTRIBUT 0x00000000000b1022 0x0000000000000000 0x0000000000000000
0x000000000000006a 0x0000000000000000 R 0x1
LOAD 0x0000000000000000 0x0000000000000000 0x0000000000000000
0x00000000000ab84c 0x00000000000ab84c R E 0x1000
GNU_STACK 0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 RW 0x10
GNU_EH_FRAME 0x0000000000098fc8 0x0000000000098fc8 0x0000000000098fc8
0x00000000000017a4 0x00000000000017a4 R 0x4
NOTE 0x00000000000ab82c 0x00000000000ab82c 0x00000000000ab82c
0x0000000000000020 0x0000000000000020 R 0x4
LOAD 0x00000000000ac848 0x00000000000ac848 0x00000000000ac848
0x00000000000047c8 0x000000000000c818 RW 0x1000
GNU_RELRO 0x00000000000ac848 0x00000000000ac848 0x00000000000ac848
0x00000000000037b8 0x00000000000037b8 R 0x1
DYNAMIC 0x00000000000af2d0 0x00000000000af2d0 0x00000000000af2d0
0x0000000000000230 0x0000000000000230 RW 0x8
INTERP 0x00000000000b2000 0x00000000000ba000 0x00000000000ba000
0x000000000000005c 0x000000000000005c R 0x1
[Requesting program interpreter: /nix/store/95y6xmfgcvgxjmba9xm6ccxxnf6i61pw-bootstrap-tools/lib/ld-linux-riscv64-lp64d.so.1]
LOAD 0x00000000000b2000 0x00000000000ba000 0x00000000000ba000
0x0000000000000060 0x0000000000000060 RW 0x1000
LOAD 0x00000000000b3000 0x00000000000bb000 0x00000000000bb000
0x00000000000019d0 0x00000000000019d0 RW 0x1000
So maybe the virt addr PHDR isn't as important
| 06:06:33 |