From 0691f7afbc8ec41ca26f21b5dafc4eeb4ca517eb Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Tue, 10 Mar 2009 00:48:10 +0000 Subject: [PATCH] binutils/ 2009-03-09 H.J. Lu PR binutils/9933 * objcopy.c (filter_symbols): Properly handle common symbols in relocatable file. binutils/testsuite/ 2009-03-09 H.J. Lu PR binutils/9933 * binutils-all/copy-4.d: New. * binutils-all/objcopy.exp: Run copy-4. --- binutils/ChangeLog | 6 ++++++ binutils/objcopy.c | 3 ++- binutils/testsuite/ChangeLog | 7 +++++++ binutils/testsuite/binutils-all/copy-4.d | 9 +++++++++ binutils/testsuite/binutils-all/objcopy.exp | 1 + 5 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 binutils/testsuite/binutils-all/copy-4.d diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 111002d08f..880d6e4f5c 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,9 @@ +2009-03-09 H.J. Lu + + PR binutils/9933 + * objcopy.c (filter_symbols): Properly handle common symbols + in relocatable file. + 2009-03-06 Nick Clifton * po/es.po: Updated Spanish translation. diff --git a/binutils/objcopy.c b/binutils/objcopy.c index 6523110e79..07d4f3f3a4 100644 --- a/binutils/objcopy.c +++ b/binutils/objcopy.c @@ -1028,7 +1028,8 @@ filter_symbols (bfd *abfd, bfd *obfd, asymbol **osyms, used_in_reloc = TRUE; } else if (relocatable /* Relocatable file. */ - && (flags & (BSF_GLOBAL | BSF_WEAK)) != 0) + && ((flags & (BSF_GLOBAL | BSF_WEAK)) != 0 + || bfd_is_com_section (bfd_get_section (sym)))) keep = TRUE; else if (bfd_decode_symclass (sym) == 'I') /* Global symbols in $idata sections need to be retained diff --git a/binutils/testsuite/ChangeLog b/binutils/testsuite/ChangeLog index 74feea2ad0..81e6c17848 100644 --- a/binutils/testsuite/ChangeLog +++ b/binutils/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2009-03-09 H.J. Lu + + PR binutils/9933 + * binutils-all/copy-4.d: New. + + * binutils-all/objcopy.exp: Run copy-4. + 2009-03-03 John David Anglin * config/hppa.sed: Fix spelling. diff --git a/binutils/testsuite/binutils-all/copy-4.d b/binutils/testsuite/binutils-all/copy-4.d new file mode 100644 index 0000000000..41fccf0040 --- /dev/null +++ b/binutils/testsuite/binutils-all/copy-4.d @@ -0,0 +1,9 @@ +#PROG: strip +#source: bintest.s +#strip: --strip-unneeded +#nm: -n +#name: strip --strip-unneeded on common symbol + +#... +0+04 C common_symbol +#pass diff --git a/binutils/testsuite/binutils-all/objcopy.exp b/binutils/testsuite/binutils-all/objcopy.exp index 997b543a9d..d45d717cfa 100644 --- a/binutils/testsuite/binutils-all/objcopy.exp +++ b/binutils/testsuite/binutils-all/objcopy.exp @@ -835,6 +835,7 @@ if [is_elf_format] { run_dump_test "copy-2" run_dump_test "copy-3" +run_dump_test "copy-4" if [is_elf_format] { run_dump_test "strip-1" -- 2.34.1