summaryrefslogtreecommitdiff
path: root/gnu/usr.bin/binutils-2.17
diff options
context:
space:
mode:
authorPhilip Guenther <guenther@cvs.openbsd.org>2018-12-06 18:59:32 +0000
committerPhilip Guenther <guenther@cvs.openbsd.org>2018-12-06 18:59:32 +0000
commitc2e91ccaea6345c7f83af0ebfb07d0fbb0fe7749 (patch)
treeba1b5f76915222e5d2983a2e5a70fcf209070a7b /gnu/usr.bin/binutils-2.17
parent9d1f72911beff6dda6dd3a7aae57a8cea67ef095 (diff)
Core files with >65535 sections have to use PN_XNUM and a section header
to pass the real count, with a minimal .shstrtab segment for consistency. Also, add support for PN_XNUM to readelf. problem reported and testing by claudio@ ok kettenis@
Diffstat (limited to 'gnu/usr.bin/binutils-2.17')
-rw-r--r--gnu/usr.bin/binutils-2.17/binutils/readelf.c7
-rw-r--r--gnu/usr.bin/binutils-2.17/include/elf/common.h3
2 files changed, 9 insertions, 1 deletions
diff --git a/gnu/usr.bin/binutils-2.17/binutils/readelf.c b/gnu/usr.bin/binutils-2.17/binutils/readelf.c
index aeb41c74be2..b2c0186d418 100644
--- a/gnu/usr.bin/binutils-2.17/binutils/readelf.c
+++ b/gnu/usr.bin/binutils-2.17/binutils/readelf.c
@@ -3175,8 +3175,11 @@ process_file_header (void)
(long) elf_header.e_ehsize);
printf (_(" Size of program headers: %ld (bytes)\n"),
(long) elf_header.e_phentsize);
- printf (_(" Number of program headers: %ld\n"),
+ printf (_(" Number of program headers: %ld"),
(long) elf_header.e_phnum);
+ if (section_headers != NULL && elf_header.e_phnum == PN_XNUM)
+ printf (" (%ld)", (long) section_headers[0].sh_info);
+ putc ('\n', stdout);
printf (_(" Size of section headers: %ld (bytes)\n"),
(long) elf_header.e_shentsize);
printf (_(" Number of section headers: %ld"),
@@ -3193,6 +3196,8 @@ process_file_header (void)
if (section_headers != NULL)
{
+ if (elf_header.e_phnum == PN_XNUM)
+ elf_header.e_phnum = section_headers[0].sh_info;
if (elf_header.e_shnum == 0)
elf_header.e_shnum = section_headers[0].sh_size;
if (elf_header.e_shstrndx == SHN_XINDEX)
diff --git a/gnu/usr.bin/binutils-2.17/include/elf/common.h b/gnu/usr.bin/binutils-2.17/include/elf/common.h
index a44e63c959c..3a7fcd09a17 100644
--- a/gnu/usr.bin/binutils-2.17/include/elf/common.h
+++ b/gnu/usr.bin/binutils-2.17/include/elf/common.h
@@ -286,6 +286,9 @@
#define EV_NONE 0 /* Invalid ELF version */
#define EV_CURRENT 1 /* Current version */
+/* Magic for e_phnum: get real value from sh_info of first section header */
+#define PN_XNUM 0xffff
+
/* Values for program header, p_type field. */
#define PT_NULL 0 /* Program header table entry unused */