My aim is to run cross compiled valgrind on an arm emulated environment. I have cross-compiled valgrind 3.13 using the arm-linaro toolchain(http://releases.linaro.org/components/toolchain/binaries/4.9-2016.02/arm-linux-gnueabi/) with command:
- ./configure --target=arm-none-linux-gnueabi --host=armv7-none-linux-gnueabi --prefix=/home/karan/valgrind/build CFLAGS=-static CPPFLAGS=-fPIC CFLAGS=-fPIC
- make && make install
I have transferred the valgrind build folder on the docker container( docker image: https://hub.docker.com/r/arm32v7/ubuntu in directory= /root/valgrind/build) and exported the PATH environment variable as well as VALGRIND_LIB variable. After this when I try to run valgrind I get the output:
valgrind: no program specified
valgrind: Use --help for more information.
I created a simple demo file(try.cpp) which prints a string and compiled it on the docker itself with command = g++ try.cpp
//try.cpp
#include<iostream>
int main()
{
std::cout<<"HELLO";
return 0;
}
the linker used is the default one and the output of command = ldd a.out is
root@d170b9f5fc84:~# ldd a.out
libstdc++.so.6 => /lib/arm-linux-gnueabihf/libstdc++.so.6 (0xfe664000)
libgcc_s.so.1 => /lib/arm-linux-gnueabihf/libgcc_s.so.1 (0xfe63b000)
libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0xfe53d000)
libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0xfe4d4000)
/lib/ld-linux-armhf.so.3 (0xfefc5000)
However on running valgrind on this simple demo file, I get the error:
root@d170b9f5fc84:~# valgrind ./a.out
==4064== Memcheck, a memory error detector
==4064== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==4064== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==4064== Command: ./a.out
==4064==
valgrind: Fatal error at startup: a function redirection
valgrind: which is mandatory for this platform-tool combination
valgrind: cannot be set up. Details of the redirection are:
valgrind:
valgrind: A must-be-redirected function
valgrind: whose name matches the pattern: strcmp
valgrind: in an object with soname matching: ld-linux-armhf.so.3
valgrind: was not found whilst processing
valgrind: symbols from the object with soname: ld-linux-armhf.so.3
valgrind:
valgrind: Possible fixes: (1, short term): install glibc's debuginfo
valgrind: package on this machine. (2, longer term): ask the packagers
valgrind: for your Linux distribution to please in future ship a non-
valgrind: stripped ld.so (or whatever the dynamic linker .so is called)
valgrind: that exports the above-named function using the standard
valgrind: calling conventions for this platform. The package you need
valgrind: to install for fix (1) is called
valgrind:
valgrind: On Debian, Ubuntu: libc6-dbg
valgrind: On SuSE, openSuSE, Fedora, RHEL: glibc-debuginfo
valgrind:
valgrind: Note that if you are debugging a 32 bit process on a
valgrind: 64 bit system, you will need a corresponding 32 bit debuginfo
valgrind: package (e.g. libc6-dbg:i386).
valgrind:
valgrind: Cannot continue -- exiting now. Sorry.
I installed libc6-dbg ( command apt-get install libc6-dbg) but to no avail. I am still getting the same error. I thought of replacing the default linker in /lib/ directory (ld-linux-armhf.so.3 -> ld-2.31.so) with the linker provided in toolchain because it had the .symtab section but that broke the OS itself and then I couldn't run any commands on bash. Could someone tell me how to run valgrind on the arm docker.? I believe My replacement of loader is not correct or incomplete.