• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// COFF Image-relative relocations
2//
3// Test that we produce image-relative relocations (IMAGE_REL_I386_DIR32NB
4// and IMAGE_REL_AMD64_ADDR32NB) when accessing foo@imgrel.
5
6// RUN: llvm-mc -filetype=obj -triple i686-pc-win32 %s > %t.w32.obj
7// RUN: llvm-readobj -r %t.w32.obj | FileCheck --check-prefix=W32 %s
8// RUN: llvm-objdump -s %t.w32.obj | FileCheck --check-prefix=W32OBJ %s
9// RUN: llvm-mc -filetype=obj -triple x86_64-pc-win32 %s > %t.w64.obj
10// RUN: llvm-readobj -r %t.w64.obj | FileCheck --check-prefix=W64 %s
11// RUN: llvm-objdump -s %t.w64.obj | FileCheck --check-prefix=W64OBJ %s
12
13.data
14foo:
15    .long 1
16    .long .Llabel@imgrel
17    .rva .Llabel, .Llabel + 16, foo, .Lother - 3
18
19.text
20.Llabel:
21    mov foo@IMGREL(%ebx, %ecx, 4), %eax
22.Lother:
23    mov foo@imgrel(%ebx, %ecx, 4), %eax
24
25// W32:      Relocations [
26// W32-NEXT:   Section (1) .text {
27// W32-NEXT:     0x3 IMAGE_REL_I386_DIR32NB foo
28// W32-NEXT:     0xA IMAGE_REL_I386_DIR32NB foo
29// W32-NEXT:   }
30// W32-NEXT:   Section (2) .data {
31// W32-NEXT:     0x4 IMAGE_REL_I386_DIR32NB .Llabel
32// W32-NEXT:     0x8 IMAGE_REL_I386_DIR32NB .Llabel
33// W32-NEXT:     0xC IMAGE_REL_I386_DIR32NB .Llabel
34// W32-NEXT:     0x10 IMAGE_REL_I386_DIR32NB foo
35// W32-NEXT:     0x14 IMAGE_REL_I386_DIR32NB .Lother
36// W32-NEXT:   }
37// W32-NEXT: ]
38
39// W32OBJ:      Contents of section .data:
40// W32OBJ-NEXT:  0000 01000000 00000000 00000000 10000000
41// W32OBJ-NEXT:  0010 00000000 fdffffff
42
43// W64:      Relocations [
44// W64-NEXT:   Section (1) .text {
45// W64-NEXT:     0x4 IMAGE_REL_AMD64_ADDR32NB foo
46// W64-NEXT:     0xC IMAGE_REL_AMD64_ADDR32NB foo
47// W64-NEXT:   }
48// W64-NEXT:   Section (2) .data {
49// W64-NEXT:     0x4 IMAGE_REL_AMD64_ADDR32NB .text
50// W64-NEXT:     0x8 IMAGE_REL_AMD64_ADDR32NB .text
51// W64-NEXT:     0xC IMAGE_REL_AMD64_ADDR32NB .text
52// W64-NEXT:     0x10 IMAGE_REL_AMD64_ADDR32NB foo
53// W64-NEXT:     0x14 IMAGE_REL_AMD64_ADDR32NB .text
54// W64-NEXT:   }
55// W64-NEXT: ]
56
57// W64OBJ:      Contents of section .data:
58// W64OBJ-NEXT:  0000 01000000 00000000 00000000 10000000
59// W64OBJ-NEXT:  0010 00000000 05000000
60