This is the mail archive of the binutils@sources.redhat.com 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 handling of ELF objects without section header table


Hi Jakub,

On Tue, Jun 18, 2002 at 11:03:13AM +0200, Jakub Jelinek wrote:

> From this, I think the right behaviour is:
> e_shoff == 0 && e_shnum == 0 -> no sections
> e_shoff != 0 && e_shnum == 0 -> e_shnum = ((ElfW(Shdr) *)(char *)ehdrp + e_shoff)->sh_size
> 				(and if even that is 0, no sections)
> otherwise e_shnum is the number of sections.
[snipped]
> --- binutils/readelf.c.jj	Tue Jun 18 09:59:35 2002
> +++ binutils/readelf.c	Tue Jun 18 10:40:57 2002
> @@ -9711,12 +9711,15 @@ get_file_header (file)
>        elf_header.e_shstrndx  = BYTE_GET (ehdr64.e_shstrndx);
>      }
>  
> -  /* There may be some extensions in the first section header.  Don't
> -     bomb if we can't read it.  */
> -  if (is_32bit_elf)
> -    get_32bit_section_headers (file, 1);
> -  else
> -    get_64bit_section_headers (file, 1);
> +  if (elf_header.e_shoff)
> +    {

Shouldn't we check for elf_header.e_shnum (= ((ElfW(Shdr) *)(char *)ehdrp + 
e_shoff)->sh_size) too?

Elias


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