[PATCH] D73139: [LLD][COFF] Enable linking of __declspec(selectany) symbols from Clang and GCC
Reid Kleckner via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 21 15:27:50 PST 2020
rnk added a comment.
In D73139#1832396 <https://reviews.llvm.org/D73139#1832396>, @mstorsjo wrote:
> This needs a testcase. Have a look in lld/test/COFF, it's probably most suitable with a `.s` test for this (the main test file itself simulating the object file created by e.g. clang, and then either a separate file in test/COFF/Inputs, or generating that second file with echo statements within the file (there's a few examples of this among the existing tests), for the other file - assemble both and try to link them together.
That sounds right to me. You know, I wonder if this would work for test structure:
# RUN: llvm-mc %s -defsym obj=1 -filetype=obj -o %t1.obj
# RUN: llvm-mc %s -defsym obj=2 -filetype=obj -o %t2.obj
# RUN: lld-link ... %t1.obj %t2.obj
.if obj=1
# obj1 contents
.endif
.if obj2
# obj2 contents
.endif
I haven't tried it, but `.if` seems nicer than echo escapes.
================
Comment at: lld/COFF/InputFiles.cpp:511
+ leaderSelection == IMAGE_COMDAT_SELECT_ANY))) {
+ leaderSelection = selection = IMAGE_COMDAT_SELECT_ANY;
+ }
----------------
Does ld.bfd implement the same size check? If so, it might be more conservative to use IMAGE_COMDAT_SELECT_SAME_SIZE for the leader.
I see that GCC only allows this attribute to apply to data, not code, so "same size" makes sense, even if it ignores that "selectany" really means IMAGE_COMDAT_SELECT_ANY. :)
Repository:
rLLD LLVM Linker
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D73139/new/
https://reviews.llvm.org/D73139
More information about the llvm-commits
mailing list