mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-04 05:48:20 +08:00
binutils/
* readelf.c (get_file_header): Only read the first section header if e_shoff is non-zero. bfd/ * elfcode.h (elf_object_p): Sanity check eh_shoff == 0 implies e_shnum == 0. Only read the first section header if e_shoff is non-zero. Don't consider e_shstrndx if there are no sections.
This commit is contained in:
@ -1,3 +1,10 @@
|
|||||||
|
2002-06-18 Jakub Jelinek <jakub@redhat.com>
|
||||||
|
|
||||||
|
* elfcode.h (elf_object_p): Sanity check eh_shoff == 0 implies
|
||||||
|
e_shnum == 0.
|
||||||
|
Only read the first section header if e_shoff is non-zero.
|
||||||
|
Don't consider e_shstrndx if there are no sections.
|
||||||
|
|
||||||
2002-06-17 Tom Rix <trix@redhat.com>
|
2002-06-17 Tom Rix <trix@redhat.com>
|
||||||
|
|
||||||
* elf32-d10v.c (elf_d10v_howto_table): Change R_D10V_10_PCREL_R,
|
* elf32-d10v.c (elf_d10v_howto_table): Change R_D10V_10_PCREL_R,
|
||||||
|
@ -624,6 +624,10 @@ elf_object_p (abfd)
|
|||||||
if (i_ehdrp->e_shentsize != sizeof (x_shdr) && i_ehdrp->e_shnum != 0)
|
if (i_ehdrp->e_shentsize != sizeof (x_shdr) && i_ehdrp->e_shnum != 0)
|
||||||
goto got_wrong_format_error;
|
goto got_wrong_format_error;
|
||||||
|
|
||||||
|
/* Further sanity check. */
|
||||||
|
if (i_ehdrp->e_shoff == 0 && i_ehdrp->e_shnum != 0)
|
||||||
|
goto got_wrong_format_error;
|
||||||
|
|
||||||
ebd = get_elf_backend_data (abfd);
|
ebd = get_elf_backend_data (abfd);
|
||||||
|
|
||||||
/* Check that the ELF e_machine field matches what this particular
|
/* Check that the ELF e_machine field matches what this particular
|
||||||
@ -677,25 +681,28 @@ elf_object_p (abfd)
|
|||||||
/* Remember the entry point specified in the ELF file header. */
|
/* Remember the entry point specified in the ELF file header. */
|
||||||
bfd_set_start_address (abfd, i_ehdrp->e_entry);
|
bfd_set_start_address (abfd, i_ehdrp->e_entry);
|
||||||
|
|
||||||
/* Seek to the section header table in the file. */
|
if (i_ehdrp->e_shoff != 0)
|
||||||
if (bfd_seek (abfd, (file_ptr) i_ehdrp->e_shoff, SEEK_SET) != 0)
|
{
|
||||||
goto got_no_match;
|
/* Seek to the section header table in the file. */
|
||||||
|
if (bfd_seek (abfd, (file_ptr) i_ehdrp->e_shoff, SEEK_SET) != 0)
|
||||||
|
goto got_no_match;
|
||||||
|
|
||||||
/* Read the first section header at index 0, and convert to internal
|
/* Read the first section header at index 0, and convert to internal
|
||||||
form. */
|
form. */
|
||||||
if (bfd_bread ((PTR) & x_shdr, (bfd_size_type) sizeof x_shdr, abfd)
|
if (bfd_bread ((PTR) & x_shdr, (bfd_size_type) sizeof x_shdr, abfd)
|
||||||
!= sizeof (x_shdr))
|
!= sizeof (x_shdr))
|
||||||
goto got_no_match;
|
goto got_no_match;
|
||||||
elf_swap_shdr_in (abfd, &x_shdr, &i_shdr);
|
elf_swap_shdr_in (abfd, &x_shdr, &i_shdr);
|
||||||
|
|
||||||
/* If the section count is zero, the actual count is in the first
|
/* If the section count is zero, the actual count is in the first
|
||||||
section header. */
|
section header. */
|
||||||
if (i_ehdrp->e_shnum == SHN_UNDEF)
|
if (i_ehdrp->e_shnum == SHN_UNDEF)
|
||||||
i_ehdrp->e_shnum = i_shdr.sh_size;
|
i_ehdrp->e_shnum = i_shdr.sh_size;
|
||||||
|
|
||||||
/* And similarly for the string table index. */
|
/* And similarly for the string table index. */
|
||||||
if (i_ehdrp->e_shstrndx == SHN_XINDEX)
|
if (i_ehdrp->e_shstrndx == SHN_XINDEX)
|
||||||
i_ehdrp->e_shstrndx = i_shdr.sh_link;
|
i_ehdrp->e_shstrndx = i_shdr.sh_link;
|
||||||
|
}
|
||||||
|
|
||||||
/* Allocate space for a copy of the section header table in
|
/* Allocate space for a copy of the section header table in
|
||||||
internal form. */
|
internal form. */
|
||||||
@ -751,7 +758,7 @@ elf_object_p (abfd)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i_ehdrp->e_shstrndx)
|
if (i_ehdrp->e_shstrndx && i_ehdrp->e_shoff)
|
||||||
{
|
{
|
||||||
if (! bfd_section_from_shdr (abfd, i_ehdrp->e_shstrndx))
|
if (! bfd_section_from_shdr (abfd, i_ehdrp->e_shstrndx))
|
||||||
goto got_no_match;
|
goto got_no_match;
|
||||||
@ -789,7 +796,7 @@ elf_object_p (abfd)
|
|||||||
bfd_section_from_shdr with it (since this particular strtab is
|
bfd_section_from_shdr with it (since this particular strtab is
|
||||||
used to find all of the ELF section names.) */
|
used to find all of the ELF section names.) */
|
||||||
|
|
||||||
if (i_ehdrp->e_shstrndx != 0)
|
if (i_ehdrp->e_shstrndx != 0 && i_ehdrp->e_shoff)
|
||||||
{
|
{
|
||||||
unsigned int num_sec;
|
unsigned int num_sec;
|
||||||
|
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
2002-06-18 Jakub Jelinek <jakub@redhat.com>
|
||||||
|
|
||||||
|
* readelf.c (get_file_header): Only read the first section header if
|
||||||
|
e_shoff is non-zero.
|
||||||
|
|
||||||
2002-06-15 H.J. Lu (hjl@gnu.org)
|
2002-06-15 H.J. Lu (hjl@gnu.org)
|
||||||
|
|
||||||
* nm.c (print_size): New variable. Initialize to 0.
|
* nm.c (print_size): New variable. Initialize to 0.
|
||||||
|
@ -9711,12 +9711,15 @@ get_file_header (file)
|
|||||||
elf_header.e_shstrndx = BYTE_GET (ehdr64.e_shstrndx);
|
elf_header.e_shstrndx = BYTE_GET (ehdr64.e_shstrndx);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* There may be some extensions in the first section header. Don't
|
if (elf_header.e_shoff)
|
||||||
bomb if we can't read it. */
|
{
|
||||||
if (is_32bit_elf)
|
/* There may be some extensions in the first section header. Don't
|
||||||
get_32bit_section_headers (file, 1);
|
bomb if we can't read it. */
|
||||||
else
|
if (is_32bit_elf)
|
||||||
get_64bit_section_headers (file, 1);
|
get_32bit_section_headers (file, 1);
|
||||||
|
else
|
||||||
|
get_64bit_section_headers (file, 1);
|
||||||
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user