rpms/elfutils/devel Makefile, 1.3, 1.4 elfutils-0.108-robustify.patch, 1.2, 1.3 elfutils.spec, 1.30, 1.31

fedora-cvs-commits at redhat.com fedora-cvs-commits at redhat.com
Thu Jun 9 22:29:15 UTC 2005


Author: roland

Update of /cvs/dist/rpms/elfutils/devel
In directory cvs.devel.redhat.com:/tmp/cvs-serv19893

Modified Files:
	Makefile elfutils-0.108-robustify.patch elfutils.spec 
Log Message:
eu-strip robustification


Index: Makefile
===================================================================
RCS file: /cvs/dist/rpms/elfutils/devel/Makefile,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Makefile	10 May 2005 05:57:44 -0000	1.3
+++ Makefile	9 Jun 2005 22:29:12 -0000	1.4
@@ -3,15 +3,20 @@
 NAME := elfutils
 SPECFILE = $(firstword $(wildcard *.spec))
 
+TARGETS += elfutils-portability.patch
+
 include ../common/Makefile.common
 
-elfutils-portability.patch: elfutils-$(VERSION).tar.gz portable.patch
-	rm -rf elfutils-$(VERSION) elfutils-$(VERSION).orig
-	tar xzf $<
-	mv elfutils-$(VERSION) elfutils-$(VERSION).orig
-	tar xzf $<
-	patch -p1 -d elfutils-$(VERSION) < portable.patch
-	cd elfutils-$(VERSION); autoreconf
-	diff -rpu elfutils-$(VERSION).orig elfutils-$(VERSION) | \
+master-cvsroot = :gserver:cvs.devel.redhat.com:/cvs/devel
+
+elfutils-portability.patch: elfutils-$(VERSION).tar.gz
+	@rm -rf elfutils-master elfutils-portable
+	cvs -d $(master-cvsroot) -Q export \
+	    -d elfutils-master elfutils
+	cvs -d $(master-cvsroot) -Q export \
+	    -d elfutils-portable -r portable-branch elfutils
+	cd elfutils-master; autoreconf
+	cd elfutils-portable; autoreconf
+	diff -rpu elfutils-master elfutils-portable | \
 	filterdiff --remove-timestamps --strip=1 --addprefix=elfutils/ > $@.new
 	mv $@.new $@

elfutils-0.108-robustify.patch:
 elfutils-0.108/libelf/elf32_getphdr.c        |   10 +++
 elfutils-0.108/libelf/elf32_getshdr.c        |   15 +++-
 elfutils-0.108/libelf/elf32_newphdr.c        |    8 ++
 elfutils-0.108/libelf/elf32_updatefile.c     |    7 ++
 elfutils-0.108/libelf/elf_begin.c            |   78 +++++++++++++++++------
 elfutils-0.108/libelf/elf_getarsym.c         |    3 
 elfutils-0.108/libelf/elf_getshstrndx.c      |   44 +++++++++++--
 elfutils-0.108/libelf/elf_newscn.c           |   18 +++--
 elfutils-0.108/libelf/gelf_getdyn.c          |    8 +-
 elfutils-0.108/libelf/gelf_getlib.c          |    5 -
 elfutils-0.108/libelf/gelf_getmove.c         |    5 -
 elfutils-0.108/libelf/gelf_getrel.c          |   14 +---
 elfutils-0.108/libelf/gelf_getrela.c         |   14 +---
 elfutils-0.108/libelf/gelf_getsym.c          |    8 +-
 elfutils-0.108/libelf/gelf_getsyminfo.c      |    5 -
 elfutils-0.108/libelf/gelf_getsymshndx.c     |   12 ++-
 elfutils-0.108/libelf/gelf_getversym.c       |    5 -
 elfutils-0.108/libelf/gelf_update_dyn.c      |   14 +---
 elfutils-0.108/libelf/gelf_update_lib.c      |   11 ---
 elfutils-0.108/libelf/gelf_update_move.c     |    4 -
 elfutils-0.108/libelf/gelf_update_rel.c      |   14 +---
 elfutils-0.108/libelf/gelf_update_rela.c     |   14 +---
 elfutils-0.108/libelf/gelf_update_sym.c      |   14 +---
 elfutils-0.108/libelf/gelf_update_syminfo.c  |   11 ---
 elfutils-0.108/libelf/gelf_update_symshndx.c |   14 +---
 elfutils-0.108/libelf/gelf_update_versym.c   |    4 -
 elfutils-0.108/libelf/libelfP.h              |    9 ++
 elfutils-0.108/src/elflint.c                 |   79 +++++++++++++++++------
 elfutils/src/strip.c                         |   89 +++++++++++++++++----------
 29 files changed, 347 insertions(+), 189 deletions(-)

Index: elfutils-0.108-robustify.patch
===================================================================
RCS file: /cvs/dist/rpms/elfutils/devel/elfutils-0.108-robustify.patch,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- elfutils-0.108-robustify.patch	26 May 2005 00:54:40 -0000	1.2
+++ elfutils-0.108-robustify.patch	9 Jun 2005 22:29:12 -0000	1.3
@@ -1,3 +1,10 @@
+2005-06-09  Roland McGrath  <roland at redhat.com>
+
+src/
+	* strip.c (handle_elf): Check for bogus values in sh_link, sh_info,
+	st_shndx, e_shstrndx, and SHT_GROUP or SHT_SYMTAB_SHNDX data.
+	Don't use assert on input values, instead bail with "illformed" error.
+
 2005-05-17  Jakub Jelinek  <jakub at redhat.com>
 
 libelf/
@@ -1265,3 +1272,280 @@
  
    /* ELF64 files often use note section entries in the 32-bit format.
       The p_align field is set to 8 in case the 64-bit format is used.
+
+--- elfutils/src/strip.c
++++ elfutils/src/strip.c
+@@ -400,6 +400,7 @@ handle_elf (int fd, Elf *elf, const char
+   Elf_Data debuglink_crc_data;
+   bool any_symtab_changes = false;
+   Elf_Data *shstrtab_data = NULL;
++  size_t shdridx = 0;
+ 
+   /* Create the full name of the file.  */
+   if (prefix != NULL)
+@@ -531,6 +532,11 @@ handle_elf (int fd, Elf *elf, const char
+       goto fail_close;
+     }
+ 
++  if (shstrndx >= shnum)
++    goto illformed;
++
++#define elf_assert(test) do { if (!(test)) goto illformed; } while (0)
++
+   /* Storage for section information.  We leave room for two more
+      entries since we unconditionally create a section header string
+      table.  Maybe some weird tool created an ELF file without one.
+@@ -552,7 +558,7 @@ handle_elf (int fd, Elf *elf, const char
+     {
+       /* This should always be true (i.e., there should not be any
+ 	 holes in the numbering).  */
+-      assert (elf_ndxscn (scn) == cnt);
++      elf_assert (elf_ndxscn (scn) == cnt);
+ 
+       shdr_info[cnt].scn = scn;
+ 
+@@ -565,6 +571,7 @@ handle_elf (int fd, Elf *elf, const char
+ 					shdr_info[cnt].shdr.sh_name);
+       if (shdr_info[cnt].name == NULL)
+ 	{
++	illformed:
+ 	  error (0, 0, gettext ("illformed file '%s'"), fname);
+ 	  goto fail_close;
+ 	}
+@@ -574,6 +581,8 @@ handle_elf (int fd, Elf *elf, const char
+ 
+       /* Remember the shdr.sh_link value.  */
+       shdr_info[cnt].old_sh_link = shdr_info[cnt].shdr.sh_link;
++      if (shdr_info[cnt].old_sh_link >= shnum)
++	goto illformed;
+ 
+       /* Sections in files other than relocatable object files which
+ 	 are not loaded can be freely moved by us.  In relocatable
+@@ -586,7 +595,7 @@ handle_elf (int fd, Elf *elf, const char
+ 	 appropriate reference.  */
+       if (unlikely (shdr_info[cnt].shdr.sh_type == SHT_SYMTAB_SHNDX))
+ 	{
+-	  assert (shdr_info[shdr_info[cnt].shdr.sh_link].symtab_idx == 0);
++	  elf_assert (shdr_info[shdr_info[cnt].shdr.sh_link].symtab_idx == 0);
+ 	  shdr_info[shdr_info[cnt].shdr.sh_link].symtab_idx = cnt;
+ 	}
+       else if (unlikely (shdr_info[cnt].shdr.sh_type == SHT_GROUP))
+@@ -605,7 +614,12 @@ handle_elf (int fd, Elf *elf, const char
+ 	  for (inner = 1;
+ 	       inner < shdr_info[cnt].data->d_size / sizeof (Elf32_Word);
+ 	       ++inner)
+-	    shdr_info[grpref[inner]].group_idx = cnt;
++	    {
++	      if (grpref[inner] < shnum)
++		shdr_info[grpref[inner]].group_idx = cnt;
++	      else
++		goto illformed;
++	    }
+ 
+ 	  if (inner == 1 || (inner == 2 && (grpref[0] & GRP_COMDAT) == 0))
+ 	    /* If the section group contains only one element and this
+@@ -616,7 +630,7 @@ handle_elf (int fd, Elf *elf, const char
+ 	}
+       else if (unlikely (shdr_info[cnt].shdr.sh_type == SHT_GNU_versym))
+ 	{
+-	  assert (shdr_info[shdr_info[cnt].shdr.sh_link].version_idx == 0);
++	  elf_assert (shdr_info[shdr_info[cnt].shdr.sh_link].version_idx == 0);
+ 	  shdr_info[shdr_info[cnt].shdr.sh_link].version_idx = cnt;
+ 	}
+ 
+@@ -624,7 +638,7 @@ handle_elf (int fd, Elf *elf, const char
+ 	 discarded right away.  */
+       if ((shdr_info[cnt].shdr.sh_flags & SHF_GROUP) != 0)
+ 	{
+-	  assert (shdr_info[cnt].group_idx != 0);
++	  elf_assert (shdr_info[cnt].group_idx != 0);
+ 
+ 	  if (shdr_info[shdr_info[cnt].group_idx].idx == 0)
+ 	    {
+@@ -700,10 +714,14 @@ handle_elf (int fd, Elf *elf, const char
+ 	    {
+ 	      /* If a relocation section is marked as being removed make
+ 		 sure the section it is relocating is removed, too.  */
+-	      if ((shdr_info[cnt].shdr.sh_type == SHT_REL
+-		   || shdr_info[cnt].shdr.sh_type == SHT_RELA)
+-		  && shdr_info[shdr_info[cnt].shdr.sh_info].idx != 0)
+-		shdr_info[cnt].idx = 1;
++	      if (shdr_info[cnt].shdr.sh_type == SHT_REL
++		  || shdr_info[cnt].shdr.sh_type == SHT_RELA)
++		{
++		  if (shdr_info[cnt].shdr.sh_info >= shnum)
++		    goto illformed;
++		  else if (shdr_info[shdr_info[cnt].shdr.sh_info].idx != 0)
++		    shdr_info[cnt].idx = 1;
++		}
+ 	    }
+ 
+ 	  if (shdr_info[cnt].idx == 1)
+@@ -733,7 +751,7 @@ handle_elf (int fd, Elf *elf, const char
+ 		  if (shdr_info[cnt].symtab_idx != 0
+ 		      && shdr_info[shdr_info[cnt].symtab_idx].data == NULL)
+ 		    {
+-		      assert (shdr_info[cnt].shdr.sh_type == SHT_SYMTAB);
++		      elf_assert (shdr_info[cnt].shdr.sh_type == SHT_SYMTAB);
+ 
+ 		      shdr_info[shdr_info[cnt].symtab_idx].data
+ 			= elf_getdata (shdr_info[shdr_info[cnt].symtab_idx].scn,
+@@ -773,6 +791,9 @@ handle_elf (int fd, Elf *elf, const char
+ 		      else if (scnidx == SHN_XINDEX)
+ 			scnidx = xndx;
+ 
++		      if (scnidx >= shnum)
++			goto illformed;
++
+ 		      if (shdr_info[scnidx].idx == 0)
+ 			{
+ 			  /* Mark this section as used.  */
+@@ -804,11 +825,15 @@ handle_elf (int fd, Elf *elf, const char
+ 		}
+ 
+ 	      /* Handle references through sh_info.  */
+-	      if (SH_INFO_LINK_P (&shdr_info[cnt].shdr)
+-		  && shdr_info[shdr_info[cnt].shdr.sh_info].idx == 0)
++	      if (SH_INFO_LINK_P (&shdr_info[cnt].shdr))
+ 		{
+-		  shdr_info[shdr_info[cnt].shdr.sh_info].idx = 1;
+-		  changes |= shdr_info[cnt].shdr.sh_info < cnt;
++		  if (shdr_info[cnt].shdr.sh_info >= shnum)
++		    goto illformed;
++		  else if ( shdr_info[shdr_info[cnt].shdr.sh_info].idx == 0)
++		    {
++		      shdr_info[shdr_info[cnt].shdr.sh_info].idx = 1;
++		      changes |= shdr_info[cnt].shdr.sh_info < cnt;
++		    }
+ 		}
+ 
+ 	      /* Mark the section as investigated.  */
+@@ -911,7 +936,7 @@ handle_elf (int fd, Elf *elf, const char
+ 	  error (EXIT_FAILURE, 0, gettext ("while generating output file: %s"),
+ 		 elf_errmsg (-1));
+ 
+-	assert (elf_ndxscn (shdr_info[cnt].newscn) == shdr_info[cnt].idx);
++	elf_assert (elf_ndxscn (shdr_info[cnt].newscn) == shdr_info[cnt].idx);
+ 
+ 	/* Add this name to the section header string table.  */
+ 	shdr_info[cnt].se = ebl_strtabadd (shst, shdr_info[cnt].name, 0);
+@@ -951,7 +976,7 @@ handle_elf (int fd, Elf *elf, const char
+ 	error (EXIT_FAILURE, 0,
+ 	       gettext ("while create section header section: %s"),
+ 	       elf_errmsg (-1));
+-      assert (elf_ndxscn (shdr_info[cnt].newscn) == shdr_info[cnt].idx);
++      elf_assert (elf_ndxscn (shdr_info[cnt].newscn) == shdr_info[cnt].idx);
+ 
+       shdr_info[cnt].data = elf_newdata (shdr_info[cnt].newscn);
+       if (shdr_info[cnt].data == NULL)
+@@ -982,7 +1007,7 @@ handle_elf (int fd, Elf *elf, const char
+     }
+ 
+   /* Index of the section header table in the shdr_info array.  */
+-  size_t shdridx = cnt;
++  shdridx = cnt;
+ 
+   /* Add the section header string table section name.  */
+   shdr_info[cnt].se = ebl_strtabadd (shst, ".shstrtab", 10);
+@@ -1007,7 +1032,7 @@ handle_elf (int fd, Elf *elf, const char
+     error (EXIT_FAILURE, 0,
+ 	   gettext ("while create section header section: %s"),
+ 	   elf_errmsg (-1));
+-  assert (elf_ndxscn (shdr_info[cnt].newscn) == idx);
++  elf_assert (elf_ndxscn (shdr_info[cnt].newscn) == idx);
+ 
+   /* Finalize the string table and fill in the correct indices in the
+      section headers.  */
+@@ -1097,21 +1122,21 @@ handle_elf (int fd, Elf *elf, const char
+ 		    shndxdata = elf_getdata (shdr_info[shdr_info[cnt].symtab_idx].scn,
+ 					     NULL);
+ 
+-		    assert ((versiondata->d_size / sizeof (Elf32_Word))
+-			    >= shdr_info[cnt].data->d_size / elsize);
++		    elf_assert ((versiondata->d_size / sizeof (Elf32_Word))
++				>= shdr_info[cnt].data->d_size / elsize);
+ 		  }
+ 
+ 		if (shdr_info[cnt].version_idx != 0)
+ 		  {
+-		    assert (shdr_info[cnt].shdr.sh_type == SHT_DYNSYM);
++		    elf_assert (shdr_info[cnt].shdr.sh_type == SHT_DYNSYM);
+ 		    /* This section has associated version
+ 		       information.  We have to modify that
+ 		       information, too.  */
+ 		    versiondata = elf_getdata (shdr_info[shdr_info[cnt].version_idx].scn,
+ 					       NULL);
+ 
+-		    assert ((versiondata->d_size / sizeof (GElf_Versym))
+-			    >= shdr_info[cnt].data->d_size / elsize);
++		    elf_assert ((versiondata->d_size / sizeof (GElf_Versym))
++				>= shdr_info[cnt].data->d_size / elsize);
+ 		  }
+ 
+ 		shdr_info[cnt].newsymidx
+@@ -1165,7 +1190,7 @@ handle_elf (int fd, Elf *elf, const char
+ 		      sec = shdr_info[sym->st_shndx].idx;
+ 		    else
+ 		      {
+-			assert (shndxdata != NULL);
++			elf_assert (shndxdata != NULL);
+ 
+ 			sec = shdr_info[xshndx].idx;
+ 		      }
+@@ -1186,7 +1211,7 @@ handle_elf (int fd, Elf *elf, const char
+ 			    nxshndx = sec;
+ 			  }
+ 
+-			assert (sec < SHN_LORESERVE || shndxdata != NULL);
++			elf_assert (sec < SHN_LORESERVE || shndxdata != NULL);
+ 
+ 			if ((inner != destidx || nshndx != sym->st_shndx
+ 			     || (shndxdata != NULL && nxshndx != xshndx))
+@@ -1209,7 +1234,7 @@ handle_elf (int fd, Elf *elf, const char
+ 		    else
+ 		      /* This is a section symbol for a section which has
+ 			 been removed.  */
+-		      assert (GELF_ST_TYPE (sym->st_info) == STT_SECTION);
++		      elf_assert (GELF_ST_TYPE (sym->st_info) == STT_SECTION);
+ 		  }
+ 
+ 		if (destidx != inner)
+@@ -1373,11 +1398,11 @@ handle_elf (int fd, Elf *elf, const char
+ 		    {
+ 		      GElf_Sym sym_mem;
+ 		      GElf_Sym *sym = gelf_getsym (symd, inner, &sym_mem);
+-		      assert (sym != NULL);
++		      elf_assert (sym != NULL);
+ 
+ 		      const char *name = elf_strptr (elf, strshndx,
+ 						     sym->st_name);
+-		      assert (name != NULL);
++		      elf_assert (name != NULL);
+ 		      size_t hidx = elf_hash (name) % nbucket;
+ 
+ 		      if (bucket[hidx] == 0)
+@@ -1396,8 +1421,8 @@ handle_elf (int fd, Elf *elf, const char
+ 	      else
+ 		{
+ 		  /* Alpha and S390 64-bit use 64-bit SHT_HASH entries.  */
+-		  assert (shdr_info[cnt].shdr.sh_entsize
+-			  == sizeof (Elf64_Xword));
++		  elf_assert (shdr_info[cnt].shdr.sh_entsize
++			      == sizeof (Elf64_Xword));
+ 
+ 		  Elf64_Xword *bucket = (Elf64_Xword *) hashd->d_buf;
+ 
+@@ -1430,11 +1455,11 @@ handle_elf (int fd, Elf *elf, const char
+ 		    {
+ 		      GElf_Sym sym_mem;
+ 		      GElf_Sym *sym = gelf_getsym (symd, inner, &sym_mem);
+-		      assert (sym != NULL);
++		      elf_assert (sym != NULL);
+ 
+ 		      const char *name = elf_strptr (elf, strshndx,
+ 						     sym->st_name);
+-		      assert (name != NULL);
++		      elf_assert (name != NULL);
+ 		      size_t hidx = elf_hash (name) % nbucket;
+ 
+ 		      if (bucket[hidx] == 0)


Index: elfutils.spec
===================================================================
RCS file: /cvs/dist/rpms/elfutils/devel/elfutils.spec,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- elfutils.spec	26 May 2005 01:02:10 -0000	1.30
+++ elfutils.spec	9 Jun 2005 22:29:12 -0000	1.31
@@ -1,5 +1,5 @@
 %define version 0.108
-%define release 3
+%define release 4
 
 %define gpl 0
 %if %{?_with_compat:1}%{!?_with_compat:0}
@@ -223,6 +223,9 @@
 %{_libdir}/libelf.so
 
 %changelog
+* Thu Jun  9 2005 Roland McGrath <roland at redhat.com> - 0.108-4
+- eu-strip robustification
+
 * Wed May 25 2005 Roland McGrath <roland at redhat.com> - 0.108-3
 - more robustification
 




More information about the fedora-cvs-commits mailing list