This is the mail archive of the binutils@sourceware.org mailing list for the binutils 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] Fix several mix up between octets and bytes in ELF program headers


On Mon, Nov 25, 2019 at 09:43:33AM +0100, Christian Eggers wrote:
> diff --git a/include/elf/internal.h b/include/elf/internal.h
> index 794c16812ee..d78014a0426 100644
> --- a/include/elf/internal.h
> +++ b/include/elf/internal.h
> @@ -86,11 +86,11 @@ typedef struct elf_internal_ehdr {
>  struct elf_internal_phdr {
>    unsigned long	p_type;			/* Identifies program segment type */
>    unsigned long	p_flags;		/* Segment flags */
> -  bfd_vma	p_offset;		/* Segment file offset */
> -  bfd_vma	p_vaddr;		/* Segment virtual address */
> -  bfd_vma	p_paddr;		/* Segment physical address */
> -  bfd_vma	p_filesz;		/* Segment size in file */
> -  bfd_vma	p_memsz;		/* Segment size in memory */
> +  bfd_vma	p_offset;		/* Segment file offset in octets */
> +  bfd_vma	p_vaddr;		/* Segment virtual address in bytes */
> +  bfd_vma	p_paddr;		/* Segment physical address in bytes */
> +  bfd_vma	p_filesz;		/* Segment size in file in octets */
> +  bfd_vma	p_memsz;		/* Segment size in memory in octets */
>    bfd_vma	p_align;		/* Segment alignment, file & memory */
>  };

I'm wondering if you would be better off leaving all the values as
octets when written to file.  There are things in the ELF spec, like
p_offset mod pagesize == p_vaddr mod pagesize, that assume p_offset
and p_vaddr have the same units.

I'm not saying you shouldn't make this change.  The ELF spec says it
"supports various processors with 8-bit bytes and either 32-bit or
64-bit architectures", so every place in the spec that says "byte"
needs some translation for your architecture anyway.  Just, have you
considered leaving all the ELF file values as octets?

-- 
Alan Modra
Australia Development Lab, IBM


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