Is it at all possible to find what the final address of an emitted instruction in an ELF executable is going to be from an LLVM backend? I need to be able to do this during the first pass of code emission as I’m also relying on information passed down from previous steps of compilation that are lost when simply emitting assembly or binary alone.
I imagine this might be possible if done at the linking as part of LTO. Are there any resources on how to write a pass that can executes at this point, and how to get the information I need?
Even with LTO, address assignment comes after code generation; LTO doesn’t let you know more about the binary layout at code generation time, just the full set of code present instead of a single translation unit.
So do you think within somewhere like the instruction encoder of LLVM MC I might be able to get a final address? Do you know if you still have access to machine instruction objects at this point too?