From 556ddccf740f5142a3e3ff94ae0bd819c8c6e161 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Tue, 3 Nov 2015 20:02:22 +0000 Subject: [PATCH] Don't create empty sections just to look like gas. We are long past the time when this much bug for bug compatibility was useful. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@251970 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/MC/MCELFStreamer.cpp | 10 ------ test/MC/ARM/eh-directive-section-comdat.s | 16 ++++----- .../ARM/eh-directive-section-multiple-func.s | 4 +-- test/MC/ARM/eh-directive-section.s | 8 ++--- test/MC/ARM/eh-link.s | 12 +++---- test/MC/ELF/align.s | 14 ++++---- test/MC/ELF/comdat-dup-group-name.s | 12 +++---- test/MC/ELF/comdat-reloc.s | 6 ++-- test/MC/ELF/comdat.s | 14 ++++---- test/MC/ELF/empty.s | 36 ++----------------- test/MC/ELF/many-sections-2.s | 3 ++ test/MC/ELF/many-sections-3.s | 2 ++ test/MC/ELF/many-sections.s | 3 +- test/MC/ELF/section-sym.s | 18 +++++----- test/MC/ELF/section-unique.s | 4 +-- test/MC/ELF/strtab-suffix-opt.s | 6 ++-- 16 files changed, 66 insertions(+), 102 deletions(-) diff --git a/lib/MC/MCELFStreamer.cpp b/lib/MC/MCELFStreamer.cpp index 7b45506a349..06d161bccab 100644 --- a/lib/MC/MCELFStreamer.cpp +++ b/lib/MC/MCELFStreamer.cpp @@ -86,20 +86,10 @@ void MCELFStreamer::mergeFragment(MCDataFragment *DF, } void MCELFStreamer::InitSections(bool NoExecStack) { - // This emulates the same behavior of GNU as. This makes it easier - // to compare the output as the major sections are in the same order. MCContext &Ctx = getContext(); SwitchSection(Ctx.getObjectFileInfo()->getTextSection()); EmitCodeAlignment(4); - SwitchSection(Ctx.getObjectFileInfo()->getDataSection()); - EmitCodeAlignment(4); - - SwitchSection(Ctx.getObjectFileInfo()->getBSSSection()); - EmitCodeAlignment(4); - - SwitchSection(Ctx.getObjectFileInfo()->getTextSection()); - if (NoExecStack) SwitchSection(Ctx.getAsmInfo()->getNonexecutableStackSection(Ctx)); } diff --git a/test/MC/ARM/eh-directive-section-comdat.s b/test/MC/ARM/eh-directive-section-comdat.s index 9c7160ea5e7..8b7f32eaece 100644 --- a/test/MC/ARM/eh-directive-section-comdat.s +++ b/test/MC/ARM/eh-directive-section-comdat.s @@ -53,8 +53,8 @@ func1: @ These are the section indexes of .TEST1, .ARM.extab.TEST1, .ARM.exidx.TEST1, @ .rel.ARM.extab.TEST1, and .rel.ARM.exidx.TEST1. @------------------------------------------------------------------------------- -@ CHECK-NEXT: 0000: 01000000 06000000 07000000 08000000 -@ CHECK-NEXT: 0010: 09000000 0A000000 +@ CHECK-NEXT: 0000: 01000000 04000000 05000000 06000000 +@ CHECK-NEXT: 0010: 07000000 08000000 @ CHECK-NEXT: ) @ CHECK: } @@ -63,7 +63,7 @@ func1: @ Check the .TEST1 section @------------------------------------------------------------------------------- @ CHECK: Section { -@ CHECK: Index: 6 +@ CHECK: Index: 4 @ CHECK-NEXT: Name: .TEST1 @ CHECK: Type: SHT_PROGBITS (0x1) @------------------------------------------------------------------------------- @@ -81,7 +81,7 @@ func1: @ Check the .ARM.extab.TEST1 section @------------------------------------------------------------------------------- @ CHECK: Section { -@ CHECK: Index: 7 +@ CHECK: Index: 5 @ CHECK-NEXT: Name: .ARM.extab.TEST1 @ CHECK: Type: SHT_PROGBITS (0x1) @------------------------------------------------------------------------------- @@ -94,7 +94,7 @@ func1: @ CHECK: } @ CHECK: Section { -@ CHECK: Index: 8 +@ CHECK: Index: 6 @ CHECK-NEXT: Name: .rel.ARM.extab.TEST1 @ CHECK: } @@ -102,7 +102,7 @@ func1: @ Check the .ARM.exidx.TEST1 section @------------------------------------------------------------------------------- @ CHECK: Section { -@ CHECK: Index: 9 +@ CHECK: Index: 7 @ CHECK-NEXT: Name: .ARM.exidx.TEST1 @ CHECK: Type: SHT_ARM_EXIDX (0x70000001) @------------------------------------------------------------------------------- @@ -113,12 +113,12 @@ func1: @ CHECK: SHF_GROUP (0x200) @ CHECK: SHF_LINK_ORDER (0x80) @ CHECK: ] -@ CHECK: Link: 6 +@ CHECK: Link: 4 @ CHECK: } @ CHECK: Section { -@ CHECK: Index: 10 +@ CHECK: Index: 8 @ CHECK-NEXT: Name: .rel.ARM.exidx.TEST1 @ CHECK: } diff --git a/test/MC/ARM/eh-directive-section-multiple-func.s b/test/MC/ARM/eh-directive-section-multiple-func.s index e5307cf9190..53c498ab87b 100644 --- a/test/MC/ARM/eh-directive-section-multiple-func.s +++ b/test/MC/ARM/eh-directive-section-multiple-func.s @@ -54,7 +54,7 @@ func2: @ Check the .TEST1 section. There should be two "bx lr" instructions. @------------------------------------------------------------------------------- @ CHECK: Section { -@ CHECK: Index: 5 +@ CHECK: Index: 3 @ CHECK-NEXT: Name: .TEST1 @ CHECK: SectionData ( @ CHECK: 0000: 1EFF2FE1 1EFF2FE1 |../.../.| @@ -87,7 +87,7 @@ func2: @------------------------------------------------------------------------------- @ CHECK: Section { @ CHECK: Name: .ARM.exidx.TEST1 -@ CHECK: Link: 5 +@ CHECK: Link: 3 @------------------------------------------------------------------------------- @ The first word should be the offset to .TEST1. @ The second word should be the offset to .ARM.extab.TEST1 diff --git a/test/MC/ARM/eh-directive-section.s b/test/MC/ARM/eh-directive-section.s index e36d9a99aaf..bd41fbe5eee 100644 --- a/test/MC/ARM/eh-directive-section.s +++ b/test/MC/ARM/eh-directive-section.s @@ -50,7 +50,7 @@ func2: @------------------------------------------------------------------------------- @ CHECK: Sections [ @ CHECK: Section { -@ CHECK: Index: 5 +@ CHECK: Index: 3 @ CHECK-NEXT: Name: .TEST1 @ CHECK: SectionData ( @ CHECK: 0000: 1EFF2FE1 |../.| @@ -84,7 +84,7 @@ func2: @------------------------------------------------------------------------------- @ This section should linked with .TEST1 section. @------------------------------------------------------------------------------- -@ CHECK: Link: 5 +@ CHECK: Link: 3 @------------------------------------------------------------------------------- @ The first word should be relocated to the code address in .TEST1 section. @@ -109,7 +109,7 @@ func2: @ Check the TEST2 section (without the dot in the beginning) @------------------------------------------------------------------------------- @ CHECK: Section { -@ CHECK: Index: 10 +@ CHECK: Index: 8 @ CHECK-NEXT: Name: TEST2 @ CHECK: SectionData ( @ CHECK: 0000: 1EFF2FE1 |../.| @@ -143,7 +143,7 @@ func2: @------------------------------------------------------------------------------- @ This section should linked with TEST2 section. @------------------------------------------------------------------------------- -@ CHECK: Link: 10 +@ CHECK: Link: 8 @------------------------------------------------------------------------------- @ The first word should be relocated to the code address in TEST2 section. diff --git a/test/MC/ARM/eh-link.s b/test/MC/ARM/eh-link.s index e14fb0638b9..19fe14db5f3 100644 --- a/test/MC/ARM/eh-link.s +++ b/test/MC/ARM/eh-link.s @@ -8,7 +8,7 @@ @ name first we could use a FileCheck variable. @ CHECK: Section { -@ CHECK: Index: 6 +@ CHECK: Index: 4 @ CHECK-NEXT: Name: .text @ CHECK-NEXT: Type: SHT_PROGBITS @ CHECK-NEXT: Flags [ @@ -25,7 +25,7 @@ @ CHECK-NEXT: EntrySize: 0 @ CHECK-NEXT: } @ CHECK-NEXT: Section { -@ CHECK-NEXT: Index: 7 +@ CHECK-NEXT: Index: 5 @ CHECK-NEXT: Name: .ARM.exidx @ CHECK-NEXT: Type: SHT_ARM_EXIDX @ CHECK-NEXT: Flags [ @@ -36,14 +36,14 @@ @ CHECK-NEXT: Address: 0x0 @ CHECK-NEXT: Offset: @ CHECK-NEXT: Size: 8 -@ CHECK-NEXT: Link: 6 +@ CHECK-NEXT: Link: 4 @ CHECK-NEXT: Info: 0 @ CHECK-NEXT: AddressAlignment: 4 @ CHECK-NEXT: EntrySize: 0 @ CHECK-NEXT: } @ CHECK: Section { -@ CHECK: Index: 10 +@ CHECK: Index: 8 @ CHECK-NEXT: Name: .text @ CHECK-NEXT: Type: SHT_PROGBITS @ CHECK-NEXT: Flags [ @@ -60,7 +60,7 @@ @ CHECK-NEXT: EntrySize: 0 @ CHECK-NEXT: } @ CHECK-NEXT: Section { -@ CHECK-NEXT: Index: 11 +@ CHECK-NEXT: Index: 9 @ CHECK-NEXT: Name: .ARM.exidx @ CHECK-NEXT: Type: SHT_ARM_EXIDX @ CHECK-NEXT: Flags [ @@ -71,7 +71,7 @@ @ CHECK-NEXT: Address: 0x0 @ CHECK-NEXT: Offset: @ CHECK-NEXT: Size: 8 -@ CHECK-NEXT: Link: 10 +@ CHECK-NEXT: Link: 8 @ CHECK-NEXT: Info: 0 @ CHECK-NEXT: AddressAlignment: 4 @ CHECK-NEXT: EntrySize: 0 diff --git a/test/MC/ELF/align.s b/test/MC/ELF/align.s index 43f5b548d9e..7e78298540f 100644 --- a/test/MC/ELF/align.s +++ b/test/MC/ELF/align.s @@ -1,22 +1,22 @@ // RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | llvm-readobj -s | FileCheck %s // Test that the alignment of rodata doesn't force a alignment of the -// previous section (.bss) +// previous section (.text) nop .section .rodata,"a",@progbits .align 8 // CHECK: Section { -// CHECK: Name: .bss -// CHECK-NEXT: Type: SHT_NOBITS +// CHECK: Name: .text +// CHECK-NEXT: Type: // CHECK-NEXT: Flags [ // CHECK-NEXT: SHF_ALLOC -// CHECK-NEXT: SHF_WRITE +// CHECK-NEXT: SHF_EXECINSTR // CHECK-NEXT: ] -// CHECK-NEXT: Address: 0x0 -// CHECK-NEXT: Offset: 0x44 -// CHECK-NEXT: Size: 0 +// CHECK-NEXT: Address: +// CHECK-NEXT: Offset: +// CHECK-NEXT: Size: // CHECK-NEXT: Link: 0 // CHECK-NEXT: Info: 0 // CHECK-NEXT: AddressAlignment: 4 diff --git a/test/MC/ELF/comdat-dup-group-name.s b/test/MC/ELF/comdat-dup-group-name.s index e52f3dcc04d..e11cba62b40 100644 --- a/test/MC/ELF/comdat-dup-group-name.s +++ b/test/MC/ELF/comdat-dup-group-name.s @@ -2,27 +2,27 @@ // Test that we produce two foo sections, each in separate groups -// CHECK: Index: 5 +// CHECK: Index: 3 // CHECK-NEXT: Name: .group -// CHECK: Index: 6 +// CHECK: Index: 4 // CHECK-NEXT: Name: .foo -// CHECK: Index: 7 +// CHECK: Index: 5 // CHECK-NEXT: Name: .group -// CHECK: Index: 8 +// CHECK: Index: 6 // CHECK-NEXT: Name: .foo // CHECK: Symbols [ // CHECK: Name: f1 // CHECK-NOT: } -// CHECK: Section: .group (0x5) +// CHECK: Section: .group (0x3) // CHECK: Name: f2 // CHECK-NOT: } -// CHECK: Section: .group (0x7) +// CHECK: Section: .group (0x5) .section .foo,"axG",@progbits,f1,comdat nop diff --git a/test/MC/ELF/comdat-reloc.s b/test/MC/ELF/comdat-reloc.s index 1ea3d1e57ef..bc126f67fee 100644 --- a/test/MC/ELF/comdat-reloc.s +++ b/test/MC/ELF/comdat-reloc.s @@ -16,14 +16,14 @@ world: // CHECK: Name: .group // CHECK-NOT: SectionData // CHECK: SectionData -// CHECK-NEXT: 0000: 01000000 07000000 08000000 +// CHECK-NEXT: 0000: 01000000 05000000 06000000 -// CHECK: Index: 7 +// CHECK: Index: 5 // CHECK-NEXT: Name: .text.world // CHECK-NOT: Section { // CHECK: SHF_GROUP -// CHECK: Index: 8 +// CHECK: Index: 6 // CHECK-NEXT: Name: .rela.text.world // CHECK-NOT: Section { // CHECK: SHF_GROUP diff --git a/test/MC/ELF/comdat.s b/test/MC/ELF/comdat.s index 18da17e6118..5e6fc64bac4 100644 --- a/test/MC/ELF/comdat.s +++ b/test/MC/ELF/comdat.s @@ -3,7 +3,7 @@ // Test that we produce the group sections and that they are before the members // CHECK: Section { -// CHECK: Index: 5 +// CHECK: Index: 3 // CHECK-NEXT: Name: .group // CHECK-NEXT: Type: SHT_GROUP // CHECK-NEXT: Flags [ @@ -16,11 +16,11 @@ // CHECK-NEXT: AddressAlignment: 4 // CHECK-NEXT: EntrySize: 4 // CHECK-NEXT: SectionData ( -// CHECK-NEXT: 0000: 01000000 06000000 07000000 +// CHECK-NEXT: 0000: 01000000 04000000 05000000 // CHECK-NEXT: ) // CHECK-NEXT: } // CHECK: Section { -// CHECK: Index: 8 +// CHECK: Index: 6 // CHECK-NEXT: Name: .group // CHECK-NEXT: Type: SHT_GROUP // CHECK-NEXT: Flags [ @@ -33,11 +33,11 @@ // CHECK-NEXT: AddressAlignment: 4 // CHECK-NEXT: EntrySize: 4 // CHECK-NEXT: SectionData ( -// CHECK-NEXT: 0000: 01000000 09000000 +// CHECK-NEXT: 0000: 01000000 07000000 // CHECK-NEXT: ) // CHECK-NEXT: } // CHECK: Section { -// CHECK: Index: 10 +// CHECK: Index: 8 // CHECK-NEXT: Name: .group // CHECK-NEXT: Type: SHT_GROUP // CHECK-NEXT: Flags [ @@ -50,7 +50,7 @@ // CHECK-NEXT: AddressAlignment: 4 // CHECK-NEXT: EntrySize: 4 // CHECK-NEXT: SectionData ( -// CHECK-NEXT: 0000: 01000000 0B000000 0C000000 +// CHECK-NEXT: 0000: 01000000 09000000 0A000000 // CHECK-NEXT: ) // CHECK-NEXT: } @@ -72,7 +72,7 @@ // CHECK-NEXT: Binding: Local // CHECK-NEXT: Type: None // CHECK-NEXT: Other: 0 -// CHECK-NEXT: Section: .group (0x8) +// CHECK-NEXT: Section: .group // CHECK-NEXT: } // CHECK: Symbol { diff --git a/test/MC/ELF/empty.s b/test/MC/ELF/empty.s index 7b686fef3a2..ea88803a31d 100644 --- a/test/MC/ELF/empty.s +++ b/test/MC/ELF/empty.s @@ -10,8 +10,8 @@ // DARWIN-NEXT: Arch: x86_64 // WINDOWS-NEXT: Arch: x86_64 -// Test that like gnu as we create text, data and bss by default. Also test -// that symtab and strtab are listed. +// Test that we create text by default. Also test that symtab and strtab are +// listed. // CHECK: Section { // CHECK: Name: .strtab @@ -20,7 +20,7 @@ // CHECK-NEXT: ] // CHECK-NEXT: Address: 0x0 // CHECK-NEXT: Offset: -// CHECK-NEXT: Size: 34 +// CHECK-NEXT: Size: 23 // CHECK-NEXT: Link: 0 // CHECK-NEXT: Info: 0 // CHECK-NEXT: AddressAlignment: 1 @@ -42,36 +42,6 @@ // CHECK-NEXT: EntrySize: 0 // CHECK-NEXT: } // CHECK: Section { -// CHECK: Name: .data -// CHECK-NEXT: Type: SHT_PROGBITS -// CHECK-NEXT: Flags [ -// CHECK-NEXT: SHF_ALLOC -// CHECK-NEXT: SHF_WRITE -// CHECK-NEXT: ] -// CHECK-NEXT: Address: 0x0 -// CHECK-NEXT: Offset: 0x40 -// CHECK-NEXT: Size: 0 -// CHECK-NEXT: Link: 0 -// CHECK-NEXT: Info: 0 -// CHECK-NEXT: AddressAlignment: 4 -// CHECK-NEXT: EntrySize: 0 -// CHECK-NEXT: } -// CHECK: Section { -// CHECK: Name: .bss -// CHECK-NEXT: Type: SHT_NOBITS -// CHECK-NEXT: Flags [ -// CHECK-NEXT: SHF_ALLOC -// CHECK-NEXT: SHF_WRITE -// CHECK-NEXT: ] -// CHECK-NEXT: Address: 0x0 -// CHECK-NEXT: Offset: 0x40 -// CHECK-NEXT: Size: 0 -// CHECK-NEXT: Link: 0 -// CHECK-NEXT: Info: 0 -// CHECK-NEXT: AddressAlignment: 4 -// CHECK-NEXT: EntrySize: 0 -// CHECK-NEXT: } -// CHECK: Section { // CHECK: Name: .symtab // CHECK-NEXT: Type: SHT_SYMTAB // CHECK-NEXT: Flags [ diff --git a/test/MC/ELF/many-sections-2.s b/test/MC/ELF/many-sections-2.s index 0077552ef31..2c3e4b87bb8 100644 --- a/test/MC/ELF/many-sections-2.s +++ b/test/MC/ELF/many-sections-2.s @@ -114,6 +114,9 @@ gen_sections16384 b\x .endm + .section foo + .section bar + gen_sections32768 a gen_sections16384 b gen_sections8192 c diff --git a/test/MC/ELF/many-sections-3.s b/test/MC/ELF/many-sections-3.s index 02d30a60523..ec198480916 100644 --- a/test/MC/ELF/many-sections-3.s +++ b/test/MC/ELF/many-sections-3.s @@ -102,6 +102,8 @@ gen_sections8 l gen_sections4 m .section foo + .section foo2 + .section foo3 .section bar, "a" a: diff --git a/test/MC/ELF/many-sections.s b/test/MC/ELF/many-sections.s index 2db6abb9321..b1348f3b7c3 100644 --- a/test/MC/ELF/many-sections.s +++ b/test/MC/ELF/many-sections.s @@ -103,7 +103,6 @@ gen_sections64 i gen_sections32 j gen_sections16 k gen_sections8 l - .section foo - .section bar +gen_sections4 m .section zed .long zed diff --git a/test/MC/ELF/section-sym.s b/test/MC/ELF/section-sym.s index 4a9484d9b77..9e660526b7a 100644 --- a/test/MC/ELF/section-sym.s +++ b/test/MC/ELF/section-sym.s @@ -9,8 +9,8 @@ // The first seciton foo has index 6 // CHECK: Section { -// CHECK: Index: 6 -// CHECK-NEXT: Name: foo (28) +// CHECK: Index: 4 +// CHECK-NEXT: Name: foo // CHECK-NEXT: Type: SHT_PROGBITS (0x1) // CHECK-NEXT: Flags [ (0x202) // CHECK-NEXT: SHF_ALLOC (0x2) @@ -25,8 +25,8 @@ // CHECK-NEXT: EntrySize: 0 // CHECK-NEXT: } // CHECK: Section { -// CHECK: Index: 8 -// CHECK-NEXT: Name: foo (28) +// CHECK: Index: 6 +// CHECK-NEXT: Name: foo // CHECK-NEXT: Type: SHT_PROGBITS (0x1) // CHECK-NEXT: Flags [ (0x200) // CHECK-NEXT: SHF_GROUP (0x200) @@ -64,22 +64,22 @@ // CHECK-NEXT: Section: Undefined (0x0) // CHECK-NEXT: } // CHECK-NEXT: Symbol { -// CHECK-NEXT: Name: f1 (57) +// CHECK-NEXT: Name: f1 // CHECK-NEXT: Value: 0x0 // CHECK-NEXT: Size: 0 // CHECK-NEXT: Binding: Local (0x0) // CHECK-NEXT: Type: None (0x0) // CHECK-NEXT: Other: 0 -// CHECK-NEXT: Section: .group (0x5) +// CHECK-NEXT: Section: .group // CHECK-NEXT: } // CHECK-NEXT: Symbol { -// CHECK-NEXT: Name: f2 (54) +// CHECK-NEXT: Name: f2 // CHECK-NEXT: Value: 0x0 // CHECK-NEXT: Size: 0 // CHECK-NEXT: Binding: Local (0x0) // CHECK-NEXT: Type: None (0x0) // CHECK-NEXT: Other: 0 -// CHECK-NEXT: Section: .group (0x7) +// CHECK-NEXT: Section: .group // CHECK-NEXT: } // CHECK-NEXT: Symbol { // CHECK-NEXT: Name: (0) @@ -88,6 +88,6 @@ // CHECK-NEXT: Binding: Local (0x0) // CHECK-NEXT: Type: Section (0x3) // CHECK-NEXT: Other: 0 -// CHECK-NEXT: Section: foo (0x6) +// CHECK-NEXT: Section: foo (0x4) // CHECK-NEXT: } // CHECK-NEXT: ] diff --git a/test/MC/ELF/section-unique.s b/test/MC/ELF/section-unique.s index bd15148f6d8..b56666130fd 100644 --- a/test/MC/ELF/section-unique.s +++ b/test/MC/ELF/section-unique.s @@ -26,7 +26,7 @@ g: // OBJ: Binding: Global // OBJ: Type: None // OBJ: Other: 0 -// OBJ: Section: .text (0x5) +// OBJ: Section: .text (0x3) // OBJ: } // OBJ: Symbol { // OBJ: Name: g @@ -35,5 +35,5 @@ g: // OBJ: Binding: Global // OBJ: Type: None // OBJ: Other: 0 -// OBJ: Section: .text (0x6) +// OBJ: Section: .text (0x4) // OBJ: } diff --git a/test/MC/ELF/strtab-suffix-opt.s b/test/MC/ELF/strtab-suffix-opt.s index 96d15005c61..69aa0933c99 100644 --- a/test/MC/ELF/strtab-suffix-opt.s +++ b/test/MC/ELF/strtab-suffix-opt.s @@ -16,6 +16,6 @@ foobar: .Ltmp3: .size foobar, .Ltmp3-foobar -// CHECK: Name: bar (19) -// CHECK: Name: foo (23) -// CHECK: Name: foobar (16) +// CHECK: Name: bar (14) +// CHECK: Name: foo (18) +// CHECK: Name: foobar (11) -- 2.34.1