GNU Assembler Start of Function & basic block

Richard Henderson rth@redhat.com
Wed Oct 6 23:05:00 GMT 2010
On 10/06/2010 02:10 PM, Emílio Wuerges wrote:
> I need to know the start and end address of each basic block.
> 
> I'm planning to hack GCC to include comments in the beginning of each BB
> and then later use the assembler to find these addresses.
> 
> I think I'm good with the GCC part, but I'm lost with assembler part.
> Can someone point me where should I hook my hack?

If you do the right bit in gcc you don't need to hack the assembler at all.

        .loc  FILENO LINENO [COLUMN] [basic_block] [prologue_end] \
              [epilogue_begin] [is_stmt VALUE] [isa VALUE] \
              [discriminator VALUE]

What you need to do is hack gcc dwarf2 debug output to mark the
basic blocks via the extensions to the .loc directive.  At which
point you'll be able to find your basic block boundaries by 
reading the information stored in the .debug_line section and
documented in the dwarf specifications.


r~



More information about the Binutils mailing list