From 1aa9ef630cd7777c24e5d1592c54fbeffad22fd8 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Thu, 12 Apr 2007 19:20:46 +0000 Subject: [PATCH] 2007-04-12 H.J. Lu PR binutils/4348 * objcopy.c (copy_object): Don't stop when there are no sections to be copied. testsuite/ 2007-04-12 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/ChangeLog | 6 ++++++ binutils/objcopy.c | 9 ++------- binutils/testsuite/ChangeLog | 8 ++++++++ binutils/testsuite/binutils-all/empty.s | 1 + binutils/testsuite/binutils-all/objcopy.exp | 1 + binutils/testsuite/binutils-all/strip-3.d | 11 +++++++++++ 6 files changed, 29 insertions(+), 7 deletions(-) create mode 100644 binutils/testsuite/binutils-all/empty.s create mode 100644 binutils/testsuite/binutils-all/strip-3.d diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 83dc368d436..a45c46b8148 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,9 @@ +2007-04-12 H.J. Lu + + PR binutils/4348 + * objcopy.c (copy_object): Don't stop when there are no + sections to be copied. + 2007-04-10 Vladimir Prus * NEWS: Mention disjoint histograms support in diff --git a/binutils/objcopy.c b/binutils/objcopy.c index c955e37bbd5..d02b3e0e0b4 100644 --- a/binutils/objcopy.c +++ b/binutils/objcopy.c @@ -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; diff --git a/binutils/testsuite/ChangeLog b/binutils/testsuite/ChangeLog index 27e5a10d5bd..13e37e3f0c5 100644 --- a/binutils/testsuite/ChangeLog +++ b/binutils/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2007-04-12 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. + 2007-02-27 Nathan Sidwell * binutils-all/objcopy.exp: Skip for uclinux targets. diff --git a/binutils/testsuite/binutils-all/empty.s b/binutils/testsuite/binutils-all/empty.s new file mode 100644 index 00000000000..8690c06ad8e --- /dev/null +++ b/binutils/testsuite/binutils-all/empty.s @@ -0,0 +1 @@ +# An empty file. diff --git a/binutils/testsuite/binutils-all/objcopy.exp b/binutils/testsuite/binutils-all/objcopy.exp index d782e9b7b79..cc56b4f1459 100644 --- a/binutils/testsuite/binutils-all/objcopy.exp +++ b/binutils/testsuite/binutils-all/objcopy.exp @@ -737,5 +737,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" diff --git a/binutils/testsuite/binutils-all/strip-3.d b/binutils/testsuite/binutils-all/strip-3.d new file mode 100644 index 00000000000..6d2b4514b03 --- /dev/null +++ b/binutils/testsuite/binutils-all/strip-3.d @@ -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 -- 2.30.2