File: wrap-dllimport.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 (42 lines) | stat: -rw-r--r-- 1,320 bytes parent folder | download | duplicates (21)
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
// REQUIRES: x86

// Check that we can wrap a dllimported symbol, so that references to
// __imp_<symbol> gets redirected to a defined local import instead.

// RUN: split-file %s %t.dir
// RUN: llvm-mc -filetype=obj -triple=i686-win32-gnu %t.dir/main.s -o %t.main.obj
// RUN: llvm-mc -filetype=obj -triple=i686-win32-gnu %t.dir/other.s -o %t.other.obj

// RUN: lld-link -dll -out:%t.dll %t.other.obj -noentry -safeseh:no -export:foo -implib:%t.lib
// RUN: lld-link -out:%t.exe %t.main.obj %t.lib -entry:entry -subsystem:console -debug:symtab -safeseh:no -wrap:foo -lldmap:%t.map
// RUN: llvm-objdump -s -d --print-imm-hex %t.exe | FileCheck %s

// CHECK:      Contents of section .rdata:
// CHECK-NEXT:  402000 06104000

// CHECK:      Disassembly of section .text:
// CHECK-EMPTY:
// CHECK:      00401000 <_entry>:
// CHECK-NEXT:   401000: ff 25 00 20 40 00             jmpl    *0x402000
// CHECK-EMPTY:
// CHECK-NEXT: 00401006 <___wrap_foo>:
// CHECK-NEXT:   401006: c3                            retl

// The jmpl instruction in _entry points at an address in 0x402000,
// which is the first 4 bytes of the .rdata section (above), which is a
// pointer that points at ___wrap_foo.

#--- main.s
.global _entry
_entry:
  jmpl *__imp__foo

.global ___wrap_foo
___wrap_foo:
  ret

#--- other.s
.global _foo

_foo:
  ret