aboutsummaryrefslogtreecommitdiff
path: root/test/ELF/end.s
blob: 390e4445e2d8348718999aa6bdae8f8b6d57a456 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// Should set the value of the "_end" symbol to the end of the data segment.
// REQUIRES: x86

// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o

// By default, the .bss section is the latest section of the data segment.
// RUN: ld.lld %t.o -o %t
// RUN: llvm-readobj -sections -symbols %t | FileCheck %s --check-prefix=DEFAULT

// DEFAULT: Sections [
// DEFAULT:     Name: .bss
// DEFAULT-NEXT:     Type:
// DEFAULT-NEXT:     Flags [
// DEFAULT-NEXT:       SHF_ALLOC
// DEFAULT-NEXT:       SHF_WRITE
// DEFAULT-NEXT:     ]
// DEFAULT-NEXT:     Address: 0x12002
// DEFAULT-NEXT:     Offset:
// DEFAULT-NEXT:     Size: 6
// DEFAULT: ]
// DEFAULT: Symbols [
// DEFAULT:     Name: _end
// DEFAULT-NEXT:     Value: 0x12008
// DEFAULT: ]

// If there is no .bss section, "_end" should point to the end of the .data section.
// RUN: echo "SECTIONS { \
// RUN:          /DISCARD/ : { *(.bss) } }" > %t.script
// RUN: ld.lld %t.o --script %t.script -o %t
// RUN: llvm-readobj -sections -symbols %t | FileCheck %s --check-prefix=NOBSS

// NOBSS: Sections [
// NOBSS:     Name: .data
// NOBSS-NEXT:     Type:
// NOBSS-NEXT:     Flags [
// NOBSS-NEXT:       SHF_ALLOC
// NOBSS-NEXT:       SHF_WRITE
// NOBSS-NEXT:     ]
// NOBSS-NEXT:     Address: 0x12000
// NOBSS-NEXT:     Offset:
// NOBSS-NEXT:     Size: 2
// NOBSS: ]
// NOBSS: Symbols [
// NOBSS:     Name: _end
// NOBSS-NEXT:     Value: 0x12002
// NOBSS: ]

// If the layout of the sections is changed, "_end" should point to the end of allocated address space.
// RUN: echo "SECTIONS { \
// RUN:          .bss : { *(.bss) } \
// RUN:          .data : { *(.data) } \
// RUN:          .text : { *(.text) } }" > %t.script
// RUN: ld.lld %t.o --script %t.script -o %t
// RUN: llvm-readobj -sections -symbols %t | FileCheck %s --check-prefix=TEXTATEND

// TEXTATEND: Sections [
// TEXTATEND:     Name: .text
// TEXTATEND-NEXT:     Type:
// TEXTATEND-NEXT:     Flags [
// TEXTATEND-NEXT:       SHF_ALLOC
// TEXTATEND-NEXT:       SHF_EXECINSTR
// TEXTATEND-NEXT:     ]
// TEXTATEND-NEXT:     Address: 0x12000
// TEXTATEND-NEXT:     Offset:
// TEXTATEND-NEXT:     Size: 1
// TEXTATEND: ]
// TEXTATEND: Symbols [
// TEXTATEND:     Name: _end
// TEXTATEND-NEXT:     Value: 0x12001
// TEXTATEND: ]

.global _start,_end
.text
_start:
    nop
.data
    .word 1
.bss
    .space 6