Open Quuxplusone opened 4 years ago
The -merge:.rdata=.text
argument can be removed from the command line, it doesn't affect creation of these sections.
The .00cfg
section is apparently somehow related to Control Flow Graph.
It's true, .00cfg has been around for a while, and I've wanted to figure out what VC link does with it. I'm not familiar with .voltbl, but we should look into it.
These pages are related to `.voltbl`:
https://bugs.chromium.org/p/chromium/issues/detail?id=925943
https://developercommunity.visualstudio.com/content/problem/441151/vc-generatesships-obj-files-with-illegal-associati.html?childToView=470388
Microsoft has made this small change to the PE spec which is related to this
issue:
https://github.com/MicrosoftDocs/win32/commit/ccf71b16e5b50f3c8acf0bba2de13bfa5f513e36
The spec has been updated again to clarify the question related to possible
loops:
https://github.com/MicrosoftDocs/win32/compare/7ddf2ceff076edb3effb6f9326307c3bbf862cfb..d86a62d2a66a033cae105f063f30b9e62ab760c1
A comment from YongKang Zhu [MSFT]:
PE-COFF document has been updated with more descriptions on associative COMDAT section, especially on multi-level association case.
As to that symbol for section A (that section B is associated with) has to show up earlier in COFF symbol table before the symbol for section B, there is no mention of this in the original PE-COFF document, so we just keep it that way and don't add this into spec now.
The issue is easy to reproduce using the latest clang from https://llvm.org/builds/ (Git commit 2663a25f, 3 February 2020).
include
int wmain(int argc, wchar_t* argv[]) { printf("Hello, world!"); return 0; }
Compile it and link using lld: clang -std=c++17 -m32 -fuse-ld=lld -Oz -Wl,-subsystem:console,-merge:.rdata=.text,-out:test1.exe test.cpp
Compile it and link using default link.exe: clang -std=c++17 -m32 -Oz -Wl,-subsystem:console,-merge:.rdata=.text,-out:test2.exe test.cpp
Compare section lists of the
test1.exe
andtest2.exe
. Thetest1.exe
(linked by lld) does have.00cfg
and.voltbl
sections; thetest2.exe
(linked by default linker, link.exe I suppose) doesn't have these sections.Repro files (with all the libraries) are here: http://veg.by/files/temp/lld_00cfg_repro.7z
It seems that these sections come from standard VC++ and Windows SDK libraries. I guess that it is expected that lld should behave like link.exe. So, probably it is worth to investigate what causes this difference.