Output codegen information to data section

I’m wondering if there’s a convenient way to output a chunk of data to some data section - specifically I have a CallBrInst and I want to output the address of the next instruction after the call (which will be the return address) as a named global symbol (or otherwise make it accessable).

Is there a way to mark this information to be output? Or do I need to propagate it through machine code translation.

I know that my target will always be x86_64 on a linux machine.

CallBrInst is an IR instruction? The addresses of machine instructions won’t be knowable until codegen.

I’m not aware of any existing scheme for capturing the addresses of specific instructions. I’d expect you could define a label for the instruction after the call, and then emit the address for the label in a special section. You would need to modify codegen (probably) and MC (certainly) to make this happen.