[COFF] Make the autogenerated .weak.<name>.default symbols static
authorMartin Storsjö <martin@martin.st>
Thu, 19 Dec 2019 08:01:40 +0000 (10:01 +0200)
committerMartin Storsjö <martin@martin.st>
Sat, 28 Dec 2019 21:12:41 +0000 (23:12 +0200)
commit7ca86ee6494d4307333b300bae80e42df4a5140f
treeae78935f7be326834c4afc8a7e0a083c7d7c3fcb
parente7853a5ce21c466ae6261ec73933672610427a07
[COFF] Make the autogenerated .weak.<name>.default symbols static

If we have references to the same extern_weak in multiple objects,
all of them would generate external symbols with the same name. Make
them static to avoid duplicate definitions; nothing should need to
refer to this symbol outside of the current object.

GCC/binutils seems to handle the same by not using a fixed string
for the ".default" suffix, but instead using the name of some other
defined external symbol from the same object (which is supposed to
be unique among objects unless there's other duplicate definitions).

Differential Revision: https://reviews.llvm.org/D71711
llvm/lib/MC/WinCOFFObjectWriter.cpp
llvm/test/MC/COFF/weak-alias-local.s
llvm/test/MC/COFF/weak-val.s
llvm/test/MC/COFF/weak.s