aboutsummaryrefslogtreecommitdiff
path: root/binutils
diff options
context:
space:
mode:
Diffstat (limited to 'binutils')
-rw-r--r--binutils/ChangeLog9
-rw-r--r--binutils/objcopy.c15
-rw-r--r--binutils/testsuite/binutils-all/objcopy.exp2
-rw-r--r--binutils/testsuite/binutils-all/readelf.exp2
-rw-r--r--binutils/testsuite/binutils-all/strip-13.d9
-rw-r--r--binutils/testsuite/binutils-all/strip-13.s12
6 files changed, 46 insertions, 3 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index a1a5e7c..b7800e1 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,12 @@
+2018-02-27 Nick Clifton <nickc@redhat.com>
+
+ PR 22875
+ * objcopy.c (copy_object): Check the error status after marking
+ symbols used in relocations.
+ * testsuite/binutils-all/strip-13.s: New test source file.
+ * testsuite/binutils-all/strip-13.s: New test driver file.
+ * testsuite/binutils-all/objcopy.exp: Run the new test.
+
2018-02-26 Alan Modra <amodra@gmail.com>
* testsuite/binutils-all/mips/mips-reginfo-n32.d,
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index 8cdf27a..d0a152c 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -3023,9 +3023,18 @@ copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch)
ignore input sections which have no corresponding output
section. */
if (strip_symbols != STRIP_ALL)
- bfd_map_over_sections (ibfd,
- mark_symbols_used_in_relocations,
- isympp);
+ {
+ bfd_set_error (bfd_error_no_error);
+ bfd_map_over_sections (ibfd,
+ mark_symbols_used_in_relocations,
+ isympp);
+ if (bfd_get_error () != bfd_error_no_error)
+ {
+ status = 1;
+ return FALSE;
+ }
+ }
+
osympp = (asymbol **) xmalloc ((symcount + add_symbols + 1) * sizeof (asymbol *));
symcount = filter_symbols (ibfd, obfd, osympp, isympp, symcount);
}
diff --git a/binutils/testsuite/binutils-all/objcopy.exp b/binutils/testsuite/binutils-all/objcopy.exp
index f4a7692..f7b811c 100644
--- a/binutils/testsuite/binutils-all/objcopy.exp
+++ b/binutils/testsuite/binutils-all/objcopy.exp
@@ -1084,6 +1084,8 @@ if [is_elf_format] {
run_dump_test "strip-8"
run_dump_test "strip-9"
run_dump_test "strip-12"
+ run_dump_test "strip-13"
+
# This requires STB_GNU_UNIQUE support with OSABI set to GNU.
if { [supports_gnu_unique] } {
run_dump_test "strip-10"
diff --git a/binutils/testsuite/binutils-all/readelf.exp b/binutils/testsuite/binutils-all/readelf.exp
index 6fc5070..45a022a 100644
--- a/binutils/testsuite/binutils-all/readelf.exp
+++ b/binutils/testsuite/binutils-all/readelf.exp
@@ -324,6 +324,8 @@ if {![binutils_assemble $srcdir/$subdir/bintest.s tmpdir/bintest.o]} then {
unresolved "readelf -S bintest (failed to assemble)"
unresolved "readelf -s bintest (failed to assemble)"
unresolved "readelf -r bintest (failed to assemble)"
+ global readelf_size
+ set readelf_size ""
} else {
if ![is_remote host] {
diff --git a/binutils/testsuite/binutils-all/strip-13.d b/binutils/testsuite/binutils-all/strip-13.d
new file mode 100644
index 0000000..a34e1eb
--- /dev/null
+++ b/binutils/testsuite/binutils-all/strip-13.d
@@ -0,0 +1,9 @@
+#PROG: strip
+#strip: -g
+#error: .* bad value
+#not-target: arm-* d10v-* dlx-* h8300-* hppa*-* ip2k-* rx-* xgate-*
+# The D10V, DLX and XGATE targets only support REL relocations but this test uses RELA relocations.
+# The ARM target does support both types, but defaults to REL.
+# The HPPA targets use reloc 241, which is the value this test uses as its "unknown" reloc.
+# The H8300-*, IP2K and RX targets do not complain about unrecognised relocs, unless they are actually used
+# (which is what should really happen with the other targets...)
diff --git a/binutils/testsuite/binutils-all/strip-13.s b/binutils/testsuite/binutils-all/strip-13.s
new file mode 100644
index 0000000..5da2426
--- /dev/null
+++ b/binutils/testsuite/binutils-all/strip-13.s
@@ -0,0 +1,12 @@
+ .text
+foo:
+ .dc.l 0x12345678
+
+ .section .rela.text
+ .dc.a 0
+ .dc.a 0x000000f1
+ .dc.a 0x000000f1
+
+ .dc.a 0
+ .dc.a 0
+ .dc.a 0