7

I cross compiled Valgrind (http://valgrind.org/downloads/valgrind-3.8.1.tar.bz2) for ARM using the following commands with the Linaro Toolchain on my Ubuntu 10.04 host ( I am using Buildroot ):

export PATH=$PATH:/home/user/toolchain/linaro/bin
CC=arm-linux-gnueabi-gcc CFLAGS=-I/home/user/toolchain/linaro/arm-linux-gnueabi/libc/usr/include LDFLAGS=-L/home/user/toolchain/linaro/arm-linux-gnueabi/libc/usr/lib ./configure --prefix=/opt/valgrind --host=armv7-none-linux-gnueabi --target=arm-none-linux-gnueabi --build=i386-ubuntu-linux
make
sudo make install

When I copy the binaries to my ARM target board, I get the following error:

==413== Memcheck, a memory error detector
==413== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==413== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==413== Command: /home/user/testApp
==413== 

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:      memcpy
valgrind:  in an object with soname matching:   ld-linux.so.3
valgrind:  was not found whilst processing
valgrind:  symbols from the object with soname: ld-linux.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:  Cannot continue -- exiting now.  Sorry.

My Linaro Toolchain Version is:

gcc version 4.7.1 20120402 (prerelease) (crosstool-NG linaro-1.13.1-2012.04-20120426 - Linaro GCC 2012.04) 

I've searched around on Google but cannot find a solution to this. How can I get Valgrind to work on my target board? I use Buildroot to build my system but libc6-dbg is not a package I can find in the build system. Is there some directory or files I need to copy from the toolchain sysroot? Thanks -

The command I am using to run Valgrind is shown here:

# which valgrind
/usr/bin/valgrind
# valgrind /home/user/MyQtApp
==216== Memcheck, a memory error detector
...
...
PhilBot
  • 748
  • 18
  • 85
  • 173

4 Answers4

6

So you are using Buildroot or OpenEmbedded to build your Libc?

If it is OE then you should have libc6-dbg package available in local repository (TMPDIR/deploy/ipk). Or add "dbg-pkgs" into IMAGE_FEATURES and rebuild your image.

Glibc 2.12 shows that you are using old version of OpenEmbedded. But even this should give you libc6-dbg package.

Can not help with Buildroot as never used it.

  • Thanks for the answer - I am actually using Buildroot though and edited my question to make that clear. Hopefully your answer will help others with this issue though. – PhilBot Dec 03 '12 at 17:30
5

I've been facing the same issue, and found a solution. Thus in case someone faces it also, here is how I made things happened : The reason why Valgrind can't debug the application is the missing symbols in C libraries. While building buildroot with an external toolchain (Linaro), we can find the non stripped C libraries in Linaro tree. in arm-linux-gnueabihf\libc\lib\arm-linux-gnueabihf folder, you will find the non stripped libraries. Simply copy the non stripped files on your target .. That's it. Hope this will help others.

  • How did you copy the non-stripped files to the target? When I copy them over it breaks the OS. Or are you copying them to a separate location and changing LD_LIBRARY_PATH? – Fred Oct 26 '17 at 17:13
  • @Fred you have to do this in two steps. First upload `ld-2.19-2014.08.so` and `libc-2.19-2014.08.so` (versions from my system) to the other place. Then move them, overwriting the old ones. In my case it worked. – Nabuchodonozor Oct 14 '21 at 12:01
1

You need librairies unstripped in your target.

2 ways to do it.

in your buildroot config:

1- make an unstripped system: BR2_STRIP_none=y It will make a very big target image

2- unstrip only the librairie folder. BR2_STRIP_EXCLUDE_DIRS="lib"

David Bonnin
  • 302
  • 1
  • 13
  • I am using an external toolchain ( Linaro ) and if I try to switch out the ld-*.so on my board I get a kernel panic when rebooting. Buildroot is not building my toolchain so I can't make compatible /lib binaries to boot with that are unstripped by using this method. – PhilBot Feb 14 '13 at 21:34
0

Sorry I am giving you a link to the package I did not use by myself, but hope it's gonna work:

https://launchpad.net/ubuntu-leb/oneiric/armel/libc6-dbg

Oleksandr Kravchuk
  • 5,963
  • 1
  • 20
  • 31
  • Thanks for the suggestion - I downloaded the .deb and extracted it's contents to my /lib directory on the target board. However, my board won't boot now. I watch TeraTerm and the kernel boots but it just hangs after loading the kernel. There must be some sort of incompatibility here. – PhilBot Nov 19 '12 at 13:56
  • 1
    are you sure it's enough to just extract package? there could be some installation scripts which perform some necessary set-up, etc... – Oleksandr Kravchuk Nov 19 '12 at 16:13