Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 21 Jul 2010 09:27:17 +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: r210328 - head/lib/libelf
Message-ID:  <201007210927.o6L9RHp0074690@svn.freebsd.org>

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

Log:
  Bug fix: permit the creation of zero-sized sections.
  
  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 09:27:00 2010	(r210327)
+++ head/lib/libelf/elf_update.c	Wed Jul 21 09:27:16 2010	(r210328)
@@ -534,22 +534,24 @@ _libelf_write_scn(Elf *e, char *nf, Elf_
 	int ec;
 	size_t fsz, msz, nobjects;
 	uint32_t sh_type;
-	uint64_t sh_off;
+	uint64_t sh_off, sh_size;
 	int elftype;
 	Elf_Data *d, dst;
 
-	if ((ec = e->e_class) == ELFCLASS32)
+	if ((ec = e->e_class) == ELFCLASS32) {
 		sh_type = s->s_shdr.s_shdr32.sh_type;
-	else
+		sh_size = (uint64_t) s->s_shdr.s_shdr32.sh_size;
+	} else {
 		sh_type = s->s_shdr.s_shdr64.sh_type;
+		sh_size = s->s_shdr.s_shdr64.sh_size;
+	}
 
 	/*
 	 * Ignore sections that do not allocate space in the file.
 	 */
-	if (sh_type == SHT_NOBITS || sh_type == SHT_NULL)
+	if (sh_type == SHT_NOBITS || sh_type == SHT_NULL || sh_size == 0)
 		return (rc);
 
-
 	elftype = _libelf_xlate_shtype(sh_type);
 	assert(elftype >= ELF_T_FIRST && elftype <= ELF_T_LAST);
 



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