-# Run a test to check linking a shared library with a broken linker
-# script that accidentally marks dynamic sections as notes. The
-# resulting executable is not expected to work, but the linker
-# should not seg-fault whilst creating the binary.
-#
-# Only run the test on targets thats support creating shared libraries.
-if { ! [istarget arc-*-*]
- && ! [istarget avr-*-*]
- && ! [istarget cr16-*-*]
- && ! [istarget cris*-*-*]
- && ! [istarget crx-*-*]
- && ! [istarget d10v-*-*]
- && ! [istarget d30v-*-*]
- && ! [istarget dlx-*-*]
- && ! [istarget fr30-*-*]
- && ! [istarget frv-*-*]
- && ! [istarget h8300-*-*]
- && ! [istarget i860-*-*]
- && ! [istarget i960-*-*]
- && ! [istarget ip2k-*-*]
- && ! [istarget iq2000-*-*]
- && ! [istarget lm32-*-*]
- && ! [istarget m32c-*-*]
- && ! [istarget m32r-*-*]
- && ! [istarget mcore*-*-*]
- && ! [istarget mep-*-*]
- && ! [istarget microblaze-*-*]
- && ! [istarget mn10200-*-*]
- && ! [istarget moxie-*-*]
- && ! [istarget ms1-*-*]
- && ! [istarget msp430-*-*]
- && ! [istarget openrisc-*-*]
- && ! [istarget or32-*-*]
- && ! [istarget pj-*-*]
- && ! [istarget rx-*-*]
- && ! [istarget spu-*-*]
- && ! [istarget v850*-*-*]
- && ! [istarget xstormy16-*-*]
- && ! [istarget *-*-irix*]
- && ! [istarget *-*-rtems] } {
- run_ld_link_tests {
- {"Build shared library for next test"
- "-shared" "" "note-3.s" {} "note-3.so" }
- {"Link using broken linker script"
- "--script note-3.t tmpdir/note-3.so" "" ""
- { { ld "note-3.l" } }
- "a.out" }
- }
+
+
+# Targets that use _bfd_generic_link_add_symbols won't pass pr21703 tests
+run_ld_link_tests {
+ {"PR ld/21703"
+ "--allow-multiple-definition tmpdir/pr21703-1.o tmpdir/pr21703-2.o" "" "" \
+ {pr21703-1.s pr21703-2.s} {{readelf {-s} pr21703.sd}} "pr21703" }
+ {"PR ld/21703 -r"
+ "-r --allow-multiple-definition tmpdir/pr21703-3.o tmpdir/pr21703-4.o" "" "" \
+ {pr21703-3.s pr21703-4.s} {{readelf {-s} pr21703-r.sd}} "pr21703.o" }
+} \[is_generic\]
+
+if [is_underscore_target] {
+ set ASFLAGS "$ASFLAGS --defsym UNDERSCORE=1"
+}
+
+set saved_ASFLAGS "$ASFLAGS"
+if { [istarget "i?86-*-*"] || [istarget "x86_64-*-*"] } {
+ set ASFLAGS "$ASFLAGS -mx86-used-note=no"