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] Add binary introspection/JIT manager #81346

Open
wants to merge 1 commit into
base: users/rafaelauler/bolt-logging-pr
Choose a base branch
from

Conversation

rafaelauler
Copy link
Contributor

Add a class that allows a process to introspect or investigate itself by disassembling its memory contents just-in-time with BOLT. An example is shown in a new unittest binary.

This leverages the new ability to use BOLT as a library instead of as a regular executable that processes input binaries, demonstrating how to use BOLT as a library.

Add a class that allows a process to introspect or investigate itself
by disassembling its memory contents just-in-time with BOLT. An
example is shown in a new unittest binary.

This leverages the new ability to use BOLT as a library instead of as
a regular executable that processes input binaries, demonstrating how
to use BOLT as a library.
@rafaelauler
Copy link
Contributor Author

Depends on #81082

Comment on lines +33 to +34
/// Allows a process to instrospect itself by running BOLT to disassemble its
/// its own address space.
Copy link
Contributor

Choose a reason for hiding this comment

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

introspect

// Analyze fib function in this binary
// Disassemble 63 bytes
uint64_t Address = reinterpret_cast<uint64_t>(&fib);
StringRef Data = StringRef(reinterpret_cast<const char *>(&fib), 63);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should JITRewriter expose symbol size so users use it directly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The rewriter object will only get knowledge about the symbol size after a call to to registerJITFunction. Not sure if I answered the question, but does it make sense to you? The user calling registerJITSection function will first make a section visible to the Rewriter, and then the user can partition this section in different functions using registerJITFunction, so the user passes the size down to the rewriter instead of the opposite.

@aaupov
Copy link
Contributor

aaupov commented Mar 31, 2024

I split out createBinaryContext change into #87172 to facilitate this review.

return Error::success();
}

Error JITRewriteInstance::disassembleFunctions() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe that this and other functions are common across *RewriteInstance classes. Is it worth defining a BaseRewriteInstance class and providing them there?

@aaupov aaupov changed the base branch from users/rafaelauler/bolt-logging-pr to main March 31, 2024 05:02
@aaupov aaupov requested a review from ayermolo as a code owner March 31, 2024 05:02
@aaupov aaupov changed the base branch from main to users/rafaelauler/bolt-logging-pr March 31, 2024 05:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants