When I run my program, OpenRCT2, for which we use custom linker script[1] to move .text section around, valgrind's callgrind fails with following assertion: valgrind: m_debuginfo/debuginfo.c:552 (check_CFSI_related_invariants): Assertion 'cfsi_fits' failed This is a program compiled with -m32 on a 64-bit system. Similar case when compiling a 64-bit version on 64-bit system. It works, however, when compiled with .text section set to default on my system, then mmap-ing sections in their expected place. [1] https://github.com/OpenRCT2/OpenRCT2/blob/76cca7a/distribution/linux/ld_script_i386.xc#L54-L56
I suspect that happens because the linker script moves the .text section around but it doesn't update the Dwarf related sections accordingly. Why do you need to do such a thing? I'd say the best advice is "don't do that!"
I'm not very well-versed in ELF, and what you suggest is entirely possible. I can, however, debug with GDB just like you would expect, if that could be used as any kind of indicator. Where would I read more about that? The reason I commit such atrocities is I have to load bits of original binary into memory, which is expected at specified VMAs.