[MC] Allow .org directives in SHT_NOBITS sections

This is used by kvm-unit-tests and can be trivially supported.
This commit is contained in:
Fangrui Song 2020-09-11 15:12:15 -07:00
parent 43e6c59f1c
commit 45d0343900
2 changed files with 17 additions and 9 deletions

View File

@ -754,6 +754,8 @@ void MCAssembler::writeSectionData(raw_ostream &OS, const MCSection *Sec,
assert((cast<MCFillFragment>(F).getValue() == 0) &&
"Invalid fill in virtual section!");
break;
case MCFragment::FT_Org:
break;
}
}

View File

@ -1,15 +1,21 @@
// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | llvm-readobj -S - | FileCheck %s
# RUN: llvm-mc -filetype=obj -triple x86_64 %s -o - | llvm-readobj -S - | FileCheck %s --strict-whitespace
.zero 4
foo:
.zero 4
.org foo+16
// CHECK: Section {
// CHECK: Name: .text
// CHECK-NEXT: Type:
// CHECK-NEXT: Flags [
// CHECK: ]
// CHECK-NEXT: Address:
// CHECK-NEXT: Offset:
// CHECK-NEXT: Size: 20
.bss
.zero 1
# .org is a zero initializer and can appear in a SHT_NOBITS section.
.org .bss+5
# CHECK: Section {
# CHECK: Name: .text
# CHECK: Size:
# CHECK-SAME: {{ 20$}}
# CHECK: Section {
# CHECK: Name: .bss
# CHECK: Size:
# CHECK-SAME: {{ 5$}}