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

Reference external symbols from static library (PE binaries) #14

Open
avncharlie opened this issue Mar 28, 2024 · 1 comment
Open

Reference external symbols from static library (PE binaries) #14

avncharlie opened this issue Mar 28, 2024 · 1 comment

Comments

@avncharlie
Copy link

I'm attempting to write instrumentation that calls a function in a static library that I want to link while pretty-printing the instrumented IR. So far I've managed to do it like so:

  1. insert the symbol by referencing a fake library: rewriting_ctx.get_or_insert_extern_symbol('external_call', 'dummy.lib')
  2. Call gtirb-pprinter as such: gtirb-pprinter instrumented.gtirb --binary out.exe --compiler-args /link /FORCE:MULTIPLE C:\path\to\mylibrary.lib

Is there a better way to do this?

@jranieri-grammatech
Copy link
Collaborator

Unfortunately I don't think so. This is about how I would go about doing the same thing on Linux for static libraries, FWIW.

We have internal transforms that disassemble the static library to GTIRB IR, then stitches that into the target IR but in my experience that's much more hassle than it's worth (you have to deal with merging different symbol types and references, COMDATs, etc).

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

No branches or pull requests

2 participants