forked from OSchip/llvm-project
[elf2] Correctly determine if we should ignore missing __tls_get_addr.
llvm-svn: 249462
This commit is contained in:
parent
28ac01bfc8
commit
f32446fb65
|
|
@ -133,13 +133,6 @@ template <class ELFT> void SymbolTable::init(uint16_t EMachine) {
|
||||||
// Given that the symbol is effectively unused, we just create a dummy
|
// Given that the symbol is effectively unused, we just create a dummy
|
||||||
// hidden one to avoid the undefined symbol error.
|
// hidden one to avoid the undefined symbol error.
|
||||||
addIgnoredSym<ELFT>("_GLOBAL_OFFSET_TABLE_");
|
addIgnoredSym<ELFT>("_GLOBAL_OFFSET_TABLE_");
|
||||||
|
|
||||||
// __tls_get_addr is defined by the dynamic linker for dynamic ELFs. For
|
|
||||||
// static linking the linker is required to optimize away any references to
|
|
||||||
// __tls_get_addr, so it's not defined anywhere. Create a hidden definition
|
|
||||||
// to avoid the undefined symbol error.
|
|
||||||
if (Config->Static)
|
|
||||||
addIgnoredSym<ELFT>("__tls_get_addr");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class ELFT> void SymbolTable::addELFFile(ELFFileBase *File) {
|
template <class ELFT> void SymbolTable::addELFFile(ELFFileBase *File) {
|
||||||
|
|
|
||||||
|
|
@ -105,9 +105,10 @@ private:
|
||||||
return !SymTabSec.getSymTable().getSharedFiles().empty() &&
|
return !SymTabSec.getSymTable().getSharedFiles().empty() &&
|
||||||
!Config->DynamicLinker.empty();
|
!Config->DynamicLinker.empty();
|
||||||
}
|
}
|
||||||
bool needsDynamicSections() const {
|
bool isOutputDynamic() const {
|
||||||
return !SymTabSec.getSymTable().getSharedFiles().empty() || Config->Shared;
|
return !SymTabSec.getSymTable().getSharedFiles().empty() || Config->Shared;
|
||||||
}
|
}
|
||||||
|
bool needsDynamicSections() const { return isOutputDynamic(); }
|
||||||
unsigned getVAStart() const { return Config->Shared ? 0 : VAStart; }
|
unsigned getVAStart() const { return Config->Shared ? 0 : VAStart; }
|
||||||
|
|
||||||
std::unique_ptr<llvm::FileOutputBuffer> Buffer;
|
std::unique_ptr<llvm::FileOutputBuffer> Buffer;
|
||||||
|
|
@ -347,6 +348,13 @@ template <class ELFT> void Writer<ELFT>::createSections() {
|
||||||
AddStartEnd("__fini_array_start", "__fini_array_end",
|
AddStartEnd("__fini_array_start", "__fini_array_end",
|
||||||
DynamicSec.FiniArraySec);
|
DynamicSec.FiniArraySec);
|
||||||
|
|
||||||
|
// __tls_get_addr is defined by the dynamic linker for dynamic ELFs. For
|
||||||
|
// static linking the linker is required to optimize away any references to
|
||||||
|
// __tls_get_addr, so it's not defined anywhere. Create a hidden definition
|
||||||
|
// to avoid the undefined symbol error.
|
||||||
|
if (!isOutputDynamic())
|
||||||
|
Symtab.addIgnoredSym<ELFT>("__tls_get_addr");
|
||||||
|
|
||||||
// FIXME: Try to avoid the extra walk over all global symbols.
|
// FIXME: Try to avoid the extra walk over all global symbols.
|
||||||
std::vector<DefinedCommon<ELFT> *> CommonSymbols;
|
std::vector<DefinedCommon<ELFT> *> CommonSymbols;
|
||||||
for (auto &P : Symtab.getSymbols()) {
|
for (auto &P : Symtab.getSymbols()) {
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,11 @@
|
||||||
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t
|
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t
|
||||||
|
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/shared.s -o %tso
|
||||||
// RUN: lld -flavor gnu2 -static %t -o %tout
|
// RUN: lld -flavor gnu2 -static %t -o %tout
|
||||||
|
// RUN: lld -flavor gnu2 %t -o %tout
|
||||||
|
// RUN: lld -flavor gnu2 -shared %tso -o %tshared
|
||||||
|
// RUN: not lld -flavor gnu2 -static %t %tshared -o %tout
|
||||||
// REQUIRES: x86
|
// REQUIRES: x86
|
||||||
|
|
||||||
.global _start
|
.global _start
|
||||||
.text
|
|
||||||
_start:
|
_start:
|
||||||
call __tls_get_addr
|
call __tls_get_addr
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue