Skip to content

[BOLT] Add reading support for Linux kernel exception table #83100

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

Merged
merged 1 commit into from
Mar 5, 2024

Conversation

maksfb
Copy link
Contributor

@maksfb maksfb commented Feb 27, 2024

Read Linux exception table and ignore functions with exceptions for now. Proper support requires an introduction of new control flow since some instructions with memory access can cause a control flow change.

Hence looking at disassembly or CFG with exceptions annotations is valuable for code analysis, delay marking functions with exceptions as non-simple until immediately before emitting the code.

Read Linux exception table and ignore functions with exceptions for now.
Proper support requires an introduction of new control flow since some
instructions with memory access can cause a control flow change.

Hence looking at disassembly or CFG with exceptions annotations is
valuable for code analysis, delay marking functions with exceptions as
non-simple until immediately before emitting the code.
Copy link
Member

@dcci dcci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I'd appreciate another pair of eyes in case I'm missing something @rafaelauler / @aaupov @ayermolo

uint32_t EntryID = 0;
while (Cursor && Cursor.tell() < ExceptionsSection->getSize()) {
const uint64_t InstAddress =
SectionAddress + Cursor.tell() + (int32_t)DE.getU32(Cursor);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is int in the structure mapping to int32_t everywhere? I assume this is true for every architecture in the world we support but I don't know if this is a general assumption. Nothing needs to change because I assume BOLT has this assumption baked in many other places, but I was curious anyway and wanted to point out.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume you are talking about the int in the Linux kernel structure. We support x86 kernels only (at least at this moment) and the data structure itself is architecture-specific. So it's not just the type of the field that can vary. Some architectures don't have exception table at all, others have different fields in the structure.

@maksfb maksfb merged commit ccf0c8d into llvm:main Mar 5, 2024
@maksfb maksfb deleted the gh-linux-exceptions branch March 28, 2024 17:34
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.

2 participants