title: Correlating LLVM IR analysis with final address
body: <p>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 <code>call</code> instruction (at a certain address in the final binary) is calling a function with a certain type signature.</p>
  <p>Some observations:</p>
  <ol>
  <li>The obvious problem is that the final addresses are not available yet when the IR pass runs.</li>
  <li>While IR instruction do not map 1:1 to machine instructions, it should be relatively safe to assume that a <code>call</code> in IR will map to a <code>call</code> in machine code.</li>
  <li>One could just disassemble the binary, look at the function being called, and get its type. However, this does not work for indirect call instructions (which is why I'm trying to do this in IR).</li>
  </ol>
  <p>In <a href="https://stackoverflow.com/questions/62273918/how-can-we-get-the-program-counter-address-using-llvm-compiler#comment110151242_62273918">this comment</a>, the suggested approach to a similar problem is to &quot;inject[] some metadata that you can spot later in the executable&quot;. However, I couldn't find any information about how to make metadata survive in the binary.</p>