This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[RFC][PATCH v2 4/4] libbfd, part of writing corefiles: Add extended numbering support for core file
- From: Daisuke HATAYAMA <d dot hatayama at jp dot fujitsu dot com>
- To: binutils at sourceware dot org
- Cc: amodra at gmail dot com, iant at google dot com, vapier at gentoo dot org, dan at codesourcery dot com
- Date: Mon, 18 Jan 2010 16:47:33 +0900 (JST)
- Subject: [RFC][PATCH v2 4/4] libbfd, part of writing corefiles: Add extended numbering support for core file
- References: <20100118.164347.193713146.d.hatayama@jp.fujitsu.com>
We add extended numbering support for libbfd, which enables libbfd
library to manipulate extended ELF object files with program headers
more than 65535 (0xffff).
This is for writing part of libbfd.
---
bfd/elfcode.h | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/bfd/elfcode.h b/bfd/elfcode.h
index f539119..d5a1f2d 100644
--- a/bfd/elfcode.h
+++ b/bfd/elfcode.h
@@ -279,7 +279,10 @@ elf_swap_ehdr_out (bfd *abfd,
H_PUT_32 (abfd, src->e_flags, dst->e_flags);
H_PUT_16 (abfd, src->e_ehsize, dst->e_ehsize);
H_PUT_16 (abfd, src->e_phentsize, dst->e_phentsize);
- H_PUT_16 (abfd, src->e_phnum, dst->e_phnum);
+ if (src->e_phnum < PN_XNUM)
+ H_PUT_16 (abfd, src->e_phnum, dst->e_phnum);
+ else
+ H_PUT_16 (abfd, PN_XNUM, dst->e_phnum);
H_PUT_16 (abfd, src->e_shentsize, dst->e_shentsize);
tmp = src->e_shnum;
if (tmp >= (SHN_LORESERVE & 0xffff))
@@ -1069,6 +1072,8 @@ elf_write_shdrs_and_ehdr (bfd *abfd)
/* Some fields in the first section header handle overflow of ehdr
fields. */
+ if (i_ehdrp->e_phnum >= PN_XNUM)
+ i_shdrp[0]->sh_info = i_ehdrp->e_phnum;
if (i_ehdrp->e_shnum >= (SHN_LORESERVE & 0xffff))
i_shdrp[0]->sh_size = i_ehdrp->e_shnum;
if (i_ehdrp->e_shstrndx >= (SHN_LORESERVE & 0xffff))
--
1.6.5.1