• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# REQUIRES: x86, shell
2# UNSUPPORTED: system-windows
3# RUN: split-file %s %t
4# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test.s -o %t/test.o
5# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/foo.s -o %t/foo.o
6# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/no-debug.s -o %t/no-debug.o
7## Set modtimes of the files for deterministic test output.
8# RUN: env TZ=UTC touch -t "197001010000.16" %t/test.o
9# RUN: env TZ=UTC touch -t "197001010000.32" %t/foo.o
10# RUN: rm -f %t/foo.a
11# RUN: llvm-ar rcsU %t/foo.a %t/foo.o
12
13# RUN: %lld -lSystem %t/test.o %t/foo.o %t/no-debug.o -o %t/test
14# RUN: (llvm-objdump --section-headers %t/test; llvm-nm -pa %t/test) | \
15# RUN:   FileCheck %s -DDIR=%t -DFOO_PATH=%t/foo.o
16
17## Check that we emit the right modtime even when the object file is in an
18## archive.
19# RUN: %lld -lSystem %t/test.o %t/foo.a %t/no-debug.o -o %t/test
20# RUN: (llvm-objdump --section-headers %t/test; llvm-nm -pa %t/test) | \
21# RUN:   FileCheck %s -DDIR=%t -DFOO_PATH=%t/foo.a\(foo.o\)
22
23## Check that we emit absolute paths to the object files in our OSO entries
24## even if our inputs are relative paths.
25# RUN: cd %t && %lld -lSystem test.o foo.o no-debug.o -o test
26# RUN: (llvm-objdump --section-headers %t/test; llvm-nm -pa %t/test) | \
27# RUN:   FileCheck %s -DDIR=%t -DFOO_PATH=%t/foo.o
28
29# RUN: cd %t && %lld -lSystem test.o foo.a no-debug.o -o %t/test
30# RUN: (llvm-objdump --section-headers %t/test; llvm-nm -pa %t/test) | \
31# RUN:   FileCheck %s -DDIR=%t -DFOO_PATH=%t/foo.a\(foo.o\)
32
33# CHECK:       Sections:
34# CHECK-NEXT:  Idx                Name
35# CHECK-NEXT:  [[#TEXT_ID:]]      __text
36# CHECK-NEXT:  [[#DATA_ID:]]      __data
37# CHECK-NEXT:  [[#MORE_DATA_ID:]] more_data
38# CHECK-NEXT:  [[#COMM_ID:]]      __common
39# CHECK-NEXT:  [[#MORE_TEXT_ID:]] more_text
40
41# CHECK:       0000000000000000 - 00                     0000    SO /tmp/test.cpp
42# CHECK-NEXT:  0000000000000010 - 03                     0001   OSO [[DIR]]/test.o
43# CHECK-NEXT:  [[#%x, STATIC:]] - 0[[#MORE_DATA_ID + 1]] 0000 STSYM _static_var
44# CHECK-NEXT:  [[#%x, MAIN:]]   - 0[[#TEXT_ID + 1]]      0000   FUN _main
45# CHECK-NEXT:  0000000000000006 - 00                     0000   FUN
46# CHECK-NEXT:  [[#%x, FUN:]]    - 0[[#MORE_TEXT_ID + 1]] 0000   FUN _fun
47# CHECK-NEXT:  0000000000000001 - 00                     0000   FUN
48# CHECK-NEXT:  [[#%x, GLOB:]]   - 0[[#DATA_ID + 1]]      0000  GSYM _global_var
49# CHECK-NEXT:  [[#%x, ZERO:]]   - 0[[#COMM_ID + 1]]      0000  GSYM _zero
50# CHECK-NEXT:  0000000000000000 - 01                     0000    SO
51# CHECK-NEXT:  0000000000000000 - 00                     0000    SO /foo.cpp
52# CHECK-NEXT:  0000000000000020 - 03                     0001   OSO [[FOO_PATH]]
53# CHECK-NEXT:  [[#%x, FOO:]]    - 0[[#TEXT_ID + 1]]      0000   FUN _foo
54# CHECK-NEXT:  0000000000000001 - 00                     0000   FUN
55# CHECK-NEXT:  0000000000000000 - 01                     0000    SO
56# CHECK-NEXT:  [[#STATIC]]      s _static_var
57# CHECK-NEXT:  [[#MAIN]]        T _main
58# CHECK-NEXT:  {{[0-9af]+}}     A _abs
59# CHECK-NEXT:  [[#FUN]]         S _fun
60# CHECK-NEXT:  [[#GLOB]]        D _global_var
61# CHECK-NEXT:  [[#ZERO]]        S _zero
62# CHECK-NEXT:  [[#FOO]]         T _foo
63# CHECK-NEXT:  {{[0-9af]+}}     T _no_debug
64# CHECK-EMPTY:
65
66#--- test.s
67
68## Make sure we don't create STABS entries for absolute symbols.
69.globl _abs
70_abs = 0x123
71
72.section __DATA, __data
73.globl _global_var
74_global_var:
75  .quad 123
76
77.section __DATA, more_data
78_static_var:
79  .quad 123
80
81.globl  _zero
82.zerofill __DATA,__common,_zero,4,2
83
84.text
85.globl  _main
86_main:
87Lfunc_begin0:
88  callq _foo
89  retq
90Lfunc_end0:
91
92.section  __DWARF,__debug_str,regular,debug
93  .asciz  "test.cpp"             ## string offset=0
94  .asciz  "/tmp"                 ## string offset=9
95.section  __DWARF,__debug_abbrev,regular,debug
96Lsection_abbrev:
97  .byte  1                       ## Abbreviation Code
98  .byte  17                      ## DW_TAG_compile_unit
99  .byte  1                       ## DW_CHILDREN_yes
100  .byte  3                       ## DW_AT_name
101  .byte  14                      ## DW_FORM_strp
102  .byte  27                      ## DW_AT_comp_dir
103  .byte  14                      ## DW_FORM_strp
104  .byte  17                      ## DW_AT_low_pc
105  .byte  1                       ## DW_FORM_addr
106  .byte  18                      ## DW_AT_high_pc
107  .byte  6                       ## DW_FORM_data4
108  .byte  0                       ## EOM(1)
109.section  __DWARF,__debug_info,regular,debug
110.set Lset0, Ldebug_info_end0-Ldebug_info_start0 ## Length of Unit
111  .long  Lset0
112Ldebug_info_start0:
113  .short  4                       ## DWARF version number
114.set Lset1, Lsection_abbrev-Lsection_abbrev ## Offset Into Abbrev. Section
115  .long  Lset1
116  .byte  8                       ## Address Size (in bytes)
117  .byte  1                       ## Abbrev [1] 0xb:0x48 DW_TAG_compile_unit
118  .long  0                       ## DW_AT_name
119  .long  9                       ## DW_AT_comp_dir
120  .quad  Lfunc_begin0            ## DW_AT_low_pc
121.set Lset3, Lfunc_end0-Lfunc_begin0     ## DW_AT_high_pc
122  .long  Lset3
123  .byte  0                       ## End Of Children Mark
124Ldebug_info_end0:
125.subsections_via_symbols
126.section  __DWARF,__debug_line,regular,debug
127
128.section OTHER,more_text,regular,pure_instructions
129.globl _fun
130_fun:
131  ret
132
133#--- foo.s
134.text
135.globl  _foo
136_foo:
137Lfunc_begin0:
138  retq
139Lfunc_end0:
140
141.section  __DWARF,__debug_str,regular,debug
142  .asciz  "foo.cpp"              ## string offset=0
143  .asciz  ""                     ## string offset=8
144.section  __DWARF,__debug_abbrev,regular,debug
145Lsection_abbrev:
146  .byte  1                       ## Abbreviation Code
147  .byte  17                      ## DW_TAG_compile_unit
148  .byte  1                       ## DW_CHILDREN_yes
149  .byte  3                       ## DW_AT_name
150  .byte  14                      ## DW_FORM_strp
151  .byte  27                      ## DW_AT_comp_dir
152  .byte  14                      ## DW_FORM_strp
153  .byte  17                      ## DW_AT_low_pc
154  .byte  1                       ## DW_FORM_addr
155  .byte  18                      ## DW_AT_high_pc
156  .byte  6                       ## DW_FORM_data4
157  .byte  0                       ## EOM(1)
158.section  __DWARF,__debug_info,regular,debug
159.set Lset0, Ldebug_info_end0-Ldebug_info_start0 ## Length of Unit
160  .long  Lset0
161Ldebug_info_start0:
162  .short  4                       ## DWARF version number
163.set Lset1, Lsection_abbrev-Lsection_abbrev ## Offset Into Abbrev. Section
164  .long  Lset1
165  .byte  8                       ## Address Size (in bytes)
166  .byte  1                       ## Abbrev [1] 0xb:0x48 DW_TAG_compile_unit
167  .long  0                       ## DW_AT_name
168  .long  8                       ## DW_AT_comp_dir
169  .quad  Lfunc_begin0            ## DW_AT_low_pc
170.set Lset3, Lfunc_end0-Lfunc_begin0     ## DW_AT_high_pc
171  .long  Lset3
172  .byte  0                       ## End Of Children Mark
173Ldebug_info_end0:
174.subsections_via_symbols
175.section  __DWARF,__debug_line,regular,debug
176
177#--- no-debug.s
178## This file has no debug info.
179.text
180.globl _no_debug
181_no_debug:
182  ret
183