brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.8 KiB · 4071d6b Raw
78 lines · plain
1# REQUIRES: x862 3# RUN: echo -e ".global variable\n.global DllMainCRTStartup\n.text\nDllMainCRTStartup:\nret\n.data\nvariable:\n.long 42" > %t-lib.s4# RUN: llvm-mc -triple=x86_64-windows-gnu %t-lib.s -filetype=obj -o %t-lib.obj5# RUN: lld-link -out:%t-lib.dll -dll -entry:DllMainCRTStartup %t-lib.obj -lldmingw -implib:%t-lib.lib6 7# RUN: llvm-mc -triple=x86_64-windows-gnu %s -defsym listptrs=1 -filetype=obj -o %t.obj8# RUN: lld-link -lldmingw -out:%t.exe -entry:main %t.obj %t-lib.lib -verbose9 10# RUN: llvm-readobj --coff-imports %t.exe | FileCheck -check-prefix=IMPORTS %s11# RUN: llvm-objdump --no-print-imm-hex -d %t.exe | FileCheck --check-prefix=DISASM %s12# RUN: llvm-objdump -s %t.exe | FileCheck --check-prefix=CONTENTS %s13 14## Check that we can autoimport these variables with pseudo relocs disabled.15# RUN: llvm-mc -triple=x86_64-windows-gnu %s -defsym listptrs=0 -filetype=obj -o %t.noptrs.obj16# RUN: lld-link -lldmingw -runtime-pseudo-reloc:no -out:%t.exe -entry:main %t.noptrs.obj %t-lib.lib17 18## Check that we can't autoimport them with autoimport disabled.19# RUN: not lld-link -lldmingw -auto-import:no -out:%t.exe -entry:main %t.noptrs.obj %t-lib.lib 2>&1 | FileCheck --check-prefix=NO-AUTOIMPORT %s20 21# IMPORTS: Import {22# IMPORTS-NEXT: Name: autoimport-refptr.s.tmp-lib.dll23# IMPORTS-NEXT: ImportLookupTableRVA: 0x205024# IMPORTS-NEXT: ImportAddressTableRVA: 0x206025# IMPORTS-NEXT: Symbol: variable (0)26# IMPORTS-NEXT: }27 28# DISASM: Disassembly of section .text:29# DISASM-EMPTY:30# DISASM: <.text>:31# Relative offset at 0x1002 pointing at the IAT at 0x206032# DISASM: 140001000:      48 8b 05 59 10 00 00    movq    4185(%rip), %rax33# DISASM: 140001007:      8b 00   movl    (%rax), %eax34# Relative offset at 0x100b pointing at the .refptr.localvar stub at35# 0x200036# DISASM: 140001009:      48 8b 0d f0 0f 00 00    movq    4080(%rip), %rcx37# DISASM: 140001010:      03 01   addl    (%rcx), %eax38# DISASM: 140001012:      c3      retq39 40# relocs: pointing at an empty list of runtime pseudo relocs.41# localvar: 4242# CONTENTS: Contents of section .data:43# CONTENTS:  140003000 08200040 01000000 08200040 0100000044# CONTENTS:  140003010 2a00000045 46# NO-AUTOIMPORT: error: undefined symbol: variable47 48    .global main49    .global localvar50    .text51main:52    movq .refptr.variable(%rip), %rax53    movl (%rax), %eax54    movq .refptr.localvar(%rip), %rcx55    addl (%rcx), %eax56    ret57 58    .data59.if listptrs==160relocs:61    .quad __RUNTIME_PSEUDO_RELOC_LIST__62    .quad __RUNTIME_PSEUDO_RELOC_LIST_END__63.endif64localvar:65    .int 4266 67# Normally the compiler wouldn't emit a stub for a variable that is68# emitted in the same translation unit.69    .section .rdata$.refptr.localvar,"dr",discard,.refptr.localvar70    .global .refptr.localvar71.refptr.localvar:72    .quad localvar73 74    .section .rdata$.refptr.variable,"dr",discard,.refptr.variable75    .global .refptr.variable76.refptr.variable:77    .quad variable78