Search code examples
armembeddedcross-compilingvalgrindembedded-linux

Unable to cross-compile Valgrind for ARM


There are many questions similar to mine on google, I have tried them all but none of them works so I have to post this question.

I'm trying to use Valgrind to detect memory leak on some binary files, which are compiled for my device (using Processor: ARM926EJ-S rev 5 (v5l)).

Therefore, I'm trying to cross compile Valgrind using the specific toolchain for my device.

Here is my process: I'm using Valgrind 3.13.0 and Ubuntu 16

1/ cd Valgrind-3.13.0

2/ sed "s/armv7/arm/g" configure (so that it won't complain about unsupported architect).

3/ ./configure --host=arm-none-linux-gnueabi (using my specific cross compiler instead of the default on of Linux)

4/ make

The following error pops up:

error: bad value (cortex-a8) for -mcpu= switch

=> Since my device using ARM926EJ-S processor, I replace cortex-a8 with arm926ej-s of all files in Valgrin-3.13.0 folder.

Running above steps again and another error pops up:

m_dispatch/dispatch-arm-linux.S: Assembler messages:
m_dispatch/dispatch-arm-linux.S:104: Error: selected processor does not support `movw r1,#47'
m_dispatch/dispatch-arm-linux.S:105: Error: selected processor does not support `movw r2,#0'
m_dispatch/dispatch-arm-linux.S:157: Error: selected processor does not support `movw r1,#:lower16:vgPlain_stats__n_xindirs_32'
m_dispatch/dispatch-arm-linux.S:158: Error: selected processor does not support `movt r1,#:upper16:vgPlain_stats__n_xindirs_32'
m_dispatch/dispatch-arm-linux.S:165: Error: selected processor does not support `movw r1,#(((1<<15))-1)'
m_dispatch/dispatch-arm-linux.S:166: Error: selected processor does not support `movw r4,#:lower16:vgPlain_tt_fast'
m_dispatch/dispatch-arm-linux.S:169: Error: selected processor does not support `movt r4,#:upper16:vgPlain_tt_fast'
m_dispatch/dispatch-arm-linux.S:182: Error: selected processor does not support `movw r1,#:lower16:vgPlain_stats__n_xindir_misses_32'
m_dispatch/dispatch-arm-linux.S:183: Error: selected processor does not support `movt r1,#:upper16:vgPlain_stats__n_xindir_misses_32'
Makefile:3224: recipe for target 'm_dispatch/libcoregrind_arm_linux_a-dispatch-arm-linux.o' failed

What am I doing wrong?


Solution

  • ARM9 uses the old ARMv5 instruction set. From the error message, it looks like Valgrind's assembly code expects a newer ARM (ARMv7) instruction set than what your processor has.

    You therefore may be out of luck and need to port the above assembler to ARMv4 to get valgrind to work.