[lld/mac] Give __DATA,__thread_ptrs type S_THREAD_LOCAL_VARIABLE_POINTERS

...instead of S_NON_LAZY_SYMBOL_POINTERS. This matches ld64.

Part of PR50769.

While here, also remove an old TODO that was done in D87178.

Differential Revision: https://reviews.llvm.org/D104594
This commit is contained in:
Nico Weber 2021-06-19 09:54:11 -04:00
parent b9c05aff20
commit 17271ece0d
4 changed files with 35 additions and 12 deletions

View File

@ -218,7 +218,6 @@ NonLazyPointerSectionBase::NonLazyPointerSectionBase(const char *segname,
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 @@ void NonLazyPointerSectionBase::writeTo(uint8_t *buf) const {
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) {}

View File

@ -136,19 +136,12 @@ private:
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 {

View File

@ -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

View File

@ -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