[PATCH] D52749: [LLD][COFF] Fix CRT global initializers
Alexandre Ganea via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 1 14:35:50 PDT 2018
aganea added a comment.
In https://reviews.llvm.org/D52749#1251704, @rnk wrote:
> In https://reviews.llvm.org/D52749#1251695, @aganea wrote:
>
> > Please note that this issue occurs only when using MSVC cl.exe. Compiling with clang-cl.exe does not expose the issue.
>
>
> I was going to say, I think clang generates a single initializer function to avoid relying on the linker's chosen section order.
>
> That's crummy, though. I guess we could limit it to the CRT section, and say anyone relying on section order corresponding to link line order in other sections is out of luck.
You're right indeed, that is the source of the bug. MSVC `cl.exe` does this:
- Name: '.CRT$XCU'
Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_LNK_COMDAT, IMAGE_SCN_MEM_READ ]
Alignment: 8
SectionData: '0000000000000000'
Relocations:
- VirtualAddress: 0
SymbolName: '??__E?Instances@?$TemplatedObject@$0A@@@2V?$vector at PEAU?$TemplatedObject@$0A@@@V?$allocator at PEAU?$TemplatedObject@$0A@@@@std@@@std@@A@@YAXXZ'
Type: IMAGE_REL_AMD64_ADDR64
- Name: '.CRT$XCU'
Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]
Alignment: 8
SectionData: '0000000000000000'
Relocations:
- VirtualAddress: 0
SymbolName: '??__Eidle@@YAXXZ'
Type: IMAGE_REL_AMD64_ADDR64
While `clang-cl` does this:
- Name: '.CRT$XCU'
Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]
Alignment: 8
SectionData: '0000000000000000'
Relocations:
- VirtualAddress: 0
SymbolName: _GLOBAL__sub_I_Source1.cpp
Type: IMAGE_REL_AMD64_ADDR64
Repository:
rLLD LLVM Linker
https://reviews.llvm.org/D52749
More information about the llvm-commits
mailing list