Make sure .text doesn't produce extra alignment.
authorRafael Espindola <rafael.espindola@gmail.com>
Mon, 27 Sep 2010 21:40:27 +0000 (21:40 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Mon, 27 Sep 2010 21:40:27 +0000 (21:40 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114895 91177308-0d34-0410-b5e6-96231b3b80d8

lib/MC/MCParser/ELFAsmParser.cpp
test/MC/ELF/align-text.s [new file with mode: 0644]

index 072befadd5f333595dc39502c5319cce32e2594e..7d8f68f1b0c51b367b8afa10dfe0224d29cdacd6 100644 (file)
@@ -54,25 +54,19 @@ public:
   // FIXME: Part of this logic is duplicated in the MCELFStreamer. What is
   // the best way for us to get access to it?
   bool ParseSectionDirectiveData(StringRef, SMLoc) {
-    bool ret =  ParseSectionSwitch(".data", MCSectionELF::SHT_PROGBITS,
+    return ParseSectionSwitch(".data", MCSectionELF::SHT_PROGBITS,
                               MCSectionELF::SHF_WRITE |MCSectionELF::SHF_ALLOC,
                               SectionKind::getDataRel());
-    getStreamer().EmitCodeAlignment(4, 0);
-    return ret;
   }
   bool ParseSectionDirectiveText(StringRef, SMLoc) {
-    bool ret = ParseSectionSwitch(".text", MCSectionELF::SHT_PROGBITS,
+    return ParseSectionSwitch(".text", MCSectionELF::SHT_PROGBITS,
                               MCSectionELF::SHF_EXECINSTR |
                               MCSectionELF::SHF_ALLOC, SectionKind::getText());
-    getStreamer().EmitCodeAlignment(4, 0);
-    return ret;
   }
   bool ParseSectionDirectiveBSS(StringRef, SMLoc) {
-    bool ret = ParseSectionSwitch(".bss", MCSectionELF::SHT_NOBITS,
+    return ParseSectionSwitch(".bss", MCSectionELF::SHT_NOBITS,
                               MCSectionELF::SHF_WRITE |
                               MCSectionELF::SHF_ALLOC, SectionKind::getBSS());
-    getStreamer().EmitCodeAlignment(4, 0);
-    return ret;
   }
   bool ParseSectionDirectiveRoData(StringRef, SMLoc) {
     return ParseSectionSwitch(".rodata", MCSectionELF::SHT_PROGBITS,
diff --git a/test/MC/ELF/align-text.s b/test/MC/ELF/align-text.s
new file mode 100644 (file)
index 0000000..4f4497c
--- /dev/null
@@ -0,0 +1,19 @@
+// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | elf-dump  | FileCheck %s
+
+// Test that the .text directive doesn't cause alignment.
+
+        .zero 1
+        .text
+        .zero 1
+
+// CHECK:      (('sh_name', 1) # '.text'
+// CHECK-NEXT:  ('sh_type', 1)
+// CHECK-NEXT:  ('sh_flags', 6)
+// CHECK-NEXT:   ('sh_addr', 0)
+// CHECK-NEXT:   ('sh_offset', 64)
+// CHECK-NEXT:   ('sh_size', 2)
+// CHECK-NEXT:   ('sh_link', 0)
+// CHECK-NEXT:   ('sh_info', 0)
+// CHECK-NEXT:   ('sh_addralign', 4)
+// CHECK-NEXT:   ('sh_entsize', 0)
+// CHECK-NEXT:  ),