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]

PATCH: PR binutils/4348: strip can't strip sections


I don't see why objcopy should stop when there are no sections to be
copied. After all, the resulting output file is still valid ELF
file.


H.J.
----
2007-04-11  H.J. Lu  <hongjiu.lu@intel.com>

	PR binutils/4348
	* objcopy.c (copy_object): Don't stop when there are no
	sections to be copied.

testsuite/

2007-04-11  H.J. Lu  <hongjiu.lu@intel.com>

	PR binutils/4348
	* binutils-all/empty.s: New file.
	* binutils-all/strip-3.d: Likewise.

	* binutils-all/objcopy.exp: Run strip-3 for ELF target.

--- binutils/objcopy.c.empty	2007-03-01 14:53:10.000000000 -0800
+++ binutils/objcopy.c	2007-04-11 21:03:26.000000000 -0700
@@ -1521,13 +1521,8 @@ copy_object (bfd *ibfd, bfd *obfd)
 	}
     }
 
-  if (bfd_count_sections (obfd) == 0)
-    {
-      non_fatal (_("there are no sections to be copied!"));
-      return FALSE;
-    }
-
-  if (gap_fill_set || pad_to_set)
+  if (bfd_count_sections (obfd) != 0
+      && (gap_fill_set || pad_to_set))
     {
       asection **set;
       unsigned int c, i;
--- binutils/testsuite/binutils-all/empty.s.empty	2007-04-11 20:57:11.000000000 -0700
+++ binutils/testsuite/binutils-all/empty.s	2007-04-11 20:56:56.000000000 -0700
@@ -0,0 +1 @@
+# An empty file.
--- binutils/testsuite/binutils-all/objcopy.exp.empty	2007-04-11 20:18:51.000000000 -0700
+++ binutils/testsuite/binutils-all/objcopy.exp	2007-04-11 21:02:23.000000000 -0700
@@ -744,5 +744,6 @@ if [is_elf_format] {
     run_dump_test "localize-hidden-1"
     run_dump_test "strip-1"
     run_dump_test "strip-2"
+    run_dump_test "strip-3"
 }
 run_dump_test "localize-hidden-2"
--- binutils/testsuite/binutils-all/strip-3.d.empty	2007-04-11 20:57:46.000000000 -0700
+++ binutils/testsuite/binutils-all/strip-3.d	2007-04-11 21:01:15.000000000 -0700
@@ -0,0 +1,11 @@
+#PROG: strip
+#source: empty.s
+#strip: -R .text -R .data -R .bss
+#readelf: -S --wide
+#name: strip empty file
+#target: *-*-linux*
+
+#...
+  \[[ 0]+\][ \t]+NULL[ \t]+.*
+  \[[ 1]+\] \.shstrtab.*[ \t]+STRTAB[ \t]+.*
+#pass


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