Search code examples
exceptionmemoryruntimevalgrind

check if memory access is aligned


how can I check if all memory access in a programm is aligned? valgrind has no option to check it. Is there another tool? could I run the Software in a vm and have a checker there?

Background: I have a big program and I know that there are unaligned mem accesses. I tried to find all them. My main issue is that the hardware that this software will run on will generate hardware exceptions if a memory access is not aligned.


Solution

  • After some months I found two solutions.

    1. Enable alignment check for x86/64 (more info see here https://stackoverflow.com/a/17748435/3748215). But be careful the stdlib is full with unalinged mem accesses on x86.

    2. Cross compile to mips64 and use qemu-mips64 to debug.