Obtaining the actual size of basic blocks (BBs) in bytes and the number of fixups of each BB


I am working on my research using LLVM.

I need to obtain the following information at each object file during compilation, and want to store them into the new section that I define. Currently the target architecture is x86_64 with ELF format.

a) actual size of basic blocks in bytes to be emitted

b) number of fixups (adjusted in MCAssembler.cpp) that belong to each basic block

I have tried to understand the backend codes, but I was not able to get the actual size of basic blocks in either code generation or MC layer. By the time of emitting the actual bytes, I could only see the unit of the fragment without the boundary of functions and basic blocks.

I need to know how many fixups (for reference updates) reside in each basic block as well, but I could not find any link to get basic block information in MC layer.

Finally, if there is any guide to define new section (and its header), please let me know. Any direction to start with would be appreciated.

Thanks a lot for your help in advance!