From 2c4666fc263a57d5489bc7def1d87a61697da240 Mon Sep 17 00:00:00 2001 From: jakub Date: Tue, 18 Jun 2002 14:08:55 +0000 Subject: [PATCH] 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. --- bfd/ChangeLog | 7 +++++++ binutils/ChangeLog | 5 +++++ binutils/readelf.c | 15 +++++++++------ 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 813e758300..0ba7f4fabe 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,10 @@ +2002-06-18 Jakub Jelinek + + * 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 * elf32-d10v.c (elf_d10v_howto_table): Change R_D10V_10_PCREL_R, diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 26c052f2a3..2463d81eb9 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,8 @@ +2002-06-18 Jakub Jelinek + + * 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) * nm.c (print_size): New variable. Initialize to 0. diff --git a/binutils/readelf.c b/binutils/readelf.c index 095310914a..4649b9b4d0 100644 --- a/binutils/readelf.c +++ b/binutils/readelf.c @@ -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) + { + /* 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); + } return 1; } -- 2.11.0