[llvm] 45d0343 - [MC] Allow .org directives in SHT_NOBITS sections
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 11 15:12:56 PDT 2020
Author: Fangrui Song
Date: 2020-09-11T15:12:42-07:00
New Revision: 45d0343900d3005d1d00cbb1a87c419c085dec71
URL: https://github.com/llvm/llvm-project/commit/45d0343900d3005d1d00cbb1a87c419c085dec71
DIFF: https://github.com/llvm/llvm-project/commit/45d0343900d3005d1d00cbb1a87c419c085dec71.diff
LOG: [MC] Allow .org directives in SHT_NOBITS sections
This is used by kvm-unit-tests and can be trivially supported.
Added:
Modified:
llvm/lib/MC/MCAssembler.cpp
llvm/test/MC/ELF/org.s
Removed:
################################################################################
diff --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp
index 9515b7e2642b..1b2eb2412a16 100644
--- a/llvm/lib/MC/MCAssembler.cpp
+++ b/llvm/lib/MC/MCAssembler.cpp
@@ -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;
}
}
diff --git a/llvm/test/MC/ELF/org.s b/llvm/test/MC/ELF/org.s
index ec6264f823c2..d8f52311420e 100644
--- a/llvm/test/MC/ELF/org.s
+++ b/llvm/test/MC/ELF/org.s
@@ -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$}}
More information about the llvm-commits
mailing list