Index: ELF/Arch/X86_64.cpp =================================================================== --- ELF/Arch/X86_64.cpp +++ ELF/Arch/X86_64.cpp @@ -81,6 +81,9 @@ template RelExpr X86_64::getRelExpr(RelType Type, const Symbol &S, const uint8_t *Loc) const { + if (Type == R_X86_64_GOTTPOFF) + Config->HasStaticTlsModel = true; + switch (Type) { case R_X86_64_8: case R_X86_64_16: Index: test/ELF/x86_64-static-tls-model.s =================================================================== --- /dev/null +++ test/ELF/x86_64-static-tls-model.s @@ -0,0 +1,18 @@ +# REQUIRES: x86 + +## In this test R_X86_64_GOTTPOFF is a IE relocation (static TLS model), +## test check we add STATIC_TLS flag. + +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o +# RUN: ld.lld %t.o -o %t1 -shared +# RUN: llvm-readobj -dynamic-table %t1 | FileCheck %s + +# CHECK: DynamicSection [ +# CHECK: FLAGS STATIC_TLS + +.section ".tdata", "awT", @progbits +.globl var +var: + +movq var@GOTTPOFF(%rip), %rax # R_X86_64_GOTTPOFF +movl %fs:0(%rax), %eax