Building proceeds until
===== (Note "-m32")
$ gcc -m64 ... -static ... -m32 -o vgpreload_core-arm-linux.so \
vgpreload_core_arm_linux_so_preloaded.o
ld.lld: error: unable to find library -lc
=====
which I workaround by running "gcc -v ...", to get the command line,
then manually running the 'ld' without the "-lc". So gcc adding
"-lc" was not necessary?
What is the full text of the line for linking vgpreload_core-arm-linux.so?
Moving the old outputs out of the way (vgpreload_core-arm-linux.so.save
and vgpreload_core-arm64-linux.so.save), and adding "-v" to what "make"
says when run from directory 'coregrind':
=====
$ gcc -v -m32 -O2 -g -Wall -Wmissing-prototypes -Wshadow -Wpointer-arith
-Wstrict-prototypes -Wmissing-declarations -Wno-unused-result
-Wcast-align -Wcast-qual -Wwrite-strings -Wempty-body -Wformat
-Wformat-signedness -Wformat-security -Wignored-qualifiers
-Wenum-conversion -finline-functions -fno-stack-protector
-fno-strict-aliasing -fno-builtin -Wno-cast-align -Wno-self-assign
-Wno-tautological-compare -O -g -fno-omit-frame-pointer
-fno-strict-aliasing -fpic -fno-builtin -nodefaultlibs -shared
-Wl,-z,interpose,-z,initfirst -nostdlib -m32 -o
vgpreload_core-arm-linux.so vgpreload_core_arm_linux_so-vg_preloaded.o
clang version 19.1.5
Target: arm-unknown-linux-android24
Thread model: posix
InstalledDir: /data/data/com.termux/files/usr/bin
"/data/data/com.termux/files/usr/bin/ld.lld"
--sysroot=/data/data/com.termux/files -EL -z now -z relro -z
max-page-size=4096 -X --hash-style=gnu
-rpath=/data/data/com.termux/files/usr/arm-linux-androideabi/lib
--eh-frame-hdr -m armelf_linux_eabi -shared -o
vgpreload_core-arm-linux.so
-L/data/data/com.termux/files/usr/arm-linux-androideabi/lib
-L/system/lib -z interpose -z initfirst
vgpreload_core_arm_linux_so-vg_preloaded.o
=====
and it succeeded (no complaint). So I don't know where "-lc"
came from the first time.
I also ran that gcc command under "strace -f -e trace=open,openat -o
strace.out" to see what filenames the linker was trying.
The strace gave 212 lines that all were 'openat',
and applying "grep libc" yields
=====
22993 openat(AT_FDCWD, "/data/data/com.termux/files/usr/lib/libc.so",
O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
22993 openat(AT_FDCWD, "/system/lib64/libc.so", O_RDONLY|O_CLOEXEC) = 4
22993 openat(AT_FDCWD,
"/data/data/com.termux/files/usr/lib/libclang-cpp.so",
O_RDONLY|O_CLOEXEC) = 5
22993 openat(AT_FDCWD,
"/data/data/com.termux/files/usr/lib/libc++_shared.so",
O_RDONLY|O_CLOEXEC) = 7
22993 openat(AT_FDCWD,
"/dev/__properties__/u:object_r:libc_debug_prop:s0",
O_RDONLY|O_NOFOLLOW|O_CLOEXEC) = 3
22993 openat(AT_FDCWD, "/system/lib64/libc++.so", O_RDONLY|O_CLOEXEC) = 4
22994 openat(AT_FDCWD, "/data/data/com.termux/files/usr/lib/libc.so",
O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
22994 openat(AT_FDCWD, "/system/lib64/libc.so", O_RDONLY|O_CLOEXEC) = 4
22994 openat(AT_FDCWD,
"/data/data/com.termux/files/usr/lib/libc++_shared.so",
O_RDONLY|O_CLOEXEC) = 8
22994 openat(AT_FDCWD,
"/dev/__properties__/u:object_r:libc_debug_prop:s0",
O_RDONLY|O_NOFOLLOW|O_CLOEXEC) = 3
22994 openat(AT_FDCWD, "/system/lib64/libc++.so", O_RDONLY|O_CLOEXEC) = 4
=====
=====
$ cd coregrind
$ ./valgrind
error: "./valgrind": executable's TLS segment is underaligned: \
alignment is 8 (skew 0), needs to be at least 64 for ARM64 Bionic
Aborted
$ echo $?
134 ## error 6 (134 - 128) ENXIO
$
=====
So now it's time to get the linker script from "ld --verbose ...",
then make TLS 64-byte aligned. To be continued ...
Do the Google/Android folks have any Valgrind patches for these issues?
I ran "ld --verbose > android.lds" [notice not the same as 'ld.lld',
which did not recognize '--verbose'],
lopped off the prefix and suffix lines marked by "==========",
and changed one line to ".tdata : align(64)". Then
adding "-T android.lds" to the linker command line that creates
'valgrind', and applying "readelf --segments" gave
=====
TLS 0x000000000006c000 0x000000000046c000 0x000000000046c000
0x0000000000000008 0x0000000000000008 R 0x40
=====
which did achieve 64-byte alignment in the Elf64_Phdr for TLS.
But 'vagrind' still won't run:
=====
$ gdb -q ./valgrind
Reading symbols from ./valgrind...
(gdb) x/5i _start ## disassemble from entry point
0x4003ec <_start>: bti j ## legal target for indirect branch
0x4003f0 <_start+4>: mov x29, #0x0 // #0
0x4003f4 <_start+8>: mov x30, #0x0 // #0
0x4003f8 <_start+12>: mov x0, sp
0x4003fc <_start+16>: b 0x400400 <_start_main>
(gdb) run
Starting program:
/data/data/com.termux/files/home/valgrind/coregrind/valgrind
During startup program terminated with signal SIGSEGV, Segmentation fault.
(gdb) info proc
No current process: you must name one.
=====
and the process is empty: no registers. So Android kernel refused
to perform the 'execve'. Must be the layout of PT_LOAD, or the
Section table, or the symbol table, or being "-static" (no shared
libraries), or ...
_______________________________________________
Valgrind-users mailing list
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users