xref: /llvm-project/lld/test/ELF/cref.s (revision 43b13341fbbb718223484a79a539a3c13062f39f)
1// REQUIRES: x86
2
3// RUN: echo '.global foo; foo:' | llvm-mc -filetype=obj -triple=x86_64-pc-linux - -o %t1.o
4// RUN: echo '.global foo, bar; bar:' | llvm-mc -filetype=obj -triple=x86_64-pc-linux - -o %t2.o
5// RUN: echo '.global zed; zed:' | llvm-mc -filetype=obj -triple=x86_64-pc-linux - -o %ta.o
6// RUN: echo 'abs1 = 42;' > %t.lds
7// RUN: rm -f %t.a
8// RUN: llvm-ar rcs %t.a %ta.o
9// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t3.o
10// RUN: ld.lld -shared -o %t1.so %t1.o
11// RUN: ld.lld -o /dev/null %t1.so %t2.o %t3.o %t.a %t.a %t.lds --defsym abs2=43 --gc-sections --cref | FileCheck -strict-whitespace %s
12
13/// If -Map is specified, print to the map file.
14// RUN: ld.lld -o /dev/null %t1.so %t2.o %t3.o %t.a --gc-sections -Map=%t.map --cref
15// RUN: FileCheck --input-file=%t.map %s --check-prefix=CHECK2
16
17// CHECK:      {{^$}}
18// CHECK-NEXT: Cross Reference Table
19// CHECK-EMPTY:
20// CHECK-NEXT: Symbol                                            File
21// CHECK-NEXT: foo                                               {{.*}}1.so
22// CHECK-NEXT:                                                   {{.*}}2.o
23// CHECK-NEXT:                                                   {{.*}}3.o
24// CHECK-NEXT: bar                                               {{.*}}2.o
25// CHECK-NEXT:                                                   {{.*}}3.o
26// CHECK-NEXT: _start                                            {{.*}}3.o
27// CHECK-NEXT: baz                                               {{.*}}3.o
28// CHECK-NEXT: zed                                               {{.*}}.a({{.*}}a.o)
29// CHECK-NEXT:                                                   {{.*}}3.o
30// CHECK-NEXT: abs1                                              {{.*}}.lds:1
31// CHECK-NEXT:                                                   {{.*}}3.o
32// CHECK-NEXT: abs2                                              --defsym{{$}}
33// CHECK-NEXT:                                                   {{.*}}3.o
34// CHECK-NOT:  discarded
35
36// CHECK2:         VMA              LMA     Size Align Out     In      Symbol
37// CHECK2:      .strtab
38// CHECK2-NEXT:         <internal>:(.strtab)
39
40/// There is a blank line before the "Cross Reference Table" header.
41// CHECK2-EMPTY:
42// CHECK2-NEXT: Cross Reference Table
43
44.global _start, foo, bar, baz, discarded
45_start:
46  call foo
47  call bar
48  call zed
49localsym:
50baz:
51
52.section .text.a,"ax",@progbits
53discarded:
54
55.data
56.quad abs1
57.quad abs2
58