From: Niall D. <ndo...@bl...> - 2013-05-29 20:04:35
|
> Under Linux, the first instruction executed in executable is in _start function > rather than in main function. I am wondering whether Valgrind instrument the > load/store in any other functions except main function and its subroutine (ex. > _start function). According to Valgrind paper, all memory is marked as > unaddressable except malloced. If Valgrind instrument memory check with > load/store in _start function. It may report a false-positive error. How does > Valgrind deal with this problem? I think you may misunderstand what valgrind is. Valgrind emulates a CPU. It therefore can, and does, track all reads and writes of memory across the process irrespective of what the code is. Valgrind has no concept of main being different to _start, or indeed of main, it just calls what ELF tells it to. If there are any false positives, it's either a bug in valgrind (very rare) or your code is doing something very unusual and probably should be doing it differently. The only legitimate source of false positives in memcheck I'm aware of is the magic cookie technique where one speculatively reads unknown memory locations for the presence of a magic cookie. In this situation you should not suppress the error, but you should instrument the code using valgrind's macro support to tell valgrind what you're really doing. Niall |