public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* PATCH: PR binutils/4348: strip can't strip sections
@ 2007-04-12  6:36 H. J. Lu
  2007-04-12 13:22 ` Nick Clifton
  0 siblings, 1 reply; 4+ messages in thread
From: H. J. Lu @ 2007-04-12  6:36 UTC (permalink / raw)
  To: binutils

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: PATCH: PR binutils/4348: strip can't strip sections
  2007-04-12  6:36 PATCH: PR binutils/4348: strip can't strip sections H. J. Lu
@ 2007-04-12 13:22 ` Nick Clifton
  2007-04-12 15:00   ` H. J. Lu
  0 siblings, 1 reply; 4+ messages in thread
From: Nick Clifton @ 2007-04-12 13:22 UTC (permalink / raw)
  To: H. J. Lu; +Cc: binutils

Hi H. J.

> 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.

I agree that the tools should not fail.  But they also should tell the 
user that nothing has happened.  Otherwise the user will never know that 
their objcopy/strip command was pointless and they may then consider it 
a bug that nothing has changed.

Cheers
   Nick


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: PATCH: PR binutils/4348: strip can't strip sections
  2007-04-12 13:22 ` Nick Clifton
@ 2007-04-12 15:00   ` H. J. Lu
  2007-04-12 20:35     ` Nick Clifton
  0 siblings, 1 reply; 4+ messages in thread
From: H. J. Lu @ 2007-04-12 15:00 UTC (permalink / raw)
  To: Nick Clifton; +Cc: binutils

On Thu, Apr 12, 2007 at 12:33:50PM +0100, Nick Clifton wrote:
> Hi H. J.
> 
> >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.
> 
> I agree that the tools should not fail.  But they also should tell the 
> user that nothing has happened.  Otherwise the user will never know that 
> their objcopy/strip command was pointless and they may then consider it 
> a bug that nothing has changed.

Something is changed in my testcase: 3 sections are removed. Even
if nothing has changed, do we warn the second strip on the same
file:

# strip x.o
# strip x.o


H.J.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: PATCH: PR binutils/4348: strip can't strip sections
  2007-04-12 15:00   ` H. J. Lu
@ 2007-04-12 20:35     ` Nick Clifton
  0 siblings, 0 replies; 4+ messages in thread
From: Nick Clifton @ 2007-04-12 20:35 UTC (permalink / raw)
  To: H. J. Lu; +Cc: binutils

Hi H. J.

> Something is changed in my testcase: 3 sections are removed. Even
> if nothing has changed, do we warn the second strip on the same
> file:
> 
> # strip x.o
> # strip x.o

Hmm, yes you have a point.  OK, I withdraw my objection.  Patch approved.

Cheers
   Nick

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-04-12 19:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-04-12  6:36 PATCH: PR binutils/4348: strip can't strip sections H. J. Lu
2007-04-12 13:22 ` Nick Clifton
2007-04-12 15:00   ` H. J. Lu
2007-04-12 20:35     ` Nick Clifton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).