GNU Binutils upgraded to version 2.39.20221117.88ac930a725
[dragora.git] / patches / binutils / 2.39 / binutils-readelf-no-sections.patch
blob728d9c0d76b54201666058be0a2eb07026b3d5d6
1 --- binutils.orig/binutils/readelf.c 2022-10-03 13:20:42.707527855 +0100
2 +++ binutils-2.39/binutils/readelf.c 2022-10-03 13:21:25.785436781 +0100
3 @@ -6357,6 +6357,13 @@ get_32bit_section_headers (Filedata * fi
4 /* PR binutils/17531: Cope with unexpected section header sizes. */
5 if (size == 0 || num == 0)
6 return false;
8 + /* The section header cannot be at the start of the file - that is
9 + where the ELF file header is located. A file with absolutely no
10 + sections in it will use a shoff of 0. */
11 + if (filedata->file_header.e_shoff == 0)
12 + return false;
14 if (size < sizeof * shdrs)
16 if (! probe)
17 @@ -6421,6 +6428,12 @@ get_64bit_section_headers (Filedata * fi
18 if (size == 0 || num == 0)
19 return false;
21 + /* The section header cannot be at the start of the file - that is
22 + where the ELF file header is located. A file with absolutely no
23 + sections in it will use a shoff of 0. */
24 + if (filedata->file_header.e_shoff == 0)
25 + return false;
27 if (size < sizeof * shdrs)
29 if (! probe)