This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC][PATCH v2 4/4] libbfd, part of writing corefiles: Add extended numbering support for core file


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]