This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: [PATCH] Fix handling of ELF objects without section header table
- From: Elias Athanasopoulos <eathan at otenet dot gr>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: binutils at sources dot redhat dot com
- Date: Tue, 18 Jun 2002 21:10:38 +0300
- Subject: Re: [PATCH] Fix handling of ELF objects without section header table
- References: <20020618110313.A20867@sunsite.ms.mff.cuni.cz>
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