[Patch AArch64] gprof support for AArch64
Marcus Shawcroft
marcus.shawcroft@arm.com
Wed May 22 08:26:00 GMT 2013
On 21/05/13 15:22, Venkataramanan Kumar wrote:
> +/* Opcode of the "bl" and "b" instructions. */
> +#define BRANCHANDLINK (0x94000000)
> +#define BRANCH (0x14000000)
> +
> +void aarch64_find_call (Sym *, bfd_vma, bfd_vma);
> +
> +void
> +aarch64_find_call (Sym *parent, bfd_vma p_lowpc, bfd_vma p_highpc)
> +{
> + bfd_vma pc, dest_pc, offset;
> + unsigned int insn;
> + Sym *child;
> +
> + DBG (CALLDEBUG, printf ("[find_call] %s: 0x%lx to 0x%lx\n",
> + parent->name, (unsigned long) p_lowpc,
> + (unsigned long) p_highpc));
> +
> + for (pc = p_lowpc; pc < p_highpc; pc += 4)
> + {
> +
> + insn = bfd_get_32 (core_bfd, ((unsigned char *) core_text_space
> + + pc - core_text_sect->vma));
> +
> + if (((insn & 0xfc000000) == BRANCHANDLINK)
> + ||((insn & 0xfc000000) == BRANCH))
> + {
The encoding for the branch instruction is:
31 30 29 28 27 26 25 .. 0
L 0 0 1 0 1 imm26
.. where L is the link flag that distinguishes between BRANCH and
BRANCHANDLINK, therefore the above can be written as:
#define BRANCH_MASK 0x7c000000
#define BRANCH_PATTERN 0x14000000
(insn & BRANCH_MASK) == BRANCH_PATTERN
/Marcus
More information about the Binutils
mailing list