Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 21 Jul 2010 09:20:40 +0000 (UTC)
From:      Kai Wang <kaiw@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r210326 - head/lib/libelf
Message-ID:  <201007210920.o6L9KeQ1073151@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kaiw
Date: Wed Jul 21 09:20:40 2010
New Revision: 210326
URL: http://svn.freebsd.org/changeset/base/210326

Log:
  Improve compatibility with other implementations of the ELF(3) API:
  when an output file has no program headers, set the 'e_phentsize'
  field of the ELF executable header to zero.
  
  Obtained from:	elftoolchain
  MFC after:		1 month

Modified:
  head/lib/libelf/elf_update.c

Modified: head/lib/libelf/elf_update.c
==============================================================================
--- head/lib/libelf/elf_update.c	Wed Jul 21 08:58:52 2010	(r210325)
+++ head/lib/libelf/elf_update.c	Wed Jul 21 09:20:40 2010	(r210326)
@@ -422,8 +422,8 @@ _libelf_resync_elf(Elf *e)
 		(E)->e_ident[EI_VERSION] = (V);				\
 		(E)->e_ehsize = _libelf_fsize(ELF_T_EHDR, (EC), (V),	\
 		    (size_t) 1);					\
-		(E)->e_phentsize = _libelf_fsize(ELF_T_PHDR, (EC), (V),	\
-		    (size_t) 1);					\
+		(E)->e_phentsize = (phnum == 0) ? 0 : _libelf_fsize(	\
+		    ELF_T_PHDR, (EC), (V), (size_t) 1);			\
 		(E)->e_shentsize = _libelf_fsize(ELF_T_SHDR, (EC), (V),	\
 		    (size_t) 1);					\
 	} while (0)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201007210920.o6L9KeQ1073151>