[lld] 17271ec - [lld/mac] Give __DATA,__thread_ptrs type S_THREAD_LOCAL_VARIABLE_POINTERS
Nico Weber via llvm-commits
llvm-commits at lists.llvm.org
Sat Jun 19 09:57:23 PDT 2021
Author: Nico Weber
Date: 2021-06-19T12:56:42-04:00
New Revision: 17271ece0da69c4dde0bbab60883b7fdd05be131
URL: https://github.com/llvm/llvm-project/commit/17271ece0da69c4dde0bbab60883b7fdd05be131
DIFF: https://github.com/llvm/llvm-project/commit/17271ece0da69c4dde0bbab60883b7fdd05be131.diff
LOG: [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
Added:
Modified:
lld/MachO/SyntheticSections.cpp
lld/MachO/SyntheticSections.h
lld/test/MachO/tlv-dylib.s
lld/test/MachO/tlv.s
Removed:
################################################################################
diff --git a/lld/MachO/SyntheticSections.cpp b/lld/MachO/SyntheticSections.cpp
index fec43002bb46..a5d21dcbaeb3 100644
--- a/lld/MachO/SyntheticSections.cpp
+++ b/lld/MachO/SyntheticSections.cpp
@@ -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) {}
diff --git a/lld/MachO/SyntheticSections.h b/lld/MachO/SyntheticSections.h
index 36141772697b..3b2605871009 100644
--- a/lld/MachO/SyntheticSections.h
+++ b/lld/MachO/SyntheticSections.h
@@ -136,19 +136,12 @@ class NonLazyPointerSectionBase : public SyntheticSection {
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/test/MachO/tlv-dylib.s b/lld/test/MachO/tlv-dylib.s
index bb40475aa226..d02f78765675 100644
--- 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
index 6263e37f7804..a7e032b01a4a 100644
--- 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
More information about the llvm-commits
mailing list