[PATCH] D75989: [COFF] Assign unique names to autogenerated .weak.<name>.default symbols

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 11 07:24:41 PDT 2020


mstorsjo created this revision.
mstorsjo added reviewers: rnk, smeenai, compnerd.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.

These symbols need to be external (MSVC tools error out if a weak external points at a symbol that isn't external; this was tried before but had to be reverted in bc5b7217dceecd3eec69593026a9e38dfbfd6908 <https://reviews.llvm.org/rGbc5b7217dceecd3eec69593026a9e38dfbfd6908>, and this was originally explicitly fixed in 732eeaf2a930ad2755cb4eb5d99a3deae0de4a72).

If multiple object files have weak symbols with defaults, their defaults could cause linker errors due to duplicate definitions, unless the names of the defaults are unique.

GNU binutils handles this by appending the name of another symbol from the same object file to the name of the default symbol. Try to implement something similar; before writing the object file, locate a symbol that should have a unique name and use the name of that one for making the weak defaults unique.

This supersedes D71711 <https://reviews.llvm.org/D71711>.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75989

Files:
  llvm/lib/MC/WinCOFFObjectWriter.cpp
  llvm/test/MC/COFF/weak-alias-local.s
  llvm/test/MC/COFF/weak-name.s
  llvm/test/MC/COFF/weak-val.s
  llvm/test/MC/COFF/weak.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75989.249610.patch
Type: text/x-patch
Size: 6395 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200311/fd7beaf9/attachment.bin>


More information about the llvm-commits mailing list