merge-sections.s
1.45 KB
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
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
# RUN: echo "SECTIONS { \
# RUN: . = SIZEOF_HEADERS; \
# RUN: .foo : { begin = .; *(.foo.*) end = .;} \
# RUN: }" > %t.script
# RUN: ld.lld -o %t1 --script %t.script %t -shared
# RUN: llvm-readobj -S --symbols %t1 | FileCheck %s
# CHECK: Name: .foo
# CHECK-NEXT: Type: SHT_PROGBITS
# CHECK-NEXT: Flags [
# CHECK-NEXT: SHF_ALLOC
# CHECK-NEXT: SHF_MERGE
# CHECK-NEXT: SHF_STRINGS
# CHECK-NEXT: ]
# CHECK-NEXT: Address: 0x[[ADDR1:.*]]
# CHECK-NEXT: Offset: 0x[[ADDR1]]
# CHECK-NEXT: Size: 8
# CHECK-NEXT: Link: 0
# CHECK-NEXT: Info: 0
# CHECK-NEXT: AddressAlignment: 2
# CHECK-NEXT: EntrySize: 0
# CHECK-NEXT: }
# CHECK: Name: begin
# CHECK-NEXT: Value: 0x[[ADDR1]]
# CHECK: Name: end
# CHECK-NEXT: Value: 0x230
# Check that we don't crash with --gc-sections
# RUN: ld.lld --gc-sections -o %t2 --script %t.script %t -shared
# RUN: llvm-readobj -S --symbols %t2 | FileCheck %s --check-prefix=GC
# GC: Name: .foo
# GC-NEXT: Type: SHT_PROGBITS
# GC-NEXT: Flags [
# GC-NEXT: SHF_ALLOC
# GC-NEXT: ]
.section .foo.1a,"aMS",@progbits,1
.asciz "foo"
.section .foo.1b,"aMS",@progbits,1
.asciz "foo"
.section .foo.2a,"aM",@progbits,1
.byte 42
.section .foo.2b,"aM",@progbits,1
.byte 42
.section .foo.3a,"aM",@progbits,2
.align 2
.short 42
.section .foo.3b,"aM",@progbits,2
.align 2
.short 42