[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v5] libelf: rewrite symtab/strtab loading



>>> On 01.03.16 at 12:59, <roger.pau@xxxxxxxxxx> wrote:
> Changes since v4:
>  - Add a define that contains the number of sections.
>  - Improve the comment to describe the memory layout.
>  - Check that the sh_link field is 0 < sh_link < e_shnum.
>  - Simplify some of the logic, since the SYMTAB section is already
>    discovered by elf_init and it's handler stored in elf->sym_tab.

Well, this was a nice idea, but ...

> @@ -164,101 +169,248 @@ void elf_parse_bsdsyms(struct elf_binary *elf, 
> uint64_t pstart)
>      sz = sizeof(uint32_t);
>  
>      /* Space for the elf and elf section headers */
> -    sz += (elf_uval(elf, elf->ehdr, e_ehsize) +
> -           elf_shdr_count(elf) * elf_uval(elf, elf->ehdr, e_shentsize));
> +    sz += elf_uval(elf, elf->ehdr, e_ehsize) +
> +          ELF_BSDSYM_SECTIONS * elf_uval(elf, elf->ehdr, e_shentsize);
>      sz = elf_round_up(elf, sz);
>  
> +
>      /* Space for the symbol and string tables. */
> -    for ( i = 0; i < elf_shdr_count(elf); i++ )
> +    sh_link = elf_uval(elf, elf->sym_tab, sh_link);
> +    if ( sh_link == SHN_UNDEF || sh_link >= elf_shdr_count(elf) )

... this check then really ought to be moved there (as I now see
in the previous version you likely simply copied what was there).

Everything else looks fine to me now.

Jan


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.