summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2016-05-03 18:03:47 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2016-05-03 18:03:47 +0000
commitf3a2b0e8f77041ff49441486e6cc296ff685af61 (patch)
treec3c4ee8e2c694c11b3b0c1ce4675b315b40aeaf1
parent6f535b744f43df17e896241610201941f2a7af2b (diff)
downloadbcm5719-llvm-f3a2b0e8f77041ff49441486e6cc296ff685af61.tar.gz
bcm5719-llvm-f3a2b0e8f77041ff49441486e6cc296ff685af61.zip
ELF: Fix regression in TLS attribute mismatch logic.
Introduce a special symbol type to indicate that we have not yet seen a type for the symbol, so we should not report TLS mismatches for that symbol. Differential Revision: http://reviews.llvm.org/D19836 llvm-svn: 268411
-rw-r--r--lld/ELF/SymbolTable.cpp7
-rw-r--r--lld/ELF/Symbols.h7
-rw-r--r--lld/test/ELF/tls-archive.s10
3 files changed, 21 insertions, 3 deletions
diff --git a/lld/ELF/SymbolTable.cpp b/lld/ELF/SymbolTable.cpp
index 88747c7bb4c..852be823acb 100644
--- a/lld/ELF/SymbolTable.cpp
+++ b/lld/ELF/SymbolTable.cpp
@@ -209,7 +209,8 @@ SymbolTable<ELFT>::insert(StringRef Name, uint8_t Type, uint8_t Visibility,
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 @@ void SymbolTable<ELFT>::addLazyArchive(
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 @@ void SymbolTable<ELFT>::addLazyObject(StringRef Name, MemoryBufferRef MBRef) {
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())
diff --git a/lld/ELF/Symbols.h b/lld/ELF/Symbols.h
index b66abb479f2..78b14a71bc1 100644
--- a/lld/ELF/Symbols.h
+++ b/lld/ELF/Symbols.h
@@ -131,6 +131,13 @@ public:
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; }
diff --git a/lld/test/ELF/tls-archive.s b/lld/test/ELF/tls-archive.s
new file mode 100644
index 00000000000..5e7c825b063
--- /dev/null
+++ b/lld/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@GOTTPOFF(%rip),%edx
OpenPOWER on IntegriCloud