[gold] Match lld WPD behavior for shared library symbols and add test

lld already marks shared library defs as ExportDynamic, which prevents
potentially unsafe devirtualization of symbols defined in shared
libraries. Match that behavior in the gold plugin, and add the same
test.

Depends on D96721.

Differential Revision: https://reviews.llvm.org/D96722

GitOrigin-RevId: 50ac3b1d780fd385d50589641bfc91b95cd2d12f
3 files changed