[PATCH] D19836: ELF: Fix regression in TLS attribute mismatch logic.
Peter Collingbourne via llvm-commits
llvm-commits at lists.llvm.org
Tue May 3 11:09:44 PDT 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL268411: ELF: Fix regression in TLS attribute mismatch logic. (authored by pcc).
Changed prior to commit:
http://reviews.llvm.org/D19836?vs=55894&id=56027#toc
Repository:
rL LLVM
http://reviews.llvm.org/D19836
Files:
lld/trunk/ELF/SymbolTable.cpp
lld/trunk/ELF/Symbols.h
lld/trunk/test/ELF/tls-archive.s
Index: lld/trunk/ELF/Symbols.h
===================================================================
--- lld/trunk/ELF/Symbols.h
+++ lld/trunk/ELF/Symbols.h
@@ -131,6 +131,13 @@
uint8_t Type; // symbol type
uint8_t StOther; // st_other field value
+ // The Type field may also have this value. It means that we have not yet seen
+ // a non-Lazy symbol with this name, so we don't know what its type is. The
+ // Type field is normally set to this value for Lazy symbols unless we saw a
+ // weak undefined symbol first, in which case we need to remember the original
+ // symbol's type in order to check for TLS mismatches.
+ enum { UnknownType = 255 };
+
bool isSection() const { return Type == llvm::ELF::STT_SECTION; }
bool isTls() const { return Type == llvm::ELF::STT_TLS; }
bool isFunc() const { return Type == llvm::ELF::STT_FUNC; }
Index: lld/trunk/ELF/SymbolTable.cpp
===================================================================
--- lld/trunk/ELF/SymbolTable.cpp
+++ lld/trunk/ELF/SymbolTable.cpp
@@ -209,7 +209,8 @@
S->ExportDynamic = true;
if (IsUsedInRegularObj)
S->IsUsedInRegularObj = true;
- if (!WasInserted && ((Type == STT_TLS) != S->body()->isTls()))
+ if (!WasInserted && S->body()->Type != SymbolBody::UnknownType &&
+ ((Type == STT_TLS) != S->body()->isTls()))
error("TLS attribute mismatch for symbol: " +
conflictMsg(S->body(), File));
@@ -436,7 +437,7 @@
bool WasInserted;
std::tie(S, WasInserted) = insert(Sym.getName());
if (WasInserted) {
- replaceBody<LazyArchive>(S, F, Sym, STT_NOTYPE);
+ replaceBody<LazyArchive>(S, F, Sym, SymbolBody::UnknownType);
return;
}
if (!S->body()->isUndefined())
@@ -464,7 +465,7 @@
bool WasInserted;
std::tie(S, WasInserted) = insert(Name);
if (WasInserted) {
- replaceBody<LazyObject>(S, Name, MBRef, STT_NOTYPE);
+ replaceBody<LazyObject>(S, Name, MBRef, SymbolBody::UnknownType);
return;
}
if (!S->body()->isUndefined())
Index: lld/trunk/test/ELF/tls-archive.s
===================================================================
--- lld/trunk/test/ELF/tls-archive.s
+++ lld/trunk/test/ELF/tls-archive.s
@@ -0,0 +1,10 @@
+// REQUIRES: x86
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/tls-mismatch.s -o %t2
+// RUN: rm -f %t.a
+// RUN: llvm-ar cru %t.a %t2
+// RUN: ld.lld %t.a %t -o %t3
+
+.globl _start,tlsvar
+_start:
+ movl tlsvar at GOTTPOFF(%rip),%edx
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19836.56027.patch
Type: text/x-patch
Size: 2523 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160503/71d3df0d/attachment.bin>
More information about the llvm-commits
mailing list