Skip to content
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

[BOLT] Ignore AArch64 markers outside their sections. #74106

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jacobbramley
Copy link
Contributor

AArch64 uses $d and $x symbols to delimit data embedded in code. However, sometimes we see $d symbols, typically in .eh_frame, with addresses that belong to different sections. These occasionally fall inside .text functions and cause BOLT to stop disassembling, which in turn causes DWARF CFA processing to fail.

As a workaround, we just ignore symbols with addresses outside the section they belong to. This behaviour is consistent with objdump and similar tools.

AArch64 uses $d and $x symbols to delimit data embedded in code.
However, sometimes we see $d symbols, typically in .eh_frame, with
addresses that belong to different sections. These occasionally fall
inside .text functions and cause BOLT to stop disassembling, which in
turn causes DWARF CFA processing to fail.

As a workaround, we just ignore symbols with addresses outside the
section they belong to. This behaviour is consistent with objdump and
similar tools.
@yota9 yota9 added the BOLT label Dec 4, 2023
@yota9 yota9 requested review from maksfb and yota9 and removed request for kbeyls December 4, 2023 07:36
@kbeyls
Copy link
Collaborator

kbeyls commented Dec 4, 2023

Thank you for posting this patch, @jacobbramley !
The code in the patch looks fine to me, but will best be reviewed by the original authors of the area of code you're changing. I'm guessing that may be @maksfb ?

Out of interest, I was also looking for an explanation of why a $d symbol could appear in .eh_frame pointing to a text section. Would you happen to have an explanation for that?

@yota9
Copy link
Member

yota9 commented Dec 4, 2023

Generally I'm not against checking the symbol sections. Maybe I would rather check this condition for all symbols and discard strange symbols with warnings, I was thinking about such approach for quite a long time, just extra "layer" of protection, not for the markers specifically. What do you think @maksfb , maybe it should be general rule for every in-section symbol?

@jacobbramley
Copy link
Contributor Author

jacobbramley commented Dec 4, 2023

Out of interest, I was also looking for an explanation of why a $d symbol could appear in .eh_frame pointing to a text section. Would you happen to have an explanation for that?

Well, I can't find any specification (or other document) that explains why that might happen, but (to my surprise) I also couldn't find a statement that symbols had to remain within their sections. I'm not ruling out that it has a special meaning, but my working theory is that it's simply a bug. I'm still working on tracking that down.

These symbols turn up reliably in Rust binaries, including the default "hello world" project, so BOLT will probably see it in the wild even if it is a bug that we later fix. Most users won't notice; the binary loads and runs fine, and objdump implementations hide the out-of-section symbols.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants