This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 1/2] libdwfl: elf_from_remote_memory should use pagesize, not p_align.


On Mon, 03 Mar 2014 15:31:27 +0100, Mark Wielaard wrote:
> --- a/libdwfl/elf-from-memory.c
> +++ b/libdwfl/elf-from-memory.c
[...]
> @@ -195,21 +200,28 @@ elf_from_remote_memory (GElf_Addr ehdr_vma,
>    bool found_base = false;
>    switch (ehdr.e32.e_ident[EI_CLASS])
>      {

The return value could be documented.

> -      inline void handle_segment (GElf_Addr vaddr, GElf_Off offset,
> -				  GElf_Xword filesz, GElf_Xword align)
> +      inline bool handle_segment (GElf_Addr vaddr, GElf_Off offset,
> +				  GElf_Xword filesz, GElf_Xword palign)
>  	{
> -	  GElf_Off segment_end = ((offset + filesz + align - 1) & -align);
> +	  /* Sanity check the alignment requirements.  */
> +	  if ((palign & (pagesize - 1)) != 0
> +	      || ((vaddr - offset) & (palign - 1)) != 0)
> +	    return true;
> +
> +	  GElf_Off segment_end = ((offset + filesz + pagesize - 1)
> +				  & -pagesize);
>  
>  	  if (segment_end > (GElf_Off) contents_size)
>  	    contents_size = segment_end;
>  
> -	  if (!found_base && (offset & -align) == 0)
> +	  if (!found_base && (offset & -pagesize) == 0)
>  	    {
> -	      loadbase = ehdr_vma - (vaddr & -align);
> +	      loadbase = ehdr_vma - (vaddr & -pagesize);
>  	      found_base = true;
>  	    }
>  
>  	  segments_end = offset + filesz;
> +	  return false;
>  	}
>  
>      case ELFCLASS32:

I agree with the patch.


Thanks,
Jan

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]