0

I am cross-compiling a C / C++ application to run on a Raspberry Pi 4 with the arm-rpi-4.9.3-linux-gnueabihf compiler from the Tools Github Repository on an x64 Debian Linux system running in a VM. I am having some issues with this application so I built Valgrind from source on the Raspberry Pi with GCC 8.3.0-++rpi1.

The compiler binaries I am using can be downloaded here: https://github.com/raspberrypi/tools/tree/master/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf

If I run Valgrind on the RPI I get a number of errors, many of which indicate "Invalid read of size 8". My understanding is this would be typical on 64-bit architecture (8*8 = 64) but may be misleading on this 32-bit system unless the application was accessing a 64-bit data structure. Also, running Valgrind on the same application, built for and running on an x64 system, does not identify errors at these same locations, which makes me think that either the compilation toolchain is introducing an ABI issue or that Valgrind is giving misleading error indications -- or both.

Valgrind also indicates on startup:

--3451-- Arch and hwcaps: ARM, LittleEndian, ARMv8-neon-vfp --3451-- Page sizes: currently 4096, max supported 4096

However $ uname -m indicates: arm7l, which I understand to be 32 bit (and definitely not ARMv8).

Can anyone provide any guidance on what might be going wrong here?

Thanks!

vasadia
  • 366
  • 5
  • 8
FooAnon
  • 566
  • 1
  • 4
  • 11
  • Code can try reading 8 bytes on any architecture so I don't see the basis for your conclusion – M.M Aug 31 '21 at 23:42
  • Sure, I'm not disputing that. I do think it's odd however that Valgrind doesn't identify these same errors for the same application, built from the same source code, running on a different architecture. – FooAnon Aug 31 '21 at 23:45
  • according to google, the CPU is ARMv8 (64-bit) but if you have installed an OS with 32-bit kernel, it will report as ARMv7. https://raspberrypi.stackexchange.com/questions/101215/ etc – M.M Aug 31 '21 at 23:48
  • Yes I get that. Presumably then the preinstalled version of GCC that ships with the Raspian image would compile 32-bit applications correct? – FooAnon Sep 01 '21 at 00:20
  • 1
    On most platforms you can force gcc to compile for 32bit by using "-m32" flag. You also can use the command "file " to see which kind of binary type you have. There is really no reason to believe you have 64 bit apps only because you see some valgrind problems. – Klaus Sep 01 '21 at 08:06

0 Answers0