This is the mail archive of the
elfutils-devel@sourceware.org
mailing list for the elfutils project.
Re: [PATCH] readelf: When highpc is in constant form also print as address.
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: elfutils-devel at lists dot fedorahosted dot org
- Date: Tue, 26 Mar 2013 07:58:25 +0100
- Subject: Re: [PATCH] readelf: When highpc is in constant form also print as address.
On Mon, 25 Mar 2013 21:23:26 +0100, Mark Wielaard wrote:
> @@ -5437,7 +5438,19 @@ attr_callback (Dwarf_Attribute *attrp, void *arg)
> if (cbargs->silent)
> break;
>
> - if (valuestr == NULL)
> + /* When highpc is in constant form it is relative to lowpc.
> + In that case also show the address. */
> + Dwarf_Addr highpc;
> + if (attr == DW_AT_high_pc && (dwarf_highpc (cbargs->die, &highpc) == 0))
> + {
> + char *a = format_dwarf_addr (cbargs->dwflmod, cbargs->addrsize,
> + highpc - 1, highpc);
That "- 1" is a bug:
DWARF-4.0:
If the value of the DW_AT_high_pc is of class address, it is the relocated
address of the first location past the last instruction associated with the
entity; if it is of class constant, the value is an unsigned integer offset
which when added to the low PC gives the address of the first location past
the last instruction associated with the entity.
gcc/dwarf2out.c:
case dw_val_class_high_pc:
dw2_asm_output_delta (DWARF2_ADDR_SIZE, AT_lbl (a),
get_AT_low_pc (die), "DW_AT_high_pc");
gdb/dwarf2read.c:
if (attr_high->form == DW_FORM_addr
|| attr_high->form == DW_FORM_GNU_addr_index)
high = DW_ADDR (attr_high);
else
high = low + DW_UNSND (attr_high);
I see no + 1 or -1 there.
low_pc (addr) 0x0000000000400530 <main>
high_pc (data8) 32 (0x000000000040054f <main+0x1f>)
0000000000400530 <main>:
main():
400530: 55 push %rbp
[...]
40054e: c9 leaveq
40054f: c3 retq
0000000000400550 <__libc_csu_init>:
vs. when build with FSF GCC 4.7:
low_pc (addr) 0x000000000040051c <main>
high_pc (addr) 0x000000000040053c
000000000040051c <main>:
40051c: 55 push %rbp
[...]
40053a: c9 leaveq
40053b: c3 retq
40053c: 0f 1f 40 00 nopl 0x0(%rax)
Thanks,
Jan