From 18d49acdab79d6f0966b47182b6c3a2ba3d9f80f Mon Sep 17 00:00:00 2001 From: Nico Rieck Date: Wed, 10 Apr 2013 23:28:17 +0000 Subject: MC: Support COFF image-relative MCSymbolRefs Add support for the COFF relocation types IMAGE_REL_I386_DIR32NB and IMAGE_REL_AMD64_ADDR32NB for 32- and 64-bit respectively. These are similar to normal 4-byte relocations except that they do not include the base address of the image. Image-relative relocations are used for debug information (32-bit) and SEH unwind tables (64-bit). A new MCSymbolRef variant called 'VK_COFF_IMGREL32' is introduced to specify such relocations. For AT&T assembly, this variant can be accessed using the symbol suffix '@imgrel'. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179240 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/MC/COFF/relocation-imgrel.s | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 test/MC/COFF/relocation-imgrel.s (limited to 'test/MC') diff --git a/test/MC/COFF/relocation-imgrel.s b/test/MC/COFF/relocation-imgrel.s new file mode 100644 index 0000000..ccd19ee --- /dev/null +++ b/test/MC/COFF/relocation-imgrel.s @@ -0,0 +1,29 @@ +// COFF Image-relative relocations +// +// Test that we produce image-relative relocations (IMAGE_REL_I386_DIR32NB +// and IMAGE_REL_AMD64_ADDR32NB) when accessing foo@imgrel. + +// RUN: llvm-mc -filetype=obj -triple i686-pc-win32 %s | llvm-readobj -r | FileCheck --check-prefix=W32 %s +// RUN: llvm-mc -filetype=obj -triple x86_64-pc-win32 %s | llvm-readobj -r | FileCheck --check-prefix=W64 %s + +.data +foo: + .long 1 + +.text + mov foo@IMGREL(%ebx, %ecx, 4), %eax + mov foo@imgrel(%ebx, %ecx, 4), %eax + +// W32: Relocations [ +// W32-NEXT: Section (1) .text { +// W32-NEXT: 0x3 IMAGE_REL_I386_DIR32NB foo +// W32-NEXT: 0xA IMAGE_REL_I386_DIR32NB foo +// W32-NEXT: } +// W32-NEXT: ] + +// W64: Relocations [ +// W64-NEXT: Section (1) .text { +// W64-NEXT: 0x4 IMAGE_REL_AMD64_ADDR32NB foo +// W64-NEXT: 0xC IMAGE_REL_AMD64_ADDR32NB foo +// W64-NEXT: } +// W64-NEXT: ] -- cgit v1.1