[patch] Code cleanup: Simplify __libdwfl_report_elf
Mark Wielaard
mjw at redhat.com
Mon Nov 19 12:43:48 UTC 2012
On Sat, 2012-10-27 at 23:03 +0200, Jan Kratochvil wrote:
> diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
> index bdd9440..83bdf46 100644
> --- a/libdwfl/ChangeLog
> +++ b/libdwfl/ChangeLog
> @@ -1,3 +1,8 @@
> +2012-10-27 Jan Kratochvil <jan.kratochvil at redhat.com>
> +
> + * dwfl_report_elf.c (__libdwfl_report_elf): Simplify START and BIAS
> + calculation.
> +
> 2012-10-17 Jan Kratochvil <jan.kratochvil at redhat.com>
>
> * dwfl_module_getdwarf.c (mod_verify_build_id): New function with code
> diff --git a/libdwfl/dwfl_report_elf.c b/libdwfl/dwfl_report_elf.c
> index 35d9f48..174ce7c 100644
> --- a/libdwfl/dwfl_report_elf.c
> +++ b/libdwfl/dwfl_report_elf.c
> @@ -183,11 +183,11 @@ __libdwfl_report_elf (Dwfl *dwfl, const char *name, const char *file_name,
> address_sync = ph->p_vaddr + ph->p_memsz;
> if ((base & (ph->p_align - 1)) != 0)
> base = (base + ph->p_align - 1) & -ph->p_align;
> - start = base + (ph->p_vaddr & -ph->p_align);
> + start = base + vaddr;
Since just one line before there is a:
vaddr = ph->p_vaddr & -ph->p_align;
this is obviously equivalent.
> break;
> }
> }
> - bias = start - vaddr;
> + bias = base;
And so this also is mathematically equivalent.
Except if we would never see a PT_LOAD segment.
But for ET_DYN we will always see one.
So this looks correct to me.
Thanks,
Mark
More information about the elfutils-devel
mailing list