diff --git a/lld/MachO/SyntheticSections.h b/lld/MachO/SyntheticSections.h --- a/lld/MachO/SyntheticSections.h +++ b/lld/MachO/SyntheticSections.h @@ -136,19 +136,12 @@ class GotSection final : public NonLazyPointerSectionBase { public: - GotSection() - : NonLazyPointerSectionBase(segment_names::dataConst, - section_names::got) { - // TODO: section_64::reserved1 should be an index into the indirect symbol - // table, which we do not currently emit - } + GotSection(); }; class TlvPointerSection final : public NonLazyPointerSectionBase { public: - TlvPointerSection() - : NonLazyPointerSectionBase(segment_names::data, - section_names::threadPtrs) {} + TlvPointerSection(); }; struct Location { diff --git a/lld/MachO/SyntheticSections.cpp b/lld/MachO/SyntheticSections.cpp --- a/lld/MachO/SyntheticSections.cpp +++ b/lld/MachO/SyntheticSections.cpp @@ -218,7 +218,6 @@ const char *name) : SyntheticSection(segname, name) { align = target->wordSize; - flags = S_NON_LAZY_SYMBOL_POINTERS; } void macho::addNonLazyBindingEntries(const Symbol *sym, @@ -254,6 +253,17 @@ write64le(&buf[i * target->wordSize], defined->getVA()); } +GotSection::GotSection() + : NonLazyPointerSectionBase(segment_names::dataConst, section_names::got) { + flags = S_NON_LAZY_SYMBOL_POINTERS; +} + +TlvPointerSection::TlvPointerSection() + : NonLazyPointerSectionBase(segment_names::data, + section_names::threadPtrs) { + flags = S_THREAD_LOCAL_VARIABLE_POINTERS; +} + BindingSection::BindingSection() : LinkEditSection(segment_names::linkEdit, section_names::binding) {} diff --git a/lld/test/MachO/tlv-dylib.s b/lld/test/MachO/tlv-dylib.s --- a/lld/test/MachO/tlv-dylib.s +++ b/lld/test/MachO/tlv-dylib.s @@ -26,6 +26,26 @@ # CHECK-DAG: __DATA __thread_ptrs 0x{{0*}}[[#%x, BAR]] pointer 0 libtlv _bar # CHECK-DAG: __DATA_CONST __got 0x{{0*}}[[#%x, BAZ]] pointer 0 libtlv _baz +# RUN: llvm-otool -lv %t/test | FileCheck --check-prefix=FLAGS %s +# FLAGS: sectname __got +# FLAGS-NEXT: segname __DATA_CONST +# FLAGS-NEXT: addr +# FLAGS-NEXT: size 0x0000000000000008 +# FLAGS-NEXT: offset +# FLAGS-NEXT: align 2^3 (8) +# FLAGS-NEXT: reloff 0 +# FLAGS-NEXT: nreloc 0 +# FLAGS-NEXT: type S_NON_LAZY_SYMBOL_POINTERS +# FLAGS: sectname __thread_ptrs +# FLAGS-NEXT: segname __DATA +# FLAGS-NEXT: addr +# FLAGS-NEXT: size 0x0000000000000010 +# FLAGS-NEXT: offset +# FLAGS-NEXT: align 2^3 (8) +# FLAGS-NEXT: reloff 0 +# FLAGS-NEXT: nreloc 0 +# FLAGS-NEXT: type S_THREAD_LOCAL_VARIABLE_POINTERS + #--- libtlv.s .section __DATA,__thread_vars,thread_local_variables .globl _foo, _bar, _baz diff --git a/lld/test/MachO/tlv.s b/lld/test/MachO/tlv.s --- a/lld/test/MachO/tlv.s +++ b/lld/test/MachO/tlv.s @@ -4,13 +4,13 @@ # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/tbss.s -o %t/tbss.o # RUN: %lld -lSystem -no_pie -o %t/regular %t/regular.o -# RUN: llvm-readobj --file-headers %t/regular | FileCheck %s --check-prefix=HEADER +# RUN: llvm-otool -hv %t/regular | FileCheck %s --check-prefix=HEADER # RUN: llvm-objdump -d --bind --rebase %t/regular | FileCheck %s --check-prefixes=REG,LINKEDIT # RUN: llvm-objdump --macho --section=__DATA,__thread_vars %t/regular | \ # RUN: FileCheck %s --check-prefix=REG-TLVP # RUN: %lld -lSystem -pie %t/regular.o -o %t/regular-pie -# RUN: llvm-readobj --file-headers %t/regular-pie | FileCheck %s --check-prefix=HEADER +# RUN: llvm-otool -hv %t/regular-pie | FileCheck %s --check-prefix=HEADER # RUN: llvm-objdump -d --bind --rebase %t/regular-pie | FileCheck %s --check-prefixes=REG,LINKEDIT # RUN: llvm-objdump --macho --section=__DATA,__thread_vars %t/regular-pie | \ # RUN: FileCheck %s --check-prefix=REG-TLVP