[PATCH] D112500: [lld-macho] Put GOT into `__DATA` segment where appropriate
Jez Ng via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 26 08:38:16 PDT 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
int3 marked an inline comment as done.
Closed by commit rG622150ad5f21: [lld-macho] Put GOT into `__DATA` segment where appropriate (authored by int3).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D112500/new/
https://reviews.llvm.org/D112500
Files:
lld/MachO/SyntheticSections.cpp
lld/test/MachO/builtin-rename.s
Index: lld/test/MachO/builtin-rename.s
===================================================================
--- lld/test/MachO/builtin-rename.s
+++ lld/test/MachO/builtin-rename.s
@@ -55,6 +55,23 @@
# YDATA-DAG: __DATA_CONST,__objc_imageinfo __DATA__objc_imageinfo
# YDATA-DAG: __DATA_CONST,__nl_symbol_ptr __IMPORT__pointers
+## LLD doesn't support defining symbols in synthetic sections, so we test them
+## via this slightly more awkward route.
+# RUN: llvm-readobj --section-headers %t/ydata | \
+# RUN: FileCheck %s --check-prefix=SYNTH -DSEGNAME=__DATA_CONST
+# RUN: llvm-readobj --section-headers %t/ndata | \
+# RUN: FileCheck %s --check-prefix=SYNTH -DSEGNAME=__DATA
+# RUN: llvm-readobj --section-headers %t/nopie | \
+# RUN: FileCheck %s --check-prefix=SYNTH -DSEGNAME=__DATA
+# RUN: llvm-readobj --section-headers %t/old | \
+# RUN: FileCheck %s --check-prefix=SYNTH -DSEGNAME=__DATA
+
+# SYNTH: Name: __got
+# SYNTH-NEXT: Segment: [[SEGNAME]] ({{.*}})
+## Note that __la_symbol_ptr always remains in the non-const data segment.
+# SYNTH: Name: __la_symbol_ptr
+# SYNTH-NEXT: Segment: __DATA ({{.*}})
+
#--- renames.s
.section __DATA,__auth_got
.global __DATA__auth_got
@@ -81,13 +98,6 @@
__DATA__cfstring:
.space 8
-# FIXME: error: conflicts with synthetic section ...
-# FIXME: we can't explicitly define syms in synthetic sections
-# COM: .section __DATA,__got
-# COM: .global __DATA__got
-# COM: __DATA__got:
-# COM: .space 8
-
.section __DATA,__mod_init_func,mod_init_funcs
.global __DATA__mod_init_func
__DATA__mod_init_func:
@@ -128,13 +138,6 @@
__DATA__objc_imageinfo:
.space 8
-# FIXME: error: conflicts with synthetic section ...
-# FIXME: we can't explicitly define syms in synthetic sections
-# COM: .section __DATA,__la_symbol_ptr,lazy_symbol_pointers
-# COM: .global __DATA__la_symbol_ptr
-# COM: __DATA__la_symbol_ptr:
-# COM: .space 8
-
.section __IMPORT,__pointers,non_lazy_symbol_pointers
.global __IMPORT__pointers
__IMPORT__pointers:
@@ -150,4 +153,6 @@
.text
.global _main
_main:
+ mov ___nan at GOTPCREL(%rip), %rax ## ensure the __got section is created
+ callq ___isnan ## ensure the __la_symbol_ptr section is created
ret
Index: lld/MachO/SyntheticSections.cpp
===================================================================
--- lld/MachO/SyntheticSections.cpp
+++ lld/MachO/SyntheticSections.cpp
@@ -259,7 +259,7 @@
}
GotSection::GotSection()
- : NonLazyPointerSectionBase(segment_names::dataConst, section_names::got) {
+ : NonLazyPointerSectionBase(segment_names::data, section_names::got) {
flags = S_NON_LAZY_SYMBOL_POINTERS;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112500.382349.patch
Type: text/x-patch
Size: 2649 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211026/6efaa941/attachment.bin>
More information about the llvm-commits
mailing list