Tips on MachineInstr-ELF offset correlation

Hello, here is my problem:

I was needing to correlate addresses in the object file (i.e. the offsets in the ELF file, which come when doing objdump -d a.out), with the corresponding MachineInstr.

For example, I would like something like this, as an additional output of the code generation process (from something like llvm’s llc tool):
0x401117 → MachineFunc #2, MachineBasicBlock #6, MachineInstr #3 (position-based id)

My input is an MIR file with all passes applied before x86-codegen.

Some ideas I had included, would the AsmPrinterHandler be useful here?

I was wondering, can I get some pointers on how to go about doing this? Thank you!