xref: /llvm-project/lld/test/COFF/autoimport-debug.s (revision d17db6066d2524856fab493dd894f8396e896bc7)
1# REQUIRES: x86
2# RUN: split-file %s %t.dir
3
4## We've got references to variable both in a .refptr and in .debug_info.
5## The .debug_info section should be discardable, so no pseudo relocations
6## need to be created in it. The .refptr section should be elimiated
7## and redirected to __imp_variable instead, so we shouldn't need to
8## create any runtime pseudo relocations. Thus, test that we can link
9## successfully with -runtime-pseudo-reloc:no, while keeping the
10## debug info.
11
12# RUN: llvm-mc -triple=x86_64-windows-gnu %t.dir/lib.s -filetype=obj -o %t.dir/lib.obj
13# RUN: lld-link -out:%t.dir/lib.dll -dll -entry:DllMainCRTStartup %t.dir/lib.obj -lldmingw -implib:%t.dir/lib.lib
14
15# RUN: llvm-mc -triple=x86_64-windows-gnu %t.dir/main.s -filetype=obj -o %t.dir/main.obj
16# RUN: lld-link -lldmingw -out:%t.dir/main.exe -entry:main %t.dir/main.obj %t.dir/lib.lib -opt:noref -debug:dwarf -runtime-pseudo-reloc:no
17
18#--- main.s
19    .global main
20    .text
21main:
22    movq .refptr.variable(%rip), %rax
23    ret
24
25    .section .rdata$.refptr.variable,"dr",discard,.refptr.variable
26    .global .refptr.variable
27.refptr.variable:
28    .quad   variable
29
30    .section .debug_info
31    .long 1
32    .quad variable
33    .long 2
34
35#--- lib.s
36    .global variable
37    .global DllMainCRTStartup
38    .text
39DllMainCRTStartup:
40    ret
41    .data
42variable:
43    .long 42
44