[llvm-bugs] [Bug 47747] New: Clang produces an incomplete comdat
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Oct 6 13:40:40 PDT 2020
https://bugs.llvm.org/show_bug.cgi?id=47747
Bug ID: 47747
Summary: Clang produces an incomplete comdat
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: rafael at espindo.la
CC: blitzrakete at gmail.com, dgregor at apple.com,
erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
richard-llvm at metafoo.co.uk
Given
common.hh:
-------------------------
struct zed {
zed() noexcept;
};
template <typename T>
thread_local zed var;
-------------------------
test1.cc:
-------------------------
#include "common.hh"
inline void* foobaz() {
return &var<int>;
}
-------------------------
test2.cc:
-------------------------
#include "common.hh"
void* foobar() {
return &var<int>;
}
-------------------------
Compile with just
$ clang++ -c test1.cc -o test1.o
$ clang++ -c test2.cc -o test2.o
$ readelf -gsW test2.o
....
COMDAT group section [ 7] `.group' [_Z3varIiE] contains 4 sections:
[Index] Name
[ 8] .text.startup
[ 9] .rela.text.startup
[ 10] .tbss._Z3varIiE
[ 11] .tbss._ZGV3varIiE
...
10: 0000000000000000 56 FUNC WEAK DEFAULT 8 _ZTH3varIiE
So the symbol _ZTH3varIiE is in a section that is in the _Z3varIiE
comdat.
But in the other file:
$ readelf -gsW test1.o
COMDAT group section [ 3] `.group' [_Z3varIiE] contains 4 sections:
[Index] Name
[ 4] .text.startup
[ 5] .rela.text.startup
[ 6] .tbss._Z3varIiE
[ 7] .tbss._ZGV3varIiE
We have the same comdat, but the symbol _ZTH3varIiE is missing. This
means that if the two files are linked, _ZTH3varIiE can be resolved to
0.
GCC correctly outputs _ZTH3varIiE in both files.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20201006/e9c5a4e0/attachment.html>
More information about the llvm-bugs
mailing list