[lld] 4e43f18 - [lld-macho] Ensure .tbss sections are also considered as ZeroFilled
Jez Ng via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 7 11:05:10 PDT 2020
Author: Jez Ng
Date: 2020-08-07T11:04:41-07:00
New Revision: 4e43f1804817b36fee62aeb7e1eb1602245efdb6
URL: https://github.com/llvm/llvm-project/commit/4e43f1804817b36fee62aeb7e1eb1602245efdb6
DIFF: https://github.com/llvm/llvm-project/commit/4e43f1804817b36fee62aeb7e1eb1602245efdb6.diff
LOG: [lld-macho] Ensure .tbss sections are also considered as ZeroFilled
This diff makes the behavior in {D80859} and {D81888} apply to
thread-local ZeroFill sections too. I realized this was necessary whie
trying to implement thread-local variables.
Reviewed By: #lld-macho, compnerd, MaskRay
Differential Revision: https://reviews.llvm.org/D85079
Added:
Modified:
lld/MachO/InputSection.h
lld/test/MachO/bss.s
Removed:
################################################################################
diff --git a/lld/MachO/InputSection.h b/lld/MachO/InputSection.h
index 96ae0cbe6ea4..ab2ac63ac82a 100644
--- a/lld/MachO/InputSection.h
+++ b/lld/MachO/InputSection.h
@@ -36,7 +36,8 @@ struct Reloc {
};
inline bool isZeroFill(uint8_t flags) {
- return (flags & llvm::MachO::SECTION_TYPE) == llvm::MachO::S_ZEROFILL;
+ return llvm::MachO::isVirtualSection(flags & llvm::MachO::SECTION_TYPE);
+}
}
class InputSection {
diff --git a/lld/test/MachO/bss.s b/lld/test/MachO/bss.s
index b56f02d2bcb5..e41a7e27dfcf 100644
--- a/lld/test/MachO/bss.s
+++ b/lld/test/MachO/bss.s
@@ -26,7 +26,7 @@
# CHECK-NEXT: Name: __bss
# CHECK-NEXT: Segment: __DATA
# CHECK-NEXT: Address:
-# CHECK-NEXT: Size: 0x4
+# CHECK-NEXT: Size: 0x8
# CHECK-NEXT: Offset: 0
# CHECK-NEXT: Alignment: 0
# CHECK-NEXT: RelocationOffset: 0x0
@@ -38,10 +38,26 @@
# CHECK-NEXT: Reserved2: 0x0
# CHECK-NEXT: Reserved3: 0x0
+# CHECK: Index: 3
+# CHECK-NEXT: Name: __thread_bss
+# CHECK-NEXT: Segment: __DATA
+# CHECK-NEXT: Address: 0x100001010
+# CHECK-NEXT: Size: 0x4
+# CHECK-NEXT: Offset: 0
+# CHECK-NEXT: Alignment: 0
+# CHECK-NEXT: RelocationOffset: 0x0
+# CHECK-NEXT: RelocationCount: 0
+# CHECK-NEXT: Type: ThreadLocalZerofill (0x12)
+# CHECK-NEXT: Attributes [ (0x0)
+# CHECK-NEXT: ]
+# CHECK-NEXT: Reserved1: 0x0
+# CHECK-NEXT: Reserved2: 0x0
+# CHECK-NEXT: Reserved3: 0x0
+
# CHECK: Name: __DATA
# CHECK-NEXT: Size:
# CHECK-NEXT: vmaddr:
-# CHECK-NEXT: vmsize: 0xC
+# CHECK-NEXT: vmsize: 0x14
# CHECK-NEXT: fileoff:
# CHECK-NEXT: filesize: 8
@@ -55,5 +71,8 @@ _main:
.bss
.zero 4
+.tbss _foo, 4
+.zero 4
+
.data
.quad 0x1234
More information about the llvm-commits
mailing list