Bug 365750 - Valgrind fails on binary with .text section not in default place
Summary: Valgrind fails on binary with .text section not in default place
Status: REPORTED
Alias: None
Product: valgrind
Classification: Developer tools
Component: callgrind (other bugs)
Version First Reported In: 3.11.0
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Josef Weidendorfer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-07-16 18:44 UTC by janisozaur+kde
Modified: 2016-09-14 15:16 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description janisozaur+kde 2016-07-16 18:44:31 UTC
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
Comment 1 Julian Seward 2016-09-14 15:00:53 UTC
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!"
Comment 2 janisozaur+kde 2016-09-14 15:16:20 UTC
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.