This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
PATCH: PR binutils/9933: `strip --strip-unneeded` strips common symbols from relocatable objects
- From: "H.J. Lu" <hongjiu dot lu at intel dot com>
- To: binutils at sources dot redhat dot com
- Date: Mon, 9 Mar 2009 09:51:33 -0700
- Subject: PATCH: PR binutils/9933: `strip --strip-unneeded` strips common symbols from relocatable objects
- Reply-to: "H.J. Lu" <hjl dot tools at gmail dot com>
`strip --strip-unneeded` shouldn't strip common symbols from relocatable
objects. This patch fixes. OK for trunk?
Thanks.
H.J.
----
binutils/
2009-03-09 H.J. Lu <hongjiu.lu@intel.com>
PR binutils/9933
* objcopy.c (filter_symbols): Properly handle common symbols
in relocatable file.
binutils/testsuite/
2009-03-09 H.J. Lu <hongjiu.lu@intel.com>
PR binutils/9933
* binutils-all/copy-4.d: New.
* binutils-all/objcopy.exp: Run copy-4.
--- binutils/objcopy.c.needed 2009-03-09 09:46:06.000000000 -0700
+++ binutils/objcopy.c 2009-03-09 09:46:33.000000000 -0700
@@ -1028,7 +1028,8 @@ filter_symbols (bfd *abfd, bfd *obfd, as
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
--- binutils/testsuite/binutils-all/copy-4.d.needed 2009-03-09 09:45:26.000000000 -0700
+++ binutils/testsuite/binutils-all/copy-4.d 2009-03-09 09:45:05.000000000 -0700
@@ -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
--- binutils/testsuite/binutils-all/objcopy.exp.needed 2008-10-02 13:43:58.000000000 -0700
+++ binutils/testsuite/binutils-all/objcopy.exp 2009-03-09 09:40:02.000000000 -0700
@@ -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"