PATCH: PR binutils/9933: `strip --strip-unneeded` strips common symbols from relocatable objects
H.J. Lu
hongjiu.lu@intel.com
Mon Mar 9 16:51:00 GMT 2009
`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"
More information about the Binutils
mailing list