OSDN Git Service

[mingw] Fix GCC ABI compatibility for comdat things
authorReid Kleckner <rnk@google.com>
Thu, 21 Jun 2018 20:27:38 +0000 (20:27 +0000)
committerReid Kleckner <rnk@google.com>
Thu, 21 Jun 2018 20:27:38 +0000 (20:27 +0000)
commit845b439bb4db7ba187e779dd51ea6ff77c24767a
treed39121fe13fee1893dd6ac4c68722b7ddfa1e1d3
parentd7f1ecfded0c0d79a4a24eeff4de9289a59f7cfd
[mingw] Fix GCC ABI compatibility for comdat things

Summary:
GCC and the binutils COFF linker do comdats differently from MSVC.
If we want to be ABI compatible, we have to do what they do, which is to
emit unique section names like ".text$_Z3foov" instead of short section
names like ".text". Otherwise, the binutils linker gets confused and
reports multiple definition errors when two object files from GCC and
Clang containing the same inline function are linked together.

The best description of the issue is probably at
https://github.com/Alexpux/MINGW-packages/issues/1677, we don't seem to
have a good one in our tracker.

I fixed up the .pdata and .xdata sections needed everywhere other than
32-bit x86. GCC doesn't use associative comdats for those, it appears to
rely on the section name.

Reviewers: smeenai, compnerd, mstorsjo, martell, mati865

Subscribers: llvm-commits, hiraditya

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335286 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
include/llvm/MC/MCAsmInfo.h
lib/CodeGen/TargetLoweringObjectFileImpl.cpp
lib/MC/MCAsmInfoCOFF.cpp
lib/MC/MCStreamer.cpp
test/CodeGen/X86/mingw-comdats.ll [new file with mode: 0644]