From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8581 invoked by alias); 12 Apr 2007 04:08:52 -0000 Received: (qmail 8573 invoked by uid 22791); 12 Apr 2007 04:08:50 -0000 X-Spam-Check-By: sourceware.org Received: from smtp106.sbc.mail.mud.yahoo.com (HELO smtp106.sbc.mail.mud.yahoo.com) (68.142.198.205) by sourceware.org (qpsmtpd/0.31) with SMTP; Thu, 12 Apr 2007 05:08:46 +0100 Received: (qmail 12972 invoked from network); 12 Apr 2007 04:08:45 -0000 Received: from unknown (HELO lucon.org) (hjjean@sbcglobal.net@75.61.85.239 with login) by smtp106.sbc.mail.mud.yahoo.com with SMTP; 12 Apr 2007 04:08:44 -0000 X-YMail-OSG: kBRo81wVM1mKh.I6CVzEoJTLe1dM_UMfLOuU3Q.naerCSd9uqczRs8JMM0vDWNrfug2hmBsHaA-- Received: by lucon.org (Postfix, from userid 500) id B517B46EEEB; Wed, 11 Apr 2007 21:08:43 -0700 (PDT) Date: Thu, 12 Apr 2007 06:36:00 -0000 From: "H. J. Lu" To: binutils@sources.redhat.com Subject: PATCH: PR binutils/4348: strip can't strip sections Message-ID: <20070412040843.GA8868@lucon.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.2.2i Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2007-04/txt/msg00140.txt.bz2 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 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 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