This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: GNU Assembler Start of Function & basic block
On Wed, Oct 6, 2010 at 6:05 PM, Richard Henderson <rth@redhat.com> wrote:
> 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~
>
At the risk of merely cheering on Richard, I also don't think you want
to hack the assembler. You want to do this symbolically and then let
the assembler worry about addresses.
See this discussion
http://sourceware.org/ml/binutils/2010-06/msg00166.html for reasons.
--
Quentin