-
Notifications
You must be signed in to change notification settings - Fork 11.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
perf record --call-graph dwarf does not support ld.lld's default --rosegment -z noseparate-code layout #53156
Comments
I ran into this same issue: |
For what it's worth I tested |
I think Linux perf does not support ld.lld's default It seems to support ld.lld's In addition, it seems to work with ld.lld's
It seems that for So I wanted to suggest that you ask on linux-perf-users and found that you had posted https://lore.kernel.org/linux-perf-users/CAOBGo4zjkcX=ZQm1uYRDe9EjYqsTCyZY-Gf1C4XqMNYGFCcF+Q@mail.gmail.com/T/#u |
I've been poking at this in various ways, I think the bug is actually in libunwind. Here are the mmaps that perf sees:
so that's 3 1 page mmaps at 0x200000, 0x201000 and 0x202000 but notice that the offset (after the
The perf code tries to make the segbase value holding the .eh_frame_hdr offset relative to the code in .text creating an address in the 0x201000 range, not 0x200000. Adjusting this for just the a.out case is sufficient to get correct stack traces dynamically and statically linked. The problem is that detected the a.out case is something I've hacked together:
So the question is what's the correct way to set up segbase (and the very related table_data)? Looking at libunwind there appears to be assumptions about segbase being .text relative and here but for ldd the .eh_frame_hdr is in a different section. I think libunwind can be made to work if it uses ELF section information rather then arithmetic on offsets, but fixing libunwind is a project bigger than what I wanted to take on. |
My change as a patch: |
Fixed for Linux 5.19 (see ClangBuiltLinux/linux#1646) |
I don't know if this is a bug in lld, perf, or libunwind, only that it doesn't happen with ld: when I link with lld, perf DWARF stack traces are incomplete. In a more complex application, this leads to stack traces being much shorter (and thus less helpful) than when linking with ld, but the following MWE demonstrates a difference in at least the
_start
symbol:The text was updated successfully, but these errors were encountered: