This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils 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]

[PATCH] strip: Just admit we don't support stripping ar archives for now.


We try to handle (in-place) stripping of ar archives, but since elf_clone
doesn't really support cloning ar members and we don't handle reducing
the size of the members, moving the offsets of other members. This causes
crashes or writing garbage. Better to just admit that for now we don't
support stripping archives. Call error when we see an ELF_K_AR file.

https://bugzilla.redhat.com/show_bug.cgi?id=766156
https://lists.fedorahosted.org/pipermail/elfutils-devel/2009-August/000567.html

Signed-off-by: Mark Wielaard <mjw@redhat.com>
---
 src/ChangeLog |  5 +++++
 src/strip.c   | 14 ++++++++++++--
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index 59d87c8..35c68c7 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2015-06-09  Mark Wielaard  <mjw@redhat.com>
+
+	* strip.c (handle_ar): Mark as unused.
+	(process_file): Produce an error when trying to handle an ar.
+
 2015-05-30  Mark Wielaard  <mjw@redhat.com>
 
 	* elfcmp.c (main): Only call memcmp when d_size != 0.
diff --git a/src/strip.c b/src/strip.c
index d63b6a8..5e69334 100644
--- a/src/strip.c
+++ b/src/strip.c
@@ -113,7 +113,7 @@ static int handle_elf (int fd, Elf *elf, const char *prefix,
 
 /* Handle all files contained in the archive.  */
 static int handle_ar (int fd, Elf *elf, const char *prefix, const char *fname,
-		      struct timespec tvp[2]);
+		      struct timespec tvp[2]) __attribute__ ((unused));
 
 static int debug_fd = -1;
 static char *tmp_debug_fname = NULL;
@@ -374,7 +374,17 @@ process_file (const char *fname)
 	  result = 1;
 	}
       else
-	result = handle_ar (fd, elf, NULL, fname, preserve_dates ? tv : NULL);
+	{
+	  /* We would like to support ar archives, but currently it just
+	     doesn't work at all since we call elf_clone on the members
+	     which doesn't really support ar members.
+	     result = handle_ar (fd, elf, NULL, fname,
+				 preserve_dates ? tv : NULL);
+	   */
+	  error (0, 0, gettext ("%s: no support for stripping archive"),
+		 fname);
+	  result = 1;
+	}
       break;
 
     default:
-- 
1.8.3.1


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