60 lines · plain
1// COFF Image-relative relocations2//3// Test that we produce image-relative relocations (IMAGE_REL_I386_DIR32NB4// and IMAGE_REL_AMD64_ADDR32NB) when accessing foo@imgrel.5 6// RUN: llvm-mc -filetype=obj -triple i686-pc-win32 %s > %t.w32.obj7// RUN: llvm-readobj -r %t.w32.obj | FileCheck --check-prefix=W32 %s8// RUN: llvm-objdump -s %t.w32.obj | FileCheck --check-prefix=W32OBJ %s9// RUN: llvm-mc -filetype=obj -triple x86_64-pc-win32 %s > %t.w64.obj10// RUN: llvm-readobj -r %t.w64.obj | FileCheck --check-prefix=W64 %s11// RUN: llvm-objdump -s %t.w64.obj | FileCheck --check-prefix=W64OBJ %s12 13.data14foo:15 .long 116 .long .Llabel@imgrel17 .rva .Llabel, .Llabel + 16, foo, .Lother - 318 19.text20.Llabel:21 mov foo@IMGREL(%ebx, %ecx, 4), %eax22.Lother:23 mov foo@imgrel(%ebx, %ecx, 4), %eax24 25// W32: Relocations [26// W32-NEXT: Section (1) .text {27// W32-NEXT: 0x3 IMAGE_REL_I386_DIR32NB foo28// W32-NEXT: 0xA IMAGE_REL_I386_DIR32NB foo29// W32-NEXT: }30// W32-NEXT: Section (2) .data {31// W32-NEXT: 0x4 IMAGE_REL_I386_DIR32NB .Llabel32// W32-NEXT: 0x8 IMAGE_REL_I386_DIR32NB .Llabel33// W32-NEXT: 0xC IMAGE_REL_I386_DIR32NB .Llabel34// W32-NEXT: 0x10 IMAGE_REL_I386_DIR32NB foo35// W32-NEXT: 0x14 IMAGE_REL_I386_DIR32NB .Lother36// W32-NEXT: }37// W32-NEXT: ]38 39// W32OBJ: Contents of section .data:40// W32OBJ-NEXT: 0000 01000000 00000000 00000000 1000000041// W32OBJ-NEXT: 0010 00000000 fdffffff42 43// W64: Relocations [44// W64-NEXT: Section (1) .text {45// W64-NEXT: 0x4 IMAGE_REL_AMD64_ADDR32NB foo46// W64-NEXT: 0xC IMAGE_REL_AMD64_ADDR32NB foo47// W64-NEXT: }48// W64-NEXT: Section (2) .data {49// W64-NEXT: 0x4 IMAGE_REL_AMD64_ADDR32NB .text50// W64-NEXT: 0x8 IMAGE_REL_AMD64_ADDR32NB .text51// W64-NEXT: 0xC IMAGE_REL_AMD64_ADDR32NB .text52// W64-NEXT: 0x10 IMAGE_REL_AMD64_ADDR32NB foo53// W64-NEXT: 0x14 IMAGE_REL_AMD64_ADDR32NB .text54// W64-NEXT: }55// W64-NEXT: ]56 57// W64OBJ: Contents of section .data:58// W64OBJ-NEXT: 0000 01000000 00000000 00000000 1000000059// W64OBJ-NEXT: 0010 00000000 0500000060