LLVM object file creation

Hello,

I am new in the llvm project and as I was reading the llvm documentation llvm does not support binary creation, however it allows to create object files (*.o) and afterwards link them using the gcc linker.
When compiling a source file I would like to create a second binary file which contains information for each instruction inside the original object file. To be more precise as the instruction stream is written to the object file I would like to write the metadata into a second stream. I would like to ask which llvm source files should I look into to find the object file creation and writing?

Thank You

Konstantinos Parasyris.

What you are describing sounds a lot like debug info, so you might be able to find pointers there.

LLVM code generation looks like:
IR → CodeGenPrepare → SelectionDAG → MachineInstrs (MI) → MC → object file

So, if you want to get as close as possible to the actual instruction layout in the binary, you need to add logic (maybe directives) in the MC layer. You may need to pass your data down through the other layers if it isn’t already available from debug info or CFI.