[gold] Use ld.bfd for tests (#130981)
The gold linker is deprecated and no longer part of the default binutils
source distribution. LLVM's gold plugin, despite its name, does not
actually require the gold linker, it is compatible with any linker
implementing the necessary plugin interface, including the normal ld.bfd
linker. However, our tests for the gold plugin currently require the
gold linker.
This PR switches the tests to the ld.bfd instead, to the degree that
this is possible. A number of tests keep using gold, because they use
flags that ld.bfd only supports in very recent versions
(`--section-ordering-file` since 2.43 and `--start-lib` since 2.47).
The `thinlto.ll` test is changed to use `test -s` instead of `test -e`,
because ld.bfd will always create the (empty) output file, even if
`--plugin-opt=thinlto-index-only` is specified.
The `linkonce_odr_unnamed_addr.ll` test adds some uses of the
linkonce_odr symbols in the IR that gets compiled to a native object.
Unlike ld.gold, ld.bfd will report the IR symbols are
PREVAILING_DEF_IRONLY (rather than PREVAILING_DEF) if the native object
only has a weak definition, but not references of the symbol in
relocations. This seems a bit iffy to me, but probably harmless in
practice.
The `common.ll` test keeps using gold, because ld.bfd appears to be
incorrectly handling common linkage when linker plugins are involved
(https://sourceware.org/bugzilla/show_bug.cgi?id=34570).