*** WARNING - DO NOT ATTEMPT THIS ***
Valgrind is a tool to help find memory-management problems in programs
The
valgrind app has only the following dependencies:
Depends (1)
musl*
*already got it from elinks/nano install in Post #3.
RUN THESE COMMANDS FROM LINUX DESKTOP:
DOWNLOAD THE REQUIRED PACKAGES:
$ cd myalpine/
$ wget
https://dl-cdn.alpinelinux.org/alpin...-3.20.0-r0.apk
$ wget
https://dl-cdn.alpinelinux.org/alpin...g-1.2.3-r5.apk
$ tar zxvf valgrind-3.20.0-r0.apk
$ mv usr/bin/valgrind scripts/
$ mkdir libexec
$ mkdir libexec/valgrind
$ mv usr/libexec/valgrind/default.supp libexec/valgrind/
$ mv usr/libexec/valgrind/memcheck-arm-linux libexec/valgrind/
$ mv usr/libexec/valgrind/vgpreload_core-arm-linux.so libexec/valgrind/
Get alternate dynamic linker/loader from Linaro toolchain.
$ cp ../gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/libc/lib/ld-2.19-2014.08-1-git.so .
NOW CONNECT YOUR KOBO TO YOUR PC:
Copy your valgrind binary from the scripts/ folder on the PC to the /mnt/onboard/.adds/koreader/scripts/ folder on the kobo.
Create a /usr/libexec folder on the Kobo.
Copy valgrind/ folder from libexec on the PC to the /mnt/onboard/.adds/ folder on the kobo.
# ln -s /mnt/onboard/.adds/valgrind/ /usr/libexec/valgrind
Copy ld-2.19-2014.08-1-git.so to root directory / of Kobo.
# valgrind /mnt/onboard/.adds/koreader/scripts/nano
(works)
# valgrind /bin/ls
Fatal error at startup:
A must-be-redirected function valgrind:
whose name matches the pattern: index
in an object with soname matching: ld-linux-armhf.so.3
was not found whilst processing
See source of problem:
https://sourceforge.net/p/valgrind/m...m/#msg30887009
# cd /lib
# ls -l ld*
-rwxr-xr-x 134412 ld-2.11.1.so
lrwxrwxrwx 13 ld-linux-armhf.so.3 -> ld-linux.so.3
lrwxrwxrwx 12 ld-linux.so.3 -> ld-2.11.1.so
-rwxr-xr-x 525980 ld-musl-armhf.so.1
Check if the stock ld-linux.so.3 includes the memcpy function:
# readelf --symbols /lib/ld-linux.so.3 | grep mem
12: 000176bc 332 FUNC WEAK DEFAULT 10 __libc_memalign@@GLIBC_2.4
Check if the alternate /ld-2.19-2014.08-1-git.so includes the memcpy function:
# readelf --symbols /ld-2.19-2014.08-1-git.so | grep memcpy
804: 00000000 0 FILE LOCAL DEFAULT ABS rtld-memcpy.os
907: 00012700 1056 FUNC LOCAL DEFAULT 11 memcpy
1097: 000132e9 16 FUNC LOCAL DEFAULT 11 __memcpy_from_thumb
**********************************************
***CRITICAL STEP***
* MAKE SURE YOU HAVE SSH CONNECTION TO KOBO ALREADY LOADED IN MEMORY *
* AND AN SFTP-CAPABLE FILEMANAGER RUNNING ON DESKTOP ABLE TO RESTORE DYNAMIC LINKER/LOADER FILE REMOTELY*
* AND AN SDCARD-BASED FILESYSTEM ON KOBO, BACKED UP
* YOU WILL BE REPLACING LINKER WHICH MAY CAUSE COMMANDS TO STOP WORKING ON KOBO *
* YOU WILL BE REPLACING LINKER WHICH MAY CAUSE COMMANDS TO STOP WORKING ON KOBO *
* YOU WILL BE REPLACING LINKER WHICH MAY CAUSE COMMANDS TO STOP WORKING ON KOBO *
Back up stock dynamic linker/loader:
# cp -P ld-linux-armhf.so.3 /
Check that it is backed up:
# ls -l /ld-linux-armhf.so.3
lrwxrwxrwx 13 /ld-linux-armhf.so.3 -> ld-linux.so.3
Copy alternate linker over the stock linker:
# cp /ld-2.19-2014.08-1-git.so ld-linux-armhf.so.3
Check if commands still work:
# pwd
/lib
* IF COMMANDS DON'T WORK, RESTORE /lib/ld-linux-armhf.so.3 FROM YOUR BACKUP USING YOUR SSH CONNECTION *
**********************************************
Now let's retry valgrind with the new linker:
# valgrind /bin/ls
(works)
On your PC recompile fbpad2 with -g option:
$ cd fbpad-eink-master/
$ source ~/koxtoolchain/refs/x-compile.sh kobo env bare
$ nano -l Makefile
Code:
1 CFLAGS += -Wall -O2 -g
$ make
Copy fbpad2 to /mnt/onboard/.adds/koreader/scripts/ folder on your Kobo.
From SSH shell run (after first running ". /korenv.sh" as was done in Post #4):
# valgrind fbpad2 -p 58 0</dev/tty1 &
<Ret>
# fbkeyboard2
Enter ALT-c and you get the shell prompt on the Kobo display.
Enter ALT-p <Ret> to see tag list.
CTRL-ALT-q to end the fbpad session.
CTRL-ALT-x to end the fbkeyboard session.
Output:
==2059== Memcheck, a memory error detector
==2059== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==2059== Using Valgrind-3.20.0 and LibVEX; rerun with -h for copyright info
==2059== Command: fbpad2 -p 58
...
==2059==
==2059== All heap blocks were freed -- no leaks are possible
==2059==
==2059== Use --track-origins=yes to see where uninitialised values come from
==2059== For lists of detected and suppressed errors, rerun with: -s
==2059== ERROR SUMMARY: 4 errors from 3 contexts (suppressed: 0 from 0)
[1]+ Segmentation fault valgrind fbpad2 -p 58 0</dev/tty1
**********************************************
***CRITICAL STEP***
* RESTORE /lib/ld-linux-armhf.so.3 FROM YOUR BACKUP USING YOUR SSH CONNECTION *
Check if commands still work:
# pwd
/lib
**********************************************