[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
This commit is contained in:
Jez Ng 2020-08-07 11:04:41 -07:00
parent 911565d108
commit 4e43f18048
2 changed files with 23 additions and 3 deletions

View File

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

View File

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