I'm trying to design a LLVM IR pass that gets some information from the LLVM IR (specifically: types used in a IR call instruction) and somehow correlate this IR-level analysis with binary-level addresses. For example, I want to know that a call
instruction (at a certain address in the final binary) is calling a function with a certain type signature.
Some observations:
call
in IR will map to a call
in machine code.In this comment, the suggested approach to a similar problem is to "inject[] some metadata that you can spot later in the executable". However, I couldn't find any information about how to make metadata survive in the binary.
You might tie the IR calls to the final calls using the debug location (which is a kind of metadata). If you make sure there is a file name, line and column for each call in IR, this hack should be possible. Cleaner solutions exist, I am sure.