File: literal-dedup.s

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (114 lines) | stat: -rw-r--r-- 3,363 bytes parent folder | download | duplicates (14)
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# REQUIRES: x86
# RUN: rm -rf %t; split-file %s %t
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test.s -o %t/test.o
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/qux.s -o %t/qux.o
# RUN: %lld -dylib %t/test.o %t/qux.o -o %t/test
# RUN: llvm-objdump --macho --section="__TEXT,__literals" --section="__DATA,ptrs" --syms %t/test | FileCheck %s
# RUN: llvm-readobj --section-headers %t/test | FileCheck %s --check-prefix=HEADER

# RUN: %lld -dylib -no_deduplicate %t/test.o %t/qux.o -o %t/test
# RUN: llvm-objdump --macho --section="__TEXT,__literals" --section="__DATA,ptrs" --syms %t/test | FileCheck %s
# RUN: llvm-readobj --section-headers %t/test | FileCheck %s --check-prefix=HEADER

# CHECK:      Contents of (__TEXT,__literals) section
# CHECK-NEXT: [[#%.16x,DEADBEEF16:]] ef be ad de ef be ad de ef be ad de ef be ad de
# CHECK-NEXT: [[#%.16x,FEEDFACE16:]] ce fa ed fe ce fa ed fe ce fa ed fe ce fa ed fe
# CHECK-NEXT: [[#%.16x,DEADBEEF8:]]  ef be ad de ef be ad de ce fa ed fe ce fa ed fe
# CHECK-NEXT: [[#%.16x,DEADBEEF4:]]  ef be ad de ce fa ed fe
# CHECK-NEXT: Contents of (__DATA,ptrs) section
# CHECK-NEXT: 0000000000001000  0x[[#%x,DEADBEEF16]]
# CHECK-NEXT: 0000000000001008  0x[[#%x,DEADBEEF16]]
# CHECK-NEXT: 0000000000001010  0x[[#%x,FEEDFACE16]]
# CHECK-NEXT: 0000000000001018  0x[[#%x,DEADBEEF16]]
# CHECK-NEXT: 0000000000001020  0x[[#%x,DEADBEEF8]]
# CHECK-NEXT: 0000000000001028  0x[[#%x,DEADBEEF8]]
# CHECK-NEXT: 0000000000001030  0x[[#%x,DEADBEEF8 + 8]]
# CHECK-NEXT: 0000000000001038  0x[[#%x,DEADBEEF8]]
# CHECK-NEXT: 0000000000001040  0x[[#%x,DEADBEEF4]]
# CHECK-NEXT: 0000000000001048  0x[[#%x,DEADBEEF4]]
# CHECK-NEXT: 0000000000001050  0x[[#%x,DEADBEEF4 + 4]]
# CHECK-NEXT: 0000000000001058  0x[[#%x,DEADBEEF4]]

## Make sure the symbol addresses are correct too.
# CHECK:     SYMBOL TABLE:
# CHECK-DAG: [[#DEADBEEF16]] g     O __TEXT,__literals _qux16
# CHECK-DAG: [[#DEADBEEF8]]  g     O __TEXT,__literals _qux8
# CHECK-DAG: [[#DEADBEEF4]]  g     O __TEXT,__literals _qux4

## Make sure we set the right alignment and flags.
# HEADER:        Name: __literals
# HEADER-NEXT:   Segment: __TEXT
# HEADER-NEXT:   Address:
# HEADER-NEXT:   Size:
# HEADER-NEXT:   Offset:
# HEADER-NEXT:   Alignment: 4
# HEADER-NEXT:   RelocationOffset:
# HEADER-NEXT:   RelocationCount: 0
# HEADER-NEXT:   Type: Regular
# HEADER-NEXT:   Attributes [ (0x0)
# HEADER-NEXT:   ]
# HEADER-NEXT:   Reserved1: 0x0
# HEADER-NEXT:   Reserved2: 0x0
# HEADER-NEXT:   Reserved3: 0x0

#--- test.s
.literal4
.p2align 2
L._foo4:
  .long 0xdeadbeef
L._bar4:
  .long 0xdeadbeef
L._baz4:
  .long 0xfeedface

.literal8
L._foo8:
  .quad 0xdeadbeefdeadbeef
L._bar8:
  .quad 0xdeadbeefdeadbeef
L._baz8:
  .quad 0xfeedfacefeedface

.literal16
L._foo16:
  .quad 0xdeadbeefdeadbeef
  .quad 0xdeadbeefdeadbeef
L._bar16:
  .quad 0xdeadbeefdeadbeef
  .quad 0xdeadbeefdeadbeef
L._baz16:
  .quad 0xfeedfacefeedface
  .quad 0xfeedfacefeedface

.section __DATA,ptrs,literal_pointers
.quad L._foo16
.quad L._bar16
.quad L._baz16
.quad _qux16

.quad L._foo8
.quad L._bar8
.quad L._baz8
.quad _qux8

.quad L._foo4
.quad L._bar4
.quad L._baz4
.quad _qux4

#--- qux.s
.globl _qux4, _qux8, _qux16

.literal4
.p2align 2
_qux4:
  .long 0xdeadbeef

.literal8
_qux8:
  .quad 0xdeadbeefdeadbeef

.literal16
_qux16:
  .quad 0xdeadbeefdeadbeef
  .quad 0xdeadbeefdeadbeef