}
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));
}
@ 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: }
@ Check the .TEST1 section
@-------------------------------------------------------------------------------
@ CHECK: Section {
-@ CHECK: Index: 6
+@ CHECK: Index: 4
@ CHECK-NEXT: Name: .TEST1
@ CHECK: Type: SHT_PROGBITS (0x1)
@-------------------------------------------------------------------------------
@ 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)
@-------------------------------------------------------------------------------
@ CHECK: }
@ CHECK: Section {
-@ CHECK: Index: 8
+@ CHECK: Index: 6
@ CHECK-NEXT: Name: .rel.ARM.extab.TEST1
@ CHECK: }
@ 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)
@-------------------------------------------------------------------------------
@ 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: }
@ 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 |../.../.|
@-------------------------------------------------------------------------------
@ 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
@-------------------------------------------------------------------------------
@ CHECK: Sections [
@ CHECK: Section {
-@ CHECK: Index: 5
+@ CHECK: Index: 3
@ CHECK-NEXT: Name: .TEST1
@ CHECK: SectionData (
@ CHECK: 0000: 1EFF2FE1 |../.|
@-------------------------------------------------------------------------------
@ 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.
@ 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 |../.|
@-------------------------------------------------------------------------------
@ 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.
@ 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 [
@ 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 [
@ 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 [
@ 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 [
@ 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
// 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
// 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
// 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
// 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 [
// 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 [
// 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 [
// 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: }
// 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 {
// 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
// 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
// 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 [
gen_sections16384 b\x
.endm
+ .section foo
+ .section bar
+
gen_sections32768 a
gen_sections16384 b
gen_sections8192 c
gen_sections4 m
.section foo
+ .section foo2
+ .section foo3
.section bar, "a"
a:
gen_sections32 j
gen_sections16 k
gen_sections8 l
- .section foo
- .section bar
+gen_sections4 m
.section zed
.long zed
// 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)
// 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)
// 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)
// 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: ]
// OBJ: Binding: Global
// OBJ: Type: None
// OBJ: Other: 0
-// OBJ: Section: .text (0x5)
+// OBJ: Section: .text (0x3)
// OBJ: }
// OBJ: Symbol {
// OBJ: Name: g
// OBJ: Binding: Global
// OBJ: Type: None
// OBJ: Other: 0
-// OBJ: Section: .text (0x6)
+// OBJ: Section: .text (0x4)
// OBJ: }
.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)