[5.6] IRGen: Fix using weak linkage to avoid duplicate metadata by only applying weak linkage to PROTOCOL related data
This adjusts PR#40342 with a fix for category linker errors. We will now only apply weak linkage to PROTOCOL metadata.
Cherry-pick of commits from https://github.com/apple/swift/pull/40486.
rdar://86256970